Skip to content

PYTHON-5404 - Add docs for profiling execution #2402

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

Merged
merged 4 commits into from
Jun 26, 2025

Conversation

NoahStapp
Copy link
Contributor

No description provided.

@NoahStapp NoahStapp requested a review from blink1073 June 25, 2025 16:02
@NoahStapp NoahStapp changed the title PYTHON-5404 - Add docs for profiling execution PYTHON-5404 - Add docs + justfile target for profiling execution Jun 25, 2025
@NoahStapp NoahStapp requested a review from ShaneHarvey June 26, 2025 15:22
import sys


def main():
Copy link
Member

@ShaneHarvey ShaneHarvey Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having this file at all? We're adding 60 lines of code to change this:

pip install py-spy
py-spy record -o output.svg -- <path/to/script>

into:

pip install py-spy
just flamegraph <--output_name=profile> <--sample_rate=2000> <path/to/script>

Can we just pass all the args to py-spy record and call it a day? It already has a default value with sample_rate so all we really save here is the -o profile.svg which I'm not sure is worth this extra file. The just flamegraph approach is also inflexible since it doesn't allow passing arbitrary options to py-spy record.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I like the conciseness of just flamegraph, but we're already requiring enough args and manual steps that we don't save much at all by having it. Just including docs on how to run py-spy should be sufficient here.

CONTRIBUTING.md Outdated
2. Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling
3. Run the `flamegraph` justfile target to generate a `.svg` file containing the flame graph:
```bash
just flamegraph <output_name=profile> <sample_rate=2000> <path/to/script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even add this to just? Since we already need to install py-spy manually why not document the py-spy command to run without just.

@NoahStapp NoahStapp requested a review from ShaneHarvey June 26, 2025 19:54
@ShaneHarvey
Copy link
Member

Thanks!

@NoahStapp NoahStapp merged commit 244f17d into mongodb:master Jun 26, 2025
70 of 73 checks passed
@NoahStapp NoahStapp changed the title PYTHON-5404 - Add docs + justfile target for profiling execution PYTHON-5404 - Add docs for profiling execution Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants