Skip to content

Pystats docs #650

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 7 commits into from
Feb 15, 2024
Merged

Pystats docs #650

merged 7 commits into from
Feb 15, 2024

Conversation

mdboom
Copy link
Contributor

@mdboom mdboom commented Feb 6, 2024

This is a first pass at trying to document the fields in the pystats. The most important ones (and the ones I'm most familiar with) are the Tier 2-related ones, so I've started with those and we can come back to the other ones later.

This probably belongs in CPython proper, but we can iterate here and submit there later.

Copy link
Collaborator

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Good start!

pystats_docs.md Outdated

## Specialization stats

TBD
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we ask @markshannon tp help fill these TBD entries?

Copy link
Member

Choose a reason for hiding this comment

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

For each family, there are three tables:

Kind

Lists the number of "deferred" (i.e. not specialized) instructions executed, the number of "hits" (specialized instructions that complete) and "misses" (specialized instructions that deopt).

Unnamed

Success: Number of specialization attempts that were successful
Failure: Number of specialization attempts that failed for some reason

Failure kind

Numbers for the various kinds of specialization failures.
The total should add up to the "Failure" entry in the above table.

Copy link
Contributor Author

@mdboom mdboom Feb 15, 2024

Choose a reason for hiding this comment

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

@markshannon: For the Kind table, I see "specialization.deferred", "specialization.deopt", "hit" and "miss". What is the difference between "deopt" and "miss"?

EDIT: Nevermind -- I was looking at some old results.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mdboom Can you add this to the doc?

@mdboom
Copy link
Contributor Author

mdboom commented Feb 7, 2024

It occurs to me that what we really ought to do is put this information in the generated output from summarize_stats.py. This PR is still a convenient way to iterate on the language though.

Copy link
Collaborator

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

A few more…

mdboom and others added 3 commits February 7, 2024 13:07
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
@gvanrossum
Copy link
Collaborator

Blocked on @markshannon answering some inline questions.


TBD

## Specialization effectiveness
Copy link
Member

@markshannon markshannon Feb 15, 2024

Choose a reason for hiding this comment

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

Specialization effectiveness

All entries are execution counts. Should add up to the total number of T1 instructions executed.
Basic: Instructions that are not and cannot be specialized, e.g. LOAD_FAST.
Not specialized: Instructions could be specialized but aren't. E.g. LOAD_ATTR, BINARY_SLICE
Specialized hits: Specialized instructions, e.g. LOAD_ATTR_MODULE that complete
Specialized misses: Specialized instructions, e.g. LOAD_ATTR_MODULE that deopt

I think there is a bug in the "Not specialized" numbers. We are counting POP_JUMP_IF_... but we shouldn't be.

Deferred by instruction

Breakdown of deferred (not specialized) instruction counts by family.

Misses by instruction

Breakdown of misses (specialized deopts) instruction counts by family.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I filed a CPython issue for the not specialized numbers problem: python/cpython#115521

pystats_docs.md Outdated

## Call stats

TBD
Copy link
Member

Choose a reason for hiding this comment

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

This is shows what fraction of calls to Python functions are inlined (no call at the C level) and for those that are not, where the call comes from. The various categories overlap.

Also includes count of frame objects created.

Read the code for more details.

pystats_docs.md Outdated

## Object stats

TBD
Copy link
Member

Choose a reason for hiding this comment

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

Grab bag of stats about objects:

"Allocations" means "allocations that are not from a freelist". Total allocations = "Allocations from freelist" + "Allocations"

"New values" is the number of values array created for objects with managed dicts.

The cache hit/miss numbers are for the MRO cache, split into dunder and other names.

pystats_docs.md Outdated

## GC stats

TBD
Copy link
Member

Choose a reason for hiding this comment

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

By generation. Collected/visits gives some measure of efficiency

@mdboom
Copy link
Contributor Author

mdboom commented Feb 15, 2024

I've incorporated @markshannon's content and will go ahead and merge (this is just a local reference -- we can always iterate).

@mdboom mdboom merged commit 99b09bb into faster-cpython:main Feb 15, 2024

This is the count of how many times each Tier 1 instruction is executed.

The "miss ratio" column shows the percentage of times when instruction executed that it deoptimized. In this case the base unspecialized instruction is not counted.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add "The deoptimization event is counted separately, see below".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I merged too quickly. Added here: #655

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.

3 participants