[ENH] Ten Percent Faster Morphic! (with conversion)

Henrik Gedenryd h.gedenryd at open.ac.uk
Tue Aug 6 16:44:51 UTC 2002


Stephen Pair wrote:

> Exactly...for small dicts you would skip the hash and always start the
> scan at 1.  Of course, it all depends on the hash, and how frequently
> the contents are accessed to determine just how much time is saved.  As
> Ned discovered, in Morphic, the savings can be significant.  But, on the
> other side, keeping things simple is sometimes worth sacrificing a
> little performance.
> 
>> I could be wrong though, and this is why I ask the above question.
>> 
>> Henrik
> 
> - Stephen

Yes. I looked at Ned's code--I was particularly surprised that the loop
unrolling made a significant difference--and it turns out it is the
primitive ops in scanFor: that take time: checking for nil, branching in the
loop, and so on, really small operations. No message sends or getting the
hash or some such, just the primitive ops of the scan.

So I suggest that a much simpler solution/smaller change is to instead add a
primitive for scanFor:, to which you pass the hash value to use so you can
use the same one also for regular dictionaries. It should be possible to
refactor the code for the message lookup of the vm, in
Interpreter>>#lookupMethodInDictionary: , into something like lookupKey: key
startingAt: index .

This ought to give the same speedup as Ned's changes (assuming that in C the
scan time is negligible), for all small regular and id-dictionaries, and by
only adding a primitive for scanFor:

I feel uncomfortable doing such a vm change myself. I don't even remember
how to use an argument in a primitive...

Henrik




More information about the Squeak-dev mailing list