Fix excessive memory allocation for sched_times (#320)#389
Merged
Conversation
florianl
approved these changes
Mar 18, 2025
gnurizen
approved these changes
Mar 18, 2025
rockdaboot
reviewed
Mar 19, 2025
Comment on lines
+553
to
+555
| // second (1000hz) multiplied by an average time a task remains off CPU (3s), | ||
| // scaled by the probability of capturing a trace. | ||
| adaption["sched_times"] = (4096 * cfg.OffCPUThreshold) / support.OffCPUThresholdMax |
Contributor
There was a problem hiding this comment.
Not a blocker, but it is not obvious to me how 4096 reflects the mentioned "average time a task remains off CPU (3s)". How exactly has the number 4096 been determined and is this the the best value or does it need further refinement?
rockdaboot
approved these changes
Mar 19, 2025
This was referenced Apr 4, 2025
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.
Summary
On my 16 core local system (VM, possibleCPUs:128, onlineCPUs:16), the previous logic allocated more than 5GB of kernel memory as worst-case (with
off-cpu-thresholdset to 1000) and the agent took ~20 seconds to start due to swapping.This PR reduces the worst-case down to 5MB.
Fixes #320.
Also see #320 (comment).