Skip to content

Conversation

@neonene
Copy link
Contributor

@neoneneneonene commented Sep 25, 2024

An alternative PR to #124323.

This helps MSVC to optimize PyType_GetBaseByToken() and PyType_GetModuleByDef() on PGO builds without current workaround.

cc @encukou

@neoneneneonene marked this pull request as draft September 25, 2024 21:10
@neonene
Copy link
ContributorAuthor

One of suspects that exhausts MSVC:

 static PyTypeObject * -get_base_by_token_recursive(PyTypeObject *type, void *token)+get_base_by_token_recursive(PyObject *bases, void *token)

@neoneneneonene marked this pull request as ready for review October 8, 2024 15:09
@neonene
Copy link
ContributorAuthor

@encukou Please review again. This should not be bad for performance on average.

@neonene
Copy link
ContributorAuthor

Bad example:

PyTypeObject*base=NULL; if (((PyHeapTypeObject*)type)->ht_token==token){found: if (result!=NULL){*result= (PyTypeObject*)Py_NewRef(base ? base : type)} return1}

Are you interested in removing the checker function like the current PR? If not, I'll give up.

not to impact PyType_GetSlot() and others.
Copy link
Member

@encukouencukou left a comment

Choose a reason for hiding this comment

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

This looks good! Thank you, and apologies for the delay.

@encukouencukou merged commit 120b891 into python:mainOct 10, 2024
@neoneneneonene deleted the opttoken branch October 10, 2024 19:21
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@neonene@encukou