[webkit-dev] JavaScriptCore Garbage Collector Invocation

Filip Pizlo fpizlo at apple.com
Mon Feb 6 12:45:40 PST 2012


> Hi,
> 
> I have been trying to optimize or somehow control the invocation of the Java Script Core's Garbage Collector by changing certain values like the highWaterMark and minBytesPerCycle of Heap.cpp. By default the value of minBytesPerCycle is 512 KB, but when i change it to 2 MB i found some performance gain in SunSpider.
> For x86 the gain is about 300 ms 
> For ARM(embedded) core getting around 150 ms.

You will notice that minBytesPerCycle is already set differently on different platforms precisely because of these time-space trade-offs.  The Heap::Heap constructor sets it to heapSizeForHint(), which will often return something like 16MB or 8MB.  If you find that you'd prefer to have finer-grained control, feel free to submit a patch that rationalizes this code to your needs.

> 
> Is there any side affect with the changes i have made with minBytesPerCycle from 512KB to 2 MB?

As Geoff already pointed out, you are making an instance of the GC always use a minimum of 2MB of memory in steady state even if the application is not using that much.

> 
> Is there any other i can optimize the performance or control the invocation of GC?

I recommend Steve Blackburn's papers on GC for Java as a good starting point, as those collectors are generally regarded as having the best balance of throughput, space usage, and architectural simplicity:

http://users.cecs.anu.edu.au/~steveb/downloads/pdf/mmtk-sigmetrics-2004.pdf
http://users.cecs.anu.edu.au/~steveb/downloads/pdf/mmtk-icse-2004.pdf

You may also want to read up on the two main styles of conservative GC (Boehm and Bartlett) as JavaScriptCore uses a combination of the two:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/#details and http://www.hpl.hp.com/personal/Hans_Boehm/gc/#further
http://computer-refuge.org/classiccmp/ftp.digital.com-jun2004/pub/Compaq/WRL/research-reports/WRL-TR-88.2.pdf

And finally consider getting the new GC book by Hosking et al:

http://www.amazon.com/Garbage-Collection-Handbook-Management-Algorithms/dp/1420082795/ref=ntt_at_ep_dpt_1

-Filip





More information about the webkit-dev mailing list