[crossfire] Proposal: retire MAX_OBJECTS and object allocator

Kevin Zheng kevinz5000 at gmail.com
Wed Mar 11 13:08:45 CDT 2020


On 3/10/20 9:56 PM, Mark Wedel wrote:
>  Not sure if still the case, but at one time, performance of allocating
> thousands of new objects individually increased lag (when loading new
> maps).  So doing it in blocks of 500 or whatever was faster.  At one
> point I had put in option to do individually allocation, simply for the
> reason above - if using a memory debugger, that block of objects failed
> to work.

Allocating one object at a time does make mapfile_load() slower (all
numbers in us):

x CF Object Allocator
+ 1 object per calloc()
+----------------------------------------------------------------------+
|                  x        +                                          |
|x x    x          x  x*x  x+           +      + + +     +       +    +|
|      |_________A_M______|   |_______________A_M_____________|        |
+----------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  10         16154         17814       17309.5       17148.7     579.95633
+  10         17560         20576         19169       19021.9     1033.7963
Difference at 95.0% confidence
        1873.2 +/- 787.548
        10.9233% +/- 4.71741%
        (Student's t, pooled s = 838.178)

This measurement was made with n=10 loading /world/world_105_115 with a
warm disk cache, with a newly started server each time so that memory
fragmentation hasn't occurred. Time elapsed was measured with a
monotonic clock.

It looks like 1-object-per-alloc increases the median by 2 ms. For tiled
world maps, at worse case 5 maps are loaded at a time, for a total
additional latency of 10 ms, or about a 11% increase.

-- 
Kevin Zheng
kevinz5000 at gmail.com | kevinz at berkeley.edu
XMPP: kevinz at eecs.berkeley.edu


More information about the crossfire mailing list