[Numpy-discussion] NEP 49: Data allocation strategies

Matti Picus matti.picus at gmail.com
Wed Apr 21 21:26:11 EDT 2021


See my comments interspersed in Ralf's reply. Thanks for the additional 
context.

Matti


On 21/4/21 3:10 am, Ralf Gommers wrote:
>
>
> ...
>
>     Motivation and Scope
>     --------------------
>
>     Users may wish to override the internal data memory routines with
>     ones
>     of their
>     own. Two such use-cases are to ensure data alignment and to pin
>     certain
>     allocations to certain NUMA cores.
>
>
> It would be great to expand a bit on these two sentences, and add some 
> links. There's a lot of history here in NumPy development to refer to 
> as well:
>
> https://numpy-discussion.scipy.narkive.com/MvmMkJcK/numpy-arrays-data-allocation-and-simd-alignement 
> <https://numpy-discussion.scipy.narkive.com/MvmMkJcK/numpy-arrays-data-allocation-and-simd-alignement>
> http://numpy-discussion.10968.n7.nabble.com/Aligned-configurable-memory-allocation-td39712.html 
> <http://numpy-discussion.10968.n7.nabble.com/Aligned-configurable-memory-allocation-td39712.html>
> http://numpy-discussion.10968.n7.nabble.com/Numpy-s-policy-for-releasing-memory-td1533.html 
> <http://numpy-discussion.10968.n7.nabble.com/Numpy-s-policy-for-releasing-memory-td1533.html>
> https://github.com/numpy/numpy/issues/5312 
> <https://github.com/numpy/numpy/issues/5312>
> https://github.com/numpy/numpy/issues/14177 
> <https://github.com/numpy/numpy/issues/14177>
>
> There must also be a good amount of ideas/discussion elsewhere.


I added more context to this section, trying to focus on the large data 
allocations in NumPy.


>
> https://bugs.python.org/issue18835 
> <https://bugs.python.org/issue18835> discussed an aligned allocator 
> for Python itself, with fairly detailed discussion about whether/how 
> NumPy could benefit. With (I think) the conclusion it shouldn't be in 
> Python, but NumPy/Arrow/others are better off doing their own thing.
>
> I'm wondering if improved memory profiling is a use case as well? Fil 
> (https://github.com/pythonspeed/filprofiler 
> <https://github.com/pythonspeed/filprofiler>) for example seems to use 
> such a strategy: 
> https://github.com/pythonspeed/filprofiler/blob/master/design/allocator-overrides.md 
> <https://github.com/pythonspeed/filprofiler/blob/master/design/allocator-overrides.md>
>
Thanks. I added a sentence about this as well.


> Does it interact with our tracemalloc support 
> (https://numpy.org/doc/stable/release/1.13.0-notes.html#support-for-tracemalloc-in-python-3-6 
> <https://numpy.org/doc/stable/release/1.13.0-notes.html#support-for-tracemalloc-in-python-3-6>)?
>

I added a sentence about this. The new C-API wrapper functions preserve 
the current status vis-a-vis tracemalloc support. I am not sure that 
support is complete. The NEP should not change the situation for better 
or worse.


>
>     User who wish to change the NumPy data memory management routines
>     will use
>
>
> This is design, not motivation or scope. Try to not refer to specific 
> function names in this section. I suggest moving this content to the 
> "Detailed design" section (or better, a "high level design" at the 
> start of that section).
>
Done.


> Cheers,
> Ralf
>
>


More information about the NumPy-Discussion mailing list