why does array appending add a page size instead of doubling ?

Ali Çehreli acehreli at yahoo.com
Sat Feb 2 23:00:32 PST 2013


On 02/02/2013 10:48 PM, Chris Cain wrote:
 > Okay, I've got a question for you Ali... why is it that sometimes as
 > Elements increased, there were a _drop_ of allocations?
 >
 > So, these in particular:
 >
 > On Sunday, 3 February 2013 at 06:02:04 UTC, Ali Çehreli wrote:
 >> Elements: 65536, Allocations: 9, Moved: 1012
 >> Elements: 131072, Allocations: 10, Moved: 28655
 >> [[ Elements: 262144, Allocations: 9, Moved: 1012 ]]
 >> Elements: 524288, Allocations: 12, Moved: 435173
 >> Elements: 1048576, Allocations: 13, Moved: 1431520
 >> [[ Elements: 2097152, Allocations: 11, Moved: 1993706 ]]
 >> Elements: 4194304, Allocations: 13, Moved: 5877728
 >> Elements: 8388608, Allocations: 14, Moved: 14838747
 >> [[ Elements: 16777216, Allocations: 12, Moved: 30438373 ]]
 >> Elements: 33554432, Allocations: 12, Moved: 59881445
 >> Elements: 67108864, Allocations: 12, Moved: 109627365
 >
 > That's quite an oddity to me, especially looking at the code.

We must be seeing the effects of how the GC works. Note that each line 
is printed for a different slice 's'. My guess is that the GC runs a 
collection right before the observed drop and the next array gets lucky.

Ali



More information about the Digitalmars-d-learn mailing list