War of allocators in JavaScriptCore

JEmalloc is a highly scalable memory allocator made by Jason Evans. This is the default allocator of the FreeBSD operating system and Firefox's Linux/Windows versions, but how does it perform in WebKit?

With the help of the Custom Allocation Framework, I've put JEmalloc's multi-threaded version into JavaScriptCore and made some measurements with 3 popular benchmark suites. I didn't modify JEmalloc's source or tweak any parameters of it, just used it as I downloaded and compiled it. I benchmarked the offical r54127 WebKit revision.

First, let's see the charts of JavaScriptCore benchmarks:




On SunSpider, TCmalloc is faster by 8.7% than JEmalloc. On V8, this value is only 6.4%. On WindScorpion benchmark suite, TCmalloc is 20% faster than JEmalloc... In all cases, System malloc is a bit faster than JEmalloc. Therefore, in all of the three cases, both the System allocator and TCmalloc performs better. I think we can't tweak JEmalloc to overtake TCmalloc's performance in the case of WindScorpion benchmark.

Memory consumption



As we can see, JEmalloc's memory consumption stands between TCmalloc and System malloc. In all of the three benchmarks, system allocator's memory consumption shows the best values. By tweaking JEmalloc's parameters, we got close only to the System malloc's memory consumption, so I expect no more improvement from JEmalloc.



Sys. malloc




496 ms

530 ms

484 ms


2 565 ms

2 707 ms

2 535 ms


13 320 ms

15 639 ms

12 646 ms


12 405 kbytes

13 022 kbytes

15 200 kbytes


131 011 kbytes

134 210 kbytes

135 820 kbytes


38 160 kbytes

40 020 kbytes

43 459 kbytes


I think we shouldn't put more effort on JEmalloc, because system allocator is much better on these benchmarks... But, what do you think?

Shawn Wilsher (not verified) - 02/04/2010 - 15:57

As I recall, Mozilla adopted jemalloc because it had less memory fragmentation over time on windows. I was unaware that we are using it in our Linux builds, and we never turned it on on OS X because we saw no gain against the system allocator. Jason Evans would certainly know more about all of this though, and you should ask him.

Dragan (not verified) - 02/04/2010 - 16:53

Just my $0.02: People to whom this matters most (embedded) will value ms over kb.

Eric (not verified) - 02/05/2010 - 02:37

Can you please described the platform used for this comparison ? Linux x86 ?

zoltan.horvath - 02/05/2010 - 08:47


we talked to Jason in 2008 and tried to achieve better results together - we used the experiment version of the custom allocation framework -, but we can only got close to the system allocator.

The platform was Linux-Qt (Debian Lenny, Qt-4.6.0), x86. :-)

Anonymous (not verified) - 02/16/2011 - 11:19

> Just my $0.02: People to whom this matters most (embedded) will value ms over kb.

When you run out of memory, performance will be *very* bad.

Resource usage is really important for performance on real world use-cases. Google finds two TCMalloc documentation pages, of which another states that it doesn't free memory to the system. That would be catastrophic behavior on something like Browser which memory usage is very dynamic (huge amount of very different sized allocs mixed with frees etc)...

These synthetic benchmarks don't really tell about real memory usage, memory usage should be tested on something like CNN, Gmail etc. over long period of usage & surfing multiple pages.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Fill in the blank