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

Henrik Gedenryd h.gedenryd at open.ac.uk
Wed Aug 7 09:34:36 UTC 2002


Stephen Pair wrote:

> But you could only do that for identity based, hashed collections right?
> Otherwise, the primitive would need to send #= somehow.

Right, doh.

> But, a
> primitive for scanFor: that was passed the hash, and was specific for
> identity comparison might indeed be worthwhile.

Yeah it could even read the hash itself, as lookupMethodInDictionary: does.

Ned Konz wrote:

>> Interpreter>>#lookupMethodInDictionary: , into something like
>> lookupKey: key startingAt: index .
> 
> well, that's a bit specialized, in that it stops at the first nil.

But the dictionary scans always stop at nil. That's how it works. Right?

> But wouldn't that force the hash to be generated/accessed? With my
> optimizations, hash is skipped altogether; I'm just doing a linear
> identity scan.
> 
> Depending on whether the (hash mod: size) operation is costly, it
> might make sense to do this in the primitive as well.

These aren't expensive, the #= send is. It dwarfs the gains from using your
technique, so it is only worth it for id-dictionaries. Using = instead of ==
went from 6 to 19 in my test, while your mods take it from 6 to 4. Changing
the unrolled one to use = takes it from 4 to 13.

Henrik




More information about the Squeak-dev mailing list