Add -N/--max-depth-outer to keep the outermost frames - #163
Merged
Merged
Conversation
-n keeps the innermost frames, which is the wrong end for attributing a sample to a phase of the program. With -n 30 on a 100-deep recursion you get the leaf detail and lose the ability to say whether the sample is under parseFile or analyzeFile -- which, on a long multi-stage job, is usually the question worth answering. -N keeps the outermost frames instead, and the two compose: -n 2 -N 2 keeps both ends and elides the middle. Keeping the outermost frames means knowing the depth before emitting anything, so trace_stack gains a counting pre-pass. It copies only the prev_execute_data pointer rather than each frame, and is skipped entirely unless -N is given, so nothing changes for existing invocations. The emitted sequence always begins at depth 0: when the innermost frames are themselves elided, the marker takes depth 0. stackcollapse-phpspy.pl flushes its accumulated stack on depth 0, so without that every trace in a file would silently merge into one. The marker's function token is whitespace-free (`<elided:19>`) because both that script and top.c split frame lines on spaces, and `#`-prefixed lines were not an option for the same reason. Stack walks are bounded by PHPSPY_MAX_STACK_WALK, since a torn read of prev_execute_data could otherwise loop forever -- a latent issue in the existing single-pass walk too. -N composes usefully with -b: capping the stack is the cheapest way to keep deep traces inside the per-trace output budget. Co-authored-by: Adam Saponara <as@php.net>
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.
#160 with some merge conflicts fixed, and one perf optimization. (With -N, we save the stack frame pointers when measuring depth, so we don't have to remote copy them again.)