Skip to content

Commit

Permalink
Move snapshot UUID generation at serialization (#7280)
Browse files Browse the repository at this point in the history
UUID generation is not cheap, and therefore should be performed only
when the snapshot is about to be sent.
Moving UUID generation at serialization time makes it out of the
critical path.
  • Loading branch information
jpbempel committed Jul 5, 2024
1 parent 23a8164 commit 3aea13c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variables:
timeout: 1h
tags: ["runner:apm-k8s-tweaked-metal"]
image: $BASE_CI_IMAGE
needs: [ "build" ]
script:
- export ARTIFACTS_DIR="$(pwd)/reports" && mkdir -p "${ARTIFACTS_DIR}"
- export CIRCLE_CI_TOKEN=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.circleci_token --with-decryption --query "Parameter.Value" --out text)
Expand Down Expand Up @@ -80,6 +81,7 @@ benchmarks-post-results:
interruptible: true
timeout: 1h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:java-dsm-kafka
needs: [ "build" ]
script:
- git clone --branch java/kafka-dsm-overhead https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform.git platform && cd platform
- ./steps/run-benchmarks.sh
Expand Down Expand Up @@ -117,6 +119,7 @@ debugger-benchmarks:
interruptible: true
timeout: 1h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/benchmarking-platform:java-debugger
needs: ["build"]
script:
- export ARTIFACTS_DIR="$(pwd)/reports" && mkdir -p "${ARTIFACTS_DIR}"
- git clone --branch java/debugger-benchmarks https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform.git /platform && cd /platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class Snapshot {
private String exceptionId;

public Snapshot(java.lang.Thread thread, ProbeImplementation probeImplementation, int maxDepth) {
this.id = UUID.randomUUID().toString();
this.version = VERSION;
this.timestamp = System.currentTimeMillis();
this.captures = new Captures();
Expand Down Expand Up @@ -105,6 +104,10 @@ public void addCaughtExceptions(List<CapturedContext.CapturedThrowable> throwabl
}

public String getId() {
// lazily generates snapshot id
if (id == null) {
id = UUID.randomUUID().toString();
}
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public boolean offer(Snapshot snapshot) {
}

String serializeSnapshot(String serviceName, Snapshot snapshot) {
snapshot.getId(); // Ensure id is generated
String str = DebuggerAgent.getSnapshotSerializer().serializeSnapshot(serviceName, snapshot);
String prunedStr = SnapshotPruner.prune(str, MAX_SNAPSHOT_SIZE, 4);
if (prunedStr.length() != str.length()) {
Expand Down

0 comments on commit 3aea13c

Please sign in to comment.