July 13, 2010
There is a couple issues with the growth rate of arrays in the array append function.

First, the newCapacity function is only called when the array must be reallocated.  I believe this to be an error, I think the newCapacity function should always be used, even if pages can be added.  This would use less cycles searching for pages to append.

Second, the newCapacity function seems to use the size of the element to determine a percentage growth.  I feel this is an error.  I think the growth factor should strictly be related to the amount of memory being requested, which already takes into account the size of the element.

At present, this means that arrays of ints grow 4x as fast as arrays of bytes. And that's 4x in percentage terms, not in 4x the memory used.  The memory used actually grows 16x faster.

Does everyone agree with this?

The relevant bug for this is http://d.puremagic.com/issues/show_bug.cgi?id=4412

-Steve




July 13, 2010

Steve Schveighoffer wrote:
> There is a couple issues with the growth rate of arrays in the array append function.
>
> First, the newCapacity function is only called when the array must be reallocated.  I believe this to be an error, I think the newCapacity function should always be used, even if pages can be added.  This would use less cycles searching for pages to append.
>
> Second, the newCapacity function seems to use the size of the element to determine a percentage growth.  I feel this is an error.  I think the growth factor should strictly be related to the amount of memory being requested, which already takes into account the size of the element.
>
> At present, this means that arrays of ints grow 4x as fast as arrays of bytes. And that's 4x in percentage terms, not in 4x the memory used.  The memory used actually grows 16x faster.
>
> Does everyone agree with this?
>
> The relevant bug for this is http://d.puremagic.com/issues/show_bug.cgi?id=4412
>
> 

Empirically, memory usage seems to be self-similar, which means a percentage increase in size is more likely to be correct than a fixed increment.