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

%%memray_flamegraph magic options #519

Closed
1 task done
lcrmorin opened this issue Jan 4, 2024 · 4 comments
Closed
1 task done

%%memray_flamegraph magic options #519

lcrmorin opened this issue Jan 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@lcrmorin
Copy link

lcrmorin commented Jan 4, 2024

Is there an existing proposal for this?

  • I have searched the existing proposals

Is your feature request related to a problem?

I am trying to personnalise memray for more advanced usage. With the %%memray magic I can't (1) specify ouptut path (--output option) and (2) cannot specify I am mainly interested in the plots (--temporal ?).

Describe the solution you'd like

I'd like the %%memray magic to have the same options as the command line tool.

Alternatives you considered

No response

@lcrmorin lcrmorin added the enhancement New feature or request label Jan 4, 2024
@godlygeek
Copy link
Contributor

I'd happily take a PR that adds --temporal support. %%memray_flamegraph has its own copy of the argument parsing from src/memray/commands/common.py, so this probably would just require copy-pasting the code for handling temporal mode from there into src/memray/_ipython/flamegraph.py, and seeing if we can add a test for it in tests/integration/test_ipython.py.

--output-path might be a little bit trickier, though. Currently %%memray_flamegraph is designed under the assumption that you want to display the generated flamegraph inside the Jupyter notebook. Are you saying that you'd like to have an option where instead it writes that generated flame graph as a .html file on disk?

@lcrmorin
Copy link
Author

lcrmorin commented Jan 5, 2024

Thanks,
I'll look into this. For path maybe the way to go is to allow for customizing task id, now I get random strings (cell id maybe ?).
Now I have another problem: I ran code overnight and memray seems to have bloated the disk. Any option to reduce memory size ? (typically sampling frequency ?)
Best,

@godlygeek
Copy link
Contributor

Memray is a tracing profiler, not a sampling profiler, so there's no concept of "sampling frequency" that you can apply. memray run itself supports a --aggregate mode that performs in-memory aggregation, resulting in higher memory usage and lower disk usage, but it's incompatible with the --temporal report you said you're interested in. Temporal reports inherently need point-in-time data about what is allocated at each moment in time, while the aggregated capture file format only retains information about what's on the heap at the high water mark and at the point when tracking is terminated.

In any event, it doesn't look like we added support for --aggregate to %%memray_flamegraph. That's an oversight - it probably should be the default. Maybe it shouldn't even be possible to turn it off... as things stand today, %%memray_flamegraph doesn't retain the capture file, only the flamegraph, and it can generate the flamegraph, both in --leaks mode and the default high water mark mode, with the smaller --aggregate capture file.

@godlygeek
Copy link
Contributor

#520 and #538 addressed the feature gap between the %%memray_flamegraph IPython magic and the memray flamegraph CLI, and helped to reduce the amount of disk space used by the magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants