GC performance - GC fragility



As a followup to the GC perf thread, I posted a small tweak of the benchmark in the attachments (under Pierre's post), to illustrate how wrong and how easily things can go with a GC (and how tricky benchmarking memory managers outside of real-world applications is).

Basicly the original test was allocating an object with single TStringList field, and added a single short string before "releasing" the whole (ie. it wouldn't stress the markup/compaction phase of the GC at all).

My variation adds a bunch of data fields to the TTestObject (in the form of a static array, to keep the code short), along with a reference to a subobject (another TTestObject).
Instead of allocating a single object at each benchmark step, several objects are then allocated, each (but the last) with a reference to the next object in the singly-linked chain.

The outcome?

FastMM now runs it 6 times faster (not 6%), and uses more than 4 times less memory (on a dual core).
Sean, this is an example why a GC can be considered "hideously" slow: its execution complexity isn't constant (unlike FastMM), and the more you stress it, the less efficient it becomes at managing memory.

Further modification of the test so that FastMM can be found to run as many times faster than the GC as desired is left as an exercice to the astute reader ;)
As a counter-exercice and challenge, I suggest finding a variation of the test where the GC ends up running significantly faster (at least twice faster) and using less memory (at least half).

Eric
.



Relevant Pages

  • Re: Memory Manager Test Results
    ... If you look at the FastMM ... I don't know what in the benchmark ... I don't know what could be allocating memory directly through Win API, ... > or less constant at 47MB, but the benchmark reserves wildly varying ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: MM chalange
    ... > Currently I am creating a new memory manager that is build only for speed ... To have that kind of speed advantage in a benchmark I guesstimate you have ... > some time for testing / tuning but am willing to donate it to the fastcode ... > 1) How can I donate the code? ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode - Alternative SZ IntToStrB&V v0.09
    ... Be aware that data need to fit in phisical memory during ... Preparing space to store report data before stat of benchmark to ... > avoid problem with fragmentation ...
    (borland.public.delphi.language.basm)
  • Re: Blind Fastcode Memory Manager Challenge
    ... The final benchmark would be the sum of all submitted benchmark, this way, ... allocates a reasonnable amount of memory at any given time (so it can ... initialize Bench B ... execute Bench C ...
    (borland.public.delphi.language.basm)
  • Re: New replay benchmark : XML Parser
    ... one does get some noticeable speed and memory ... I suggest we include this benchmark in the B&V0.35 tool. ... > and BucketMem (1200 for RecyclerMM) ... > Not sure if it's the file loading time ...
    (borland.public.delphi.language.basm)