[LLVMdev] MmapAllocator

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Aug 8 20:20:58 PDT 2010


On Aug 7, 2010, at 7:05 PM, Steven Noonan wrote:
> I've been doing work on memory reduction in Unladen Swallow, and
> during testing, LiveRanges seemed to be consuming one of the largest
> chunks of memory.

That's interesting. How did you measure this? I'd love to see your data.

Note that the LiveRange struct is allocated by a plain std::vector, and your patch doesn't change that. I assume you are talking about the VNInfo structs?

> I wrote a replacement allocator for use by
> BumpPtrAllocator which uses mmap()/munmap() in place of
> malloc()/free().

It's a bit more complicated than that. Modern malloc's use a whole bag of tricks to avoid lock contention in multiprocessor systems, and they know which allocation size the kernel likes, and which system calls to use.

By calling mmap directly, you are throwing all that system specific knowledge away.

It's great that you provide measurements, but it's not clear what you are measuring. Does 'mem max' include the overhead of asking the kernel for tiny 4K allocations, if any? Also, what is your operating system and architecture? That could make a big difference.

Have you looked at the effect of twiddling the default 4K slab size in BumpPtrAllocator? I suspect you could get more dramatic results that way.

Thanks for working on this!

/jakob





More information about the llvm-dev mailing list