Repository navigation
Conversation
Object serialization builds Sample and Label objects for callers that only need bytes. Writing samples directly avoids retaining that object graph without changing the existing object-returning methods.
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 18 Pipeline jobs failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: dcadfda | Docs | View more details | Give us feedback! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?:
Add
time.stopEncoded()andheap.profileEncoded(). Callers can encode the collected snapshot without buildingSampleandLabelobjects. The existing object-returning methods stay unchanged.Motivation:
Changing the encoder in the tracer is too late to avoid those allocations. The profiler can write samples directly as it visits them.
In the 6,500-sample wall-profile benchmark, the writer retained about 0.6 MiB instead of 3.2 MiB and reduced median total time from 4.5–4.7 ms to 2.7–2.8 ms. Median synchronous work rose from 1.7 ms to 2.5–2.6 ms.
Additional Notes:
Do not merge until DataDog/pprof-format#126 ships the
ProfileWritermethods used here. Update the codec dependency and lockfile to that release, then runnpm ciandnpm run compile. DataDog/dd-trace-js#11302 will still use the object encoder until it pins a compatible@datadog/pprofrelease.How to test the change?:
Local verification used a codec tarball from the staged writer revision of DataDog/pprof-format#126. That revision is not yet pushed. The current PR head and published codec lack the writer methods this branch needs. With the paired codec installed, run
npm run test:jsto check the encoded wall and heap paths against the existing object paths, andnode --expose-gc benchmark/direct-profile-writer.cjsto compare the serializers.On Node 26.3.1, 158 tests passed on this branch versus 154 on
mainat3905f38. Both runs skipped 63 tests and failed the same assertion: the allocation OOM fixture dumped a profile but exited without a fatal error.