fix: enhance native flamegraph to handle empty sample counts#647
Open
harp-intel wants to merge 1 commit intomainfrom
Open
fix: enhance native flamegraph to handle empty sample counts#647harp-intel wants to merge 1 commit intomainfrom
harp-intel wants to merge 1 commit intomainfrom
Conversation
…tests Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the mergeSystemFolded function in the flamegraph command to gracefully handle empty input scenarios. Previously, the function would error if either input was empty; now it only errors when both inputs are empty, and falls back to using whichever input is available when only one is empty. This is a practical improvement for real-world scenarios where one profiling method might fail or produce no samples while the other succeeds.
Changes:
- Modified error handling in
mergeSystemFoldedto only error when both fp and dwarf sample counts are zero - Added fallback logic to use dwarf stacks when fp is empty, and vice versa, with appropriate warning logs
- Added comprehensive unit tests covering all three edge cases: fp empty, dwarf empty, and both empty
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/flamegraph/flamegraph_tables.go | Enhanced mergeSystemFolded to handle empty inputs with fallback logic and clearer error messages |
| cmd/flamegraph/flamegraph_tables_test.go | Added new test file with tests for empty input scenarios and helper function for parsing folded stacks |
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.
This pull request improves the handling of empty input cases in the
mergeSystemFoldedfunction and adds comprehensive unit tests to verify the new behaviors. The changes ensure that the function gracefully handles scenarios where either or both of the input folded stack traces are empty, and provides better logging and error messages.Enhanced error handling and logging:
mergeSystemFoldedinflamegraph_tables.goto:fpanddwarfsample counts are zero, with a clearer error message.Testing improvements:
flamegraph_tables_test.gowith tests for: