Configurable NativeSpaceProfiler samplingInterval #5725
Closed
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?
Allow users of ddtrace to configure samplingIntervals for the NativeSpaceProfiler.
Motivation
Heap sampling rate needs to be configurable for JS applications that have very high allocation rates. In services, with high allocation rates, the default sampling interval can cause unacceptable slow downs. This change allows users to find a more appropriate heap sampling rate that is tuned to their application's allocation rate.
Prior to this Wall, Events, and Space Profilers were all referencing the same option: samplingInterval, however, they had different units. NativeWallProfiler and EventsProfiler expected samplingInterval to be in hertz, and NativeSpaceProfiler expected samplingInterval to be in number of bytes between samples. This and the lack of environment variable support made it impossible for users to configure the NativeSpaceProfiler samplingInterval.
Additional Notes
This breaks the API of NativeSpaceProfiler since it switches from accepting samplingInterval to accepting heapSamplingInterval. That said, this is not a publicly exported class, so it seems acceptable to make this change in a non-backwards compatible way. If that is not acceptable, it would also be possible to update this change to allow for both samplingInterval and heapSamplingInterval and give the latter precedence. I did not do that, because it seemed to add unnecessary complexity to the profiler.
Tests
All of the following tests have been verified locally: