| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Ping @colesbury, @kumaraditya303. Is there a better place for the _PyMem_ProcessDelayed()? I thought _PyThreadState_Attach() at first but that is too low level. |
Sorry, something went wrong.
There was a problem hiding this comment.
I don't think we should do this. You risk accidentally introducing quadratic behavior.
We will likely tweak the heuristics in the future for when _PyMem_ProcessDelayed() is called, but that should be based on data for real applications.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Memory usage numbers (proposed fix explained below):
Test script:
Delayed memory free checks (and subsequent frees if applicable) currently only occur in one of two situations:
This works great for many small objects, but with larger buffers these can accumulate quickly, so more frequent checks should be done.
I tried a few things but _PyMem_ProcessDelayed() added to _Py_HandlePending() seems to work well and be safe and a QSBR_QUIESCENT_STATE has just been reported so there is a fresh chance to actually free. Seems to happen often enough that memory usage is kept down, and if nothing to free then _PyMem_ProcessDelayed() is super-cheap.
Another option would be to track the amount of pending memory to be freed and increase the frequency of free attempts if that number gets too large, but to start with this small change seems to solved the problem well enough. Could also schedule GC if pending frees get too high, but that seems like a roundabout way to arrive at _PyMem_ProcessDelayedNoDealloc().
Performance as checked by pyperformance full suite is unchanged with the fix (literally 0.17% better avg, so noise).