Skip to content

Commit

Permalink
Add performance optimization for Java (#117)
Browse files Browse the repository at this point in the history
* Add performance optimization for Java

* Update code comment
  • Loading branch information
DarcyRaynerDD authored Feb 17, 2023
1 parent 9a0272a commit dc8fcd3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/datadog_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,24 @@ then
fi
export DD_JMXFETCH_ENABLED="false"
export DD_RUNTIME_METRICS_ENABLED="false"
export DD_REMOTE_CONFIG_ENABLED="false"

DD_Agent_Jar=/opt/java/lib/dd-java-agent.jar
if [ -f "$DD_Agent_Jar" ]
then
export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -javaagent:$DD_Agent_Jar -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
# Removes the -XX:-TieredCompilation flag from the java command passed
# through from the Lambda runtime. Allows the JVM to use the C1 compiler
# and Interpreter, which is much faster on cold start and
# uses less memory.
START_COMMAND=${args[0]}
REMAINDER_ARGS=("${args[@]:1}")
for index in "${!REMAINDER_ARGS[@]}" ; do
[[ ${REMAINDER_ARGS[$index]} == "-XX:-TieredCompilation" ]] && unset -v 'REMAINDER_ARGS[$index]' ;
done
REMAINDER_ARGS="${REMAINDER_ARGS[@]}"
# -XX:TieredStopAtLevel=1 tells the compiler to stop at the C1 compiler
args=($START_COMMAND -javaagent:$DD_Agent_Jar -XX:TieredStopAtLevel=1 ${REMAINDER_ARGS[@]})

else
echo "File $DD_Agent_Jar does not exist!"
fi
Expand Down

0 comments on commit dc8fcd3

Please sign in to comment.