std.allocator: FreeList uses simple statistics to control number of items

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri May 22 09:26:26 PDT 2015


On Wednesday, 20 May 2015 at 17:28:50 UTC, Andrei Alexandrescu 
wrote:
> 1. How to update Pmiss efficiently? Most allocations should be 
> fast, so it shouldn't be update with every call to allocate(). 
> What I have now is I update every K calls.

A one-pole low pass filter is a very efficient moving average.
https://github.com/D-Programming-Language/druntime/blob/6e55b7aaff7566d374c2f253f831d3489e7fd1a5/src/gc/gc.d#L1732

Feed it with 1 on hit and 0 on miss to get Phit on average.


More information about the Digitalmars-d mailing list