Skip to content

Docs: Polish profile documentation #110494

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Oct 7, 2023

There are a couple of issues with the current (outdated) documentation

  • To profile a function that takes a single argument is simply misleading. It does not have to be a function, and a single argument is .. just wrong.
  • Users do not like "code as string" and we should at least provide the way to do it with actual code in the "instant manual".
  • The original statement of cprofile not being able to handle sys.exit() is wrong - it can. However, cProfile/profile do not output results if profiling terminates because of SIGTERM #104676 mentioned that it can't handle SIGTERM. I moved this statement up - closer to where it should be seen.
  • In the limitation section, the claim about clock precision is super old - we know it was there at least 16 years ago, when it was copied from somewhere else. The resolution of the system clock now is at ns level. I removed the section directly, we can redo the statement to talk about this - it's still possible that the system clock resolution is an issue, but it's probably much better and definitely not at 0.001s level.

📚 Documentation preview 📚: https://cpython-previews--110494.org.readthedocs.build/

@gaogaotiantian gaogaotiantian added docs Documentation in the Doc dir skip issue skip news labels Oct 7, 2023
@@ -141,6 +149,9 @@ the output by. This only applies when ``-o`` is not supplied.
.. versionadded:: 3.8
Added the ``-m`` option to :mod:`profile`.

Note that if the process is terminated by ``SIGTERM`` during profiling, no
Copy link
Contributor

Choose a reason for hiding this comment

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

How about SIGKILL? ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I changed the description a bit as there might be other cases when the profiling won't work.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@gaogaotiantian
Copy link
Member Author

@CAM-Gerlach could you maybe take a look at it? Thanks!

@gaogaotiantian
Copy link
Member Author

@AA-Turner do you know who should I reach out to for the docs change? Thanks!

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Thanks for your patience.

I'd prefer if we just removed clearly incorrect bits and added additional info, rather than reworking the "Limitations" section this extensively. Let me know what you think.

Comment on lines -580 to -586
One limitation has to do with accuracy of timing information. There is a
fundamental problem with deterministic profilers involving accuracy. The most
obvious restriction is that the underlying "clock" is only ticking at a rate
(typically) of about .001 seconds. Hence no measurements will be more accurate
than the underlying clock. If enough measurements are taken, then the "error"
will tend to average out. Unfortunately, removing this first error induces a
second source of error.
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I like this paragraph, and it still contains meaningful information. I'd just update it to leave out specifics about resolution.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. But in reality, the clock resolution should not be an issue (or significant issue compared to other source) anymore. If we list this as limitation, there are a LOT of factors that we could potentially write here.

Comment on lines -594 to -596
this error. The error that accumulates in this fashion is typically less than
the accuracy of the clock (less than one clock tick), but it *can* accumulate
and become very significant.
Copy link
Member

Choose a reason for hiding this comment

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

I'd leave this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The sentence the error that accumulates in this fashion is typically less than the accuracy of the clock (less than one clock tick) is incorrect now, as the accuracy of the clock has improved a lot for the last .. I don't know how many years. This is definitely more significant than the clock accuracy issue. Do you want me to keep the "become very significant"?

@bedevere-app
Copy link

bedevere-app bot commented Feb 10, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants