[squeak-dev] The Inbox: Collections-cmm.874.mcz
asqueaker at gmail.com
Sat Jan 25 01:13:23 UTC 2020
On Fri, Jan 24, 2020 at 6:19 PM Levente Uzonyi <leves at caesar.elte.hu> wrote:
> Hi Chris,
> On Fri, 24 Jan 2020, Chris Muller wrote:
> > Hi Jakob,
> > Optimal execution performance can never be assured with #new, since the
> potential cost of under-allocation in various places is offset by the gains
> of not over-allocating in other places.
> > Although it's impossible to tweak the default initial size in #new to
> optimize for performance, we can at least optimize for space, and also for
> clarity-of-usage. #new, by nature, expresses a "lack of concern for
> optimization", so Squeak should at least provide compactness in that case.
> Places in the code that
> > need optimization will correctly express that by writing #new: with a
> larger pre-allocation.
> > It's true that system level changes of any kind could result in the need
> for downstream changes but, in this case, it seems very unlikely.
> The way I understand it, Jakob says that your suggested change has a
> chance to slow down things just to save a few hundred kilobytes of memory.
But your suggested change is 100% *guaranteed* to slow things down, with no
This avoids that particular slow down, while guarantee'ing to save space!
All for only a very *teency-weency chance* of other areas being minorly
affected (and, easily fixed if they are!).
> I don't think we would want to do that without measuring the effects of
> the change somehow.
Performance measuring is already part of every system that cares, right?
None of those systems are depending on any particular default initial size
for performance. If they are, they should be fixed.
> Same applies to OrderedCollections.
> Following your reasoning, the optimal initial capacity for any dynamic
> collection created with #new should be 0, but that doesn't feel right...
Not 0, 3. It's "reasoning", not extremism. :)
3 would be a great default for OrderedCollection. Ultra-minimal, but with
a purpose. I mean, really, with 10, we have 92% of all instances wasting
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev