-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
_PyStaticCode_InternStrings
is called ~800 times during startup.
#96459
Comments
Maybe @kumaraditya303 is interested in doing this? |
Yeah, seems like a good improvement. FWIW, I considered doing this a while back but with a static initializer but it was way too messy. |
What percentage of the startup |
This is a bit problematic since the hash codes vary based on the hash seed. I wouldn’t be surprised if this was most of the cost. Please look into that before writing the code. |
The hashes always get initialized, it will be no slower to do them all up front. |
Another thing is if we create a table of strings it should also include the global identifier strings not just deepfreeze strings. |
My point was that we don't know if this rearrangement of the code is going to have any effect. And in particular if the hash computation is expensive, it may dominate the cost, so rearranging the code won't help. So yes, we need a flame graph or something like that to show where the time is spent. |
I agree with listing the strings so then allocations can be faster. |
The
_Py_Deepfreeze_Init()
function calls_PyStaticCode_InternStrings
once for each string.Creating the interned string dict in one go, from the table of static strings would be much faster.
something like this (error checking omitted, and other liberties taken for brevity)
All the hash codes will need to be initialized first, but we probably should do that anyway.
The text was updated successfully, but these errors were encountered: