[webkit-dev] WTF::fastMalloc

Maciej Stachowiak mjs at apple.com
Tue Oct 1 15:43:42 PDT 2013

On Oct 1, 2013, at 3:11 PM, Geoffrey Garen <ggaren at apple.com> wrote:

>>> (4) Find a fast API for aligned virtual memory allocation.
>>> (5) Find a fast API for committing / decommitting physical memory without releasing virtual memory pages.
>> Hrm. Isn't this already available via OSAllocator or are you referring
>> to the fact that the Posix implementation has a few problems?
> OSAllocator is the right model, yes. 
> There are two problems with the current OSAllocator POSIX implementation:
> (1) It uses mmap, which doesn’t support aligned allocation. To get aligned allocation, POSIX double-allocates all virtual memory. That is 2X too much. So, we need to find a variation on mmap that supports an alignment constraint.

PageAllocationAligned.cpp does this, but it would be more effective to unmap the unneeded extra at each end (or use mremap on systems that have it). That would be extra VM calls but would not require 2x the space. I'm not sure why it doesn't do that already - perhaps because it is building on top of OSAllocator and no one tried hard enough to optimize it.

(The current FastMalloc doesn't try to align its requests for system memory to more than a page boundary so it doesn't have this issue.)

> (2) POSIX uses MADV_FREE, MADV_DONTNEED, and/or MADV_WILLNEED. I don’t think anybody has ever verified that these APIs do what we want. In my experience, they usually don’t. So, we need to find a variation on these APIs that works and is fast.

I don't have the expertise to know what these do or whether it is what we want. But our current malloc uses these, so it would not be a regression for the new malloc to use them even if they are subtly wrong, unless there is something wildly different about its use of system memory.

> We need somebody to resolve these issues, otherwise our memory footprint will be unacceptably high, and/or our VM operations will be unacceptably slow.
> Geoff
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

More information about the webkit-dev mailing list