Skip to content
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

Temporal flamegraphs #317

Merged
merged 12 commits into from
Feb 24, 2023
Merged

Conversation

godlygeek
Copy link
Contributor

@godlygeek godlygeek commented Feb 9, 2023

I'm leaving off the news and docs for now, as I'd still like to do some more refactoring here (possibly putting this under a new subcommand, rather than putting it under a flag for the existing flamegraph reporter).

I should probably add some automated tests as well... but other than that, this should be in a reviewable state.

@godlygeek godlygeek self-assigned this Feb 9, 2023
@godlygeek godlygeek force-pushed the temporal_flamegraphs branch 3 times, most recently from fb7695c to e733d5f Compare February 9, 2023 04:57
@godlygeek godlygeek marked this pull request as ready for review February 9, 2023 04:57
@godlygeek godlygeek force-pushed the temporal_flamegraphs branch 2 times, most recently from 8093b66 to f4dbebe Compare February 10, 2023 00:00
@godlygeek
Copy link
Contributor Author

@pablogsal Since you've started looking at this, I pushed one commit as a fixup that corrects some minor issues noticed while testing, rather than force pushing fixes to code you've already started reviewing.

We'll need to make sure to apply the fixup before landing this.

Anyway, there's tests now! 🥳

@pablogsal
Copy link
Member

pablogsal commented Feb 16, 2023

Anyway, there's tests now! 🥳

Ah, but someone forgot to signup the commits :P 😆

@godlygeek
Copy link
Contributor Author

Ah, but someone forgot to signup the commits :P 😆

Ah, only the fixup, which I deliberately avoided signing to remind us that we needed to squash it :P

@pablogsal pablogsal added this to the Q1 2023 milestone Feb 21, 2023
src/memray/_memray.pyx Outdated Show resolved Hide resolved
@pablogsal
Copy link
Member

pablogsal commented Feb 23, 2023

One thing I noticed, we should change the title in the flamegraph because right now it shows temporal_flamegraph:

Screenshot 2023-02-23 at 14 03 39

src/memray/_memray.pyx Outdated Show resolved Hide resolved
@godlygeek
Copy link
Contributor Author

The force push I just did should address the new concerns you raised, plus some minor things I noticed: the unnecessary vector copy, our help button text not mentioning the sliders, our title not including "(memory leaks)", and the warning about generating the report without tracking Python allocators not showing up.

@godlygeek
Copy link
Contributor Author

Whoops, one more force push - I missed updating TemporalAllocationRecord to not be a subclass of AllocationRecord in the extension module's type stubs.

@godlygeek
Copy link
Contributor Author

Whoops, one more force push - I missed updating TemporalAllocationRecord to not be a subclass of AllocationRecord in the extension module's type stubs.

Which also surfaced another type warning. I just shut it up with a # type: ignore, since that's code that I plan on refactoring as soon as we land this PR.

For each snapshot, report the allocations performed between that
snapshot and the next, grouped by location, and also report which
snapshot each of those allocations is freed in.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Create a template page for a new type of flame graph. Initially this is
just an exactly copy of our existing flame graph template, to make the
changes from the original stand out as diffs in future commits.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Allow generating flame graphs with a temporal dimension, which are able
to show the allocations performed in some range and not deallocated
before the end of that range.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
`SIZE_MAX` is a helpful marker for us to work within the C++ layer, but
translating this to `None` in the Python layer and `null` in the
JavaScript layer makes things easier and more intuitive to work with,
and avoids having a magic number (different for 32 vs 64 bit builds!)
leak into our public interface.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Previously we were postprocessing the aggregated records to handle the
`merge_threads` option, but we can instead just preprocess the records
fed into the aggregator, so that the aggregator uses the right key from
the start.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
This will allow the same stack trace creation logic to be shared by
multiple types of allocation records.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Instead, make it its own type, analogous to `AllocationRecord` but
without the `address`, `n_allocations`, and `size` properties, and
instead with an `intervals` property that holding a list of intervals,
each with an `n_allocations` and `n_bytes`, as well as
an `allocated_before_snapshot` and `deallocated_before_snapshot`
indicating which time ranges that allocation was alive for.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Make some methods that always should have been `const` actually be
`const`, and improve the comments to clarify why this method needs an
intermediate hash table.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
When the report is first rendered, before the user has interacted with
it at all, we want to show the same set of leaked allocations as the
old, non-temporal leaks report would show. This means that we need to
include deallocations that occurred after the final snapshot, but before
tracking stopped.

To achieve that, we need to adjust our treatment of the "end" index
chosen by the user, including allocations and deallocations that
occurred between that snapshot and the next one (in other words,
treating it as inclusive rather than exclusive).

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Previously the rendered HTML contained "temporal_flamegraph report". Fix
it to say "temporal flamegraph report (memory leaks)" instead, and to
give our normal warning if the leaks report was generated without
tracking Python allocators.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Temporal flame graphs have just been inheriting the help text of normal
flame graphs. Update this to add a small section explaining how to use
the sliders to investigate a different time range.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek
Copy link
Contributor Author

And then, just for fun, I rebased on main. 😂

@pablogsal pablogsal enabled auto-merge (rebase) February 24, 2023 19:45
@pablogsal pablogsal merged commit 8782f56 into bloomberg:main Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants