Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Julian Taylor
On 18.02.2014 16:21, Julian Taylor wrote: > On Mon, Feb 17, 2014 at 9:42 PM, Nathaniel Smith wrote: >> On 17 Feb 2014 15:17, "Sturla Molden" wrote: >>> >>> Julian Taylor wrote: >>> When an array is created it tries to get its memory from the cache and when its deallocated it returns it

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Sturla Molden
I am cross-posting this to Cython user group to make sure they see this. Sturla Nathaniel Smith wrote: > On 18 Feb 2014 10:21, "Julian Taylor" wrote: > > On Mon, Feb 17, 2014 at 9:42 PM, Nathaniel Smith wrote: > On 17 Feb 2014 15:17, "Sturla Molden" wrote: > > Julian Taylor wrote: > > Whe

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Nathaniel Smith
On 18 Feb 2014 10:21, "Julian Taylor" wrote: > > On Mon, Feb 17, 2014 at 9:42 PM, Nathaniel Smith wrote: > > On 17 Feb 2014 15:17, "Sturla Molden" wrote: > >> > >> Julian Taylor wrote: > >> > >> > When an array is created it tries to get its memory from the cache and > >> > when its deallocated

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Julian Taylor
On Mon, Feb 17, 2014 at 9:42 PM, Nathaniel Smith wrote: > On 17 Feb 2014 15:17, "Sturla Molden" wrote: >> >> Julian Taylor wrote: >> >> > When an array is created it tries to get its memory from the cache and >> > when its deallocated it returns it to the cache. >> ... > > Another optimization w

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Sturla Molden
Julian Taylor wrote: > I was thinking of something much simpler, just a layer of pointer stacks > for different allocations sizes, the larger the size the smaller the > cache with pessimistic defaults. > e.g. the largest default cache layer is 128MB and with one or two > entries so we can cache te

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-18 Thread Julian Taylor
On Tue, Feb 18, 2014 at 1:47 AM, David Cournapeau wrote: > > On Mon, Feb 17, 2014 at 7:31 PM, Julian Taylor > wrote: >> >> hi, >> I noticed that during some simplistic benchmarks (e.g. >> https://github.com/numpy/numpy/issues/4310) a lot of time is spent in >> the kernel zeroing pages. >> This is

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread David Cournapeau
On Mon, Feb 17, 2014 at 7:31 PM, Julian Taylor < jtaylor.deb...@googlemail.com> wrote: > hi, > I noticed that during some simplistic benchmarks (e.g. > https://github.com/numpy/numpy/issues/4310) a lot of time is spent in > the kernel zeroing pages. > This is because under linux glibc will always

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Stefan Seefeld
On 02/17/2014 06:56 PM, Nathaniel Smith wrote: > On Mon, Feb 17, 2014 at 3:55 PM, Stefan Seefeld wrote: >> On 02/17/2014 03:42 PM, Nathaniel Smith wrote: >>> Another optimization we should consider that might help a lot in the >>> same situations where this would help: for code called from the >>>

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Julian Taylor
On 17.02.2014 22:27, Sturla Molden wrote: > Nathaniel Smith wrote: >> Also, I'd be pretty wary of caching large chunks of unused memory. People >> already have a lot of trouble understanding their program's memory usage, >> and getting rid of 'greedy free' will make this even worse. > > A cache w

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Nathaniel Smith
On Mon, Feb 17, 2014 at 3:55 PM, Stefan Seefeld wrote: > On 02/17/2014 03:42 PM, Nathaniel Smith wrote: >> Another optimization we should consider that might help a lot in the >> same situations where this would help: for code called from the >> cpython eval loop, it's afaict possible to determine

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Sturla Molden
Nathaniel Smith wrote: > Also, I'd be pretty wary of caching large chunks of unused memory. People > already have a lot of trouble understanding their program's memory usage, > and getting rid of 'greedy free' will make this even worse. A cache would only be needed when there is a lot of computin

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Stefan Seefeld
On 02/17/2014 03:42 PM, Nathaniel Smith wrote: > Another optimization we should consider that might help a lot in the > same situations where this would help: for code called from the > cpython eval loop, it's afaict possible to determine which inputs are > temporaries by checking their refcnt. In

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Nathaniel Smith
On 17 Feb 2014 15:17, "Sturla Molden" wrote: > > Julian Taylor wrote: > > > When an array is created it tries to get its memory from the cache and > > when its deallocated it returns it to the cache. > > Good idea, however there is already a C function that does this. It uses a > heap to keep the

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Julian Taylor
On 17.02.2014 21:16, Sturla Molden wrote: > Julian Taylor wrote: > >> When an array is created it tries to get its memory from the cache and >> when its deallocated it returns it to the cache. > > Good idea, however there is already a C function that does this. It uses a > heap to keep the cache

Re: [Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Sturla Molden
Julian Taylor wrote: > When an array is created it tries to get its memory from the cache and > when its deallocated it returns it to the cache. Good idea, however there is already a C function that does this. It uses a heap to keep the cached memory blocks sorted according to size. You know it

[Numpy-discussion] allocated memory cache for numpy

2014-02-17 Thread Julian Taylor
hi, I noticed that during some simplistic benchmarks (e.g. https://github.com/numpy/numpy/issues/4310) a lot of time is spent in the kernel zeroing pages. This is because under linux glibc will always allocate large memory blocks with mmap. As these pages can come from other processes the kernel mu