-
Notifications
You must be signed in to change notification settings - Fork 349
memory profiling: heap memory profiling at runtime #6525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| CONFIG_PERFORMANCE_COUNTERS=y | ||
| CONFIG_SYS_HEAP_RUNTIME_STATS=y | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a debug overlay @kv2019i ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense if put is as default debug overlay, since its functionality is for stack overflow detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry not following how the heap state helps with stack overflow detection, is this a different Zephyr option ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are separate functionality, no relation between heap and stack overflow detection.
CONFIG_SYS_HEAP_RUNTIME_STATS is used to collect heap allocated/free space, total is around 1.4MB.
CONFIG_STACK_SENTINEL this is used to enable stack overflow detection by check a magic number in the stack bottom, after enable this, once stack overflow happened, Zephyr logging will print "Stack overflow" with other information, so move it to debug build config is also good, please let me know, if you want to move it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#6530
this already added, @kv2019i , do you think I need remove here?
once remove, I need add -d option for perf build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@btian1 see above, we need these 2 Kconfigs to allow the developers to tune the output depending on what they are debugging.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood , I did not find in current SOF code base, add it from new and then add code to make these config work?
I also want to add this at the beginning, however, due to wrapped too much layer, I did not try with this.
It may need introduce new parameters for each function and code change may be big, any better ideas?
rmalloc/rzalloc...., need add pipeline and component info for each memory alloc and free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood Maybe add "
DEBUG" or "PRINT" somewhere? Otherwise this option looks to me like it enables heap allocations and without itrmalloc()won't work. Same forSOF_HEAP_RUNTIME_PIPELINEperhapsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also suspect that those options would have quite a large run-time / logging impact, so I'd really rather have them off by default and only enable them for debugging. The former would supposedly "only" print one line for each allocations, but we allocate quite a lot. We have many instances where we initialise a single functionality but use several allocations for it. Hopefully we don't allocate any memory for each
.copy()/.process()iteration, but even when one pipeline is running and another one processes IPCs which will print excessive additional information for memory allocations - that can affect performance of the running pipeline.Same holds for heap state dumps for each pipeline creation and destruction. Especially since we now have multiple pipelines for most or all streams. I know we have those dumps with XTOS and I find them quite intrusive and excessively polluting logs too (see #4744 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RanderWang , Rander today introduced that close fw alloc memory based on pipeline, this is much more easy to do data collection and analysis.
For SOF, allocation based on rmalloc, any code call this module can get a buffer with specific size, the difficult part is we have to add all called place with pipe and component information.