Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-40521: [subinterpreters] Make dtoa bigint free list per-interpreter#24821
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
JunyiXie commented Mar 11, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
Include/internal/pycore_dtoa.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many C files include directly or indirectly pycore_interp.h which includes pycore_dtoa.h. I would prefer to not pollule their namespaces with names like Kmax, ULong, Long, UULong which can clash with other names.
I see different options:
- Don't fix dtoa.c for now
- Add a prefix to all these names in the header file (ex: "PyDtoa") and create aliases in dtoa.c (ex:
#define Kmax _PyDtoa_Kmax). - Add an API like PyInterpreterState.dict to have per-interpreter variables: the freelist would be dynamically allocated on the heap memory, and stored as a raw pointer in PyInterpreterState. Or if you don't want to add a whole API, just expose the cache as a "void *" in the structure, and add init/fini functions to allocate/free this structure (free list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your review. I chose the second option to fix this problem.
bedevere-bot commented Mar 11, 2021
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 |
JunyiXie commented Mar 12, 2021
I have made the requested changes; please review again |
bedevere-bot commented Mar 12, 2021
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
JunyiXie commented Mar 12, 2021
I have removed the news. But I don't know how to make bedevere/news — No news entry in Misc/NEWS.d/next/ or "skip news" label found check success. |
Include/internal/pycore_dtoa.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This typedef is not needed in pycore_interp.h, please move it into dtoa.c.
Include/internal/pycore_dtoa.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| struct | |
| Bigint{ | |
| structBigint*next; | |
| struct_PyDtoa_Bigint{ | |
| struct_PyDtoa_Bigint*next; |
Include/internal/pycore_interp.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Bigint*bigint_freelist[_PyDtoa_Kmax+1]; | |
| struct_PyDtoa_Bigint*dtoa_freelist[_PyDtoa_Kmax+1]; |
Python/dtoa.c Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to add a helper function get_freelist().
I suggest to use _PyInterpreterState_GET() which is faster than PyInterpreterState_Get().
Python/dtoa.c Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #defineKmax _PyDtoa_Kmax | |
| #defineULong _PyDtoa_ULong | |
| #defineLong _PyDtoa_Long | |
| #defineULLong _PyDtoa_ULLong | |
| #defineULong _PyDtoa_ULong | |
| #defineLong _PyDtoa_Long | |
| #defineULLong _PyDtoa_ULLong | |
| #defineKmax _PyDtoa_Kmax | |
| typedefstruct_PyDtoa_BigintBigint; |
Include/internal/pycore_dtoa.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow other files, you should use "INTERNAL" instead: #ifndef Py_INTERNAL_DTOA_H.
Include/internal/pycore_interp.h Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add:
#ifndef PY_NO_SHORT_FLOAT_REPR ... #endif If the PY_NO_SHORT_FLOAT_REPR macro is defined, dtoa.c is not used.
JunyiXie commented Mar 12, 2021
Thank vstinner, for your very detailed review. I did not consider these details before. |
JunyiXie commented Mar 12, 2021
I have made the requested changes; please review again |
bedevere-bot commented Mar 12, 2021
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
Python/dtoa.c Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See "function declaration isn’t a prototype [-Wstrict-prototypes]" compiler warning:
| get_freelist(){ | |
| get_freelist(void){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review, sorry I didn't pay attention to the warning.
JunyiXie commented Mar 12, 2021
I have made the requested changes; please review again |
bedevere-bot commented Mar 12, 2021
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
vstinner commented Mar 12, 2021
Can you please build Python with PY_NO_SHORT_FLOAT_REPR macro defined? For example, add -DPY_NO_SHORT_FLOAT_REPR=1 flag in CFLAGS. |
JunyiXie commented Mar 13, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
@vstinner Thank you for your reminder, I added After I revert my commit and run the unit test as well, there will still be these errors. |
vstinner commented Mar 13, 2021
I merged your PR thanks.
I just wanted to check if it's possible to build Python in the PY_NO_SHORT_FLOAT_REPR macro defined: it's the case, thanks. I'm not interetesed by test_configparser failures. Platforms where PY_NO_SHORT_FLOAT_REPR macro is defined are rare. If an user of one of such platform is impacted, they can report an issue. |
https://bugs.python.org/issue40521
Make dtoa bigint free list per-interpreter
https://bugs.python.org/issue40521