[gambit-list] Make the default heap size 1MB
feeley at iro.umontreal.ca
Thu Jan 3 20:16:58 EST 2013
On 2013-01-03, at 5:43 PM, Bradley Lucier <lucier at math.purdue.edu> wrote:
> On Jan 3, 2013, at 2:38 PM, Marc Feeley wrote:
>> On 2012-12-18, at 8:45 AM, Bradley Lucier <lucier at math.purdue.edu> wrote:
>>> Surely 1MB can be OK as a default heap size nowadays ;-)!
>> Why not 2, 5 or 10MB?
> What's your point?
My point is simply that there doesn't seem to be a rule for choosing the best default heap size. Some programs (such as mbrot) seem to perform best on your machine with a 1 MB heap while other programs will do better with 10 MB. Moreover, it also depends on the details of the processor. For example on my Mac (2.6 GHz i7 with 6 MB L3 cache and 0.25 MB L2 cache) I get these numbers for your modified mbrot:
510 ms for heap size <= 0.4 MB
195 ms for 0.5 MB <= heap size <= 1.3 MB
161 ms for 1.4 MB <= heap size <= 3.0 MB
140 ms for 3.1 MB <= heap size
The lowest run time (136 ms) is at heap size = 20 MB .
What setting should we optimize for?
I agree however that the current setting is too low. But given that I will change the default, I would prefer to only change it once. What is a "reasonable" setting? The experiment on my computer suggests "the bigger the better".
>> A default heap size of 5 MB makes some sense given that it is roughly the size of the executable code of the library.
> I think a default heap size should be the size of the largest cache (or half the size of the largest cache, given that the garbage collector is stop-and-copy (I think)) in commonly-used processors. That way most of the data working set would be in cache.
> My guess is that only a relatively small part of the Gambit runtime code is active at any given time in most programs (especially with the conditional specialization of most standard operators).
>> BTW, if you want a different default heap size, why don't you use :
>> export GAMBCOPT=m1000
>> in your .profile?
> I know how to set the cachet; what I'm concerned about is people we'd like to attract to Gambit who try it out first with some trivial code that performs poorly because Gambit is spending 2/3 of its time in GC. Newbies don't understand about boxing flonums, or computations that give ratnum results, etc.
> Increasing the default heap size from basically zero would help with this problem.
> On my mac mini, with a 3MB L2 cache, 2.4GHz Core 2 Duo, I get the following times for mbrot with the following minimum heap sizes (in K).
> Somewhere between 500K and 1500K seems to be the sweet spot for minimum cache size.
> BTW, the number of GCs does not seem to vary smoothly, it seems to jump at discrete points in the minimum heap size. That goes against my intuition.
That's because the (stop-and-copy) heap is composed of a set of msections which are all the same size (0.5 MB if I recall correctly). If you ask for 0.6 MB, you will get 1 MB (2 msections).
More information about the Gambit-list