Need for speed

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Apr 1 21:13:18 UTC 2021


On Thu, Apr 01, 2021 at 01:17:15PM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 4/1/21 12:55 PM, H. S. Teoh wrote:
> 
> > - Constructing large arrays by appending 1 element at a time with
> > `~`.  Obviously, this requires many array reallocations and the
> > associated copying
> 
> And that may not be a contributing factor. :) The following program
> sees just 15 allocations and 1722 element copies for 1 million
> appending operations:
[...]
> This is because the GC does not allocate if there are unused pages
> right after the array.

Right, but in a typical program it's unpredictable whether there will be
unused pages after the array.


> (However, increasing the element count to 10 million increases
> allocations slightly to 18 but element copies jump to 8 million.)
[...]

Thanks for the very interesting information; so it looks like most of
the time spent is actually in copying array elements than anything else!


T

-- 
Let's eat some disquits while we format the biskettes.


More information about the Digitalmars-d-learn mailing list