New submission from Marcos Dione:

Linux kernel's new madvise() MADV_FREE[1] could be used in the memory allocator 
to signal unused parts of the private heap as such, allowing the kernel use 
those pages for resolving lowmem pressure situations. From a LWN article[2]:

[...] Rather than reclaiming the pages immediately, this operation marks them 
for "lazy freeing" at some future point. Should the kernel run low on memory, 
these pages will be among the first reclaimed for other uses; should the 
application try to use such a page after it has been reclaimed, the kernel will 
give it a new, zero-filled page. But if memory is not tight, pages marked with 
MADV_FREE will remain in place; a future access to those pages will clear the 
"lazy free" bit and use the memory that was there before the MADV_FREE call. 

[...] MADV_FREE appears to be aimed at user-space memory allocator 
implementations. When an application frees a set of pages, the allocator will 
use an MADV_FREE call to tell the kernel that the contents of those pages no 
longer matter. Should the application quickly allocate more memory in the same 
address range, it will use the same pages, thus avoiding much of the overhead 
of freeing the old pages and allocating and zeroing the new ones. In short, 
MADV_FREE is meant as a way to say "I don't care about the data in this address 
range, but I may reuse the address range itself in the near future." 

Also note that this feature already exists in BSD kernels.

--
[1] 
http://kernelnewbies.org/Linux_4.5#head-42578a3e087d5bcc2940954a38ce794fe2cd642c

[2] https://lwn.net/Articles/590991/

----------
components: Interpreter Core
messages: 262117
nosy: StyXman
priority: normal
severity: normal
status: open
title: Use new madvise()'s MADV_FREE on the private heap
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26601>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to