Conversation
newSourcePrinter accumulated cum[addr] += value for every frame of every sample. For a recursive function the same address is on the stack many times within one sample, so the sample was added to that address once per frame. Count each address at most once per sample instead, the same way newGraph does with its seenNode set. flat is only accumulated for the leaf frame, so it is unaffected. Updates google#707.
Author
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.


Updates #707. This is the first of two PRs; the analysis is in #707 (comment).
newSourcePrinterdidcum[addr] += valuefor every frame of every sample. With recursion the same address is on the stack many times within one sample, so the sample was added to that address once per frame. On a CPU profile of a recursivefib(total 310ms), one 10ms sample with 29fibframes added 190ms to one call instruction and 90ms to the other.This counts each address at most once per sample, the same way
newGraphdoes with itsseenNodeset. It affects-weblistand the web UI Source page, which both go throughMakeWebList.It looks like a regression from #599 (cbba55b). Before that, weblist went through
rpt.newGraphand got the deduplication for free. The README documents the rule this restores: "Samples that include a location multiple times (e.g. for recursive functions) are counted only once per location."Effect on the
fibprofile:The values after the change are the ones
-disasmalready reports for the same profile. They are still above 100% because the header is a sum over instructions that one recursive sample contributes to more than once. That is a separate cause with a separate fix (the second PR), so this one saysUpdates, notFixes.What doesn't change:
flat, which is only added for the leaf frame; weblist output for profiles without recursion, which I checked is byte-for-byte identical on testdata/sample.bin + sample.cpu; and every other view, since nothing else usesnewSourcePrinter.The test has two samples. In one the recursive call address is the leaf as well as an outer frame, which also pins down that
flatis still counted when the address has already been seen. Moving theflatupdate inside the newifwould make it fail.