Closed Bug 424891 Opened 16 years ago Closed 16 years ago

TT: add a simple mnpos2ctname cache

Categories

(Tamarin Graveyard :: Tracing Virtual Machine, enhancement)

x86
Linux
enhancement
Not set
normal

Tracking

(Not tracked)

VERIFIED WONTFIX

People

(Reporter: graydon, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

This patch wins between 5-15% on many of the sunspider benchmarks; it simply adds a bounded, linear move-to-front cache on the front of the mnpos2ctname function, which dominates a very hot subtree of the call graph profiles (> 99.9% repetitive calls).

It's a crude technique -- static variable with static GC root -- but I'd recommend adopting something *like* this. Review / suggestions about a more appropriate approach would be appreciated. For example, would it be better to stick the cache in the PoolObject?

(I notice that the TC PoolObject is quite different from the TT one; is there a plan to reconcile the code bases at some point?)
Minor update to same code; puts the GC root put on the interpreter stack rather than in a static. Still uses a static for the cache itself.
Attachment #311477 - Attachment is obsolete: true
Attachment #311656 - Flags: review?(edwsmith)
Do you know if the compile-time multinames being created are mostly being used to access dynamic properties?  There is already a cache for the case when you're looking up a binding (fixture) with a compile time name.  in that case we cache the Binding info with the name and the multiname is just an intermediate value only needed on a cache miss.

but for the case of looking up a dynamic property with a ct name, i could see the generated multiname living longer.  in that case, this cache makes sense.  another possibility would be to add to the existing cache -- an entry holding a binding that means "do a dynamic lookup using this multiname" 
Hey Graydon, I haven't poked into this yet but this smells like there may be an underlying bug here -- I wouldn't have thought that this would have been such a huge win.

On the other hand... sunspider is all ES3, so it's going to be all dynamic lookups anyway... so maybe this is just an optimization case that I missed in my first cut at caching stuff in the interpreter.

as far as details of the cache implementation, looks workable, but I wonder if we could get by with a fixed-size cache (a la QCache, which we use for TraitsEnvData) and avoid the overhead of allocating GC memory as we go along.
Attachment #311656 - Flags: review?(edwsmith) → review?(stejohns)
IMHO mn_cache should be a property of the Interpreter, not a global -- any reason it's not?

Otherwise, looks good
Hey, I tried reapplying this to current tip but find that it now is actually a performance drag rather than gain -- I think because the big savings from it was being able to bypass the call to getInternedPoolString(), which is now vastly cheaper due to the recent String rewrite. 
Great. I was hoping this would turn out to be the case. Shall I close this, then? Ad-hoc caches are sort of warts, much preferable to just have an efficient subsystem.
Yeah, I think so; it might be worth revisiting someday but I think it's no longer the low-hanging fruit.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
Attachment #311656 - Flags: review?(stejohns)
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: