Skip to content
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

Use blocks_output_buffer #79

Closed
rhpvorderman opened this issue May 17, 2021 · 2 comments
Closed

Use blocks_output_buffer #79

rhpvorderman opened this issue May 17, 2021 · 2 comments
Labels
enhancement New feature or request on hold Postponed until a newer version of python.

Comments

@rhpvorderman
Copy link
Collaborator

@animalize made a more intelligent output buffer for python. It utilizes python lists internally.

The old buffer simply uses a PyMem_Resize call. This has the disadvantage of reallocating the memory every time it is called. When the buffer is grown this way, the data at the beginning is copied quite a lot of times. This means that using larger buffer sizes runs into a limit at some point.

The blocks_output_buffer creates a python list with all the buffer blocks. These are created only once. In the end these blocks are all joined together, requiring only one memcpy call per block. This is not only theoretically faster, but it also turns out to be that way in practice.

@rhpvorderman rhpvorderman added the enhancement New feature or request label May 21, 2021
@rhpvorderman
Copy link
Collaborator Author

rhpvorderman commented Jun 7, 2021

unfortunately, realizing this in cython incurs a performance penalty compared to the current solution.

Fixed the memory leak. Unfortunately there is still the issue of Pypy compatibility that needs to be addressed.

@rhpvorderman rhpvorderman reopened this Jun 9, 2021
@rhpvorderman rhpvorderman added the on hold Postponed until a newer version of python. label Jan 8, 2022
@rhpvorderman
Copy link
Collaborator Author

See python/cpython#101260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request on hold Postponed until a newer version of python.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant