I'm having some issues using MethodCache instead of CacheMap.

The problem I have right now with MethodCache is that there's no way to use it for inline caching. In order for my inline cache to work, I need to be able to cache at the call site. But in order for that to be safe I need to be informed when the cache should be cleared. Checking if I should clear it on each call defeats the purpose.

The old CacheMap allowed code to register for such events. When a new method was defined in a hierarchy, anyone who had cached that method or the same-named method from a superclass would be notified they should flush their caches. With a small modification, this also works with call sites; if I cache a method I could rest assured that changes would correctly cause me to flush.

There's currently no way to do this with the MethodCache. However MethodCache *is* a bit faster.

Here are some numbers for method invocation with MethodCache versus CacheMap:

CacheMap:
Test interpreted: 100k loops calling self's foo 100 times
  2.587000   0.000000   2.587000 (  2.587000)
  2.894000   0.000000   2.894000 (  2.894000)
  1.908000   0.000000   1.908000 (  1.908000)
  1.900000   0.000000   1.900000 (  1.899000)
  1.892000   0.000000   1.892000 (  1.892000)
  1.889000   0.000000   1.889000 (  1.889000)
  1.892000   0.000000   1.892000 (  1.892000)
  1.886000   0.000000   1.886000 (  1.887000)
  1.874000   0.000000   1.874000 (  1.874000)
  1.906000   0.000000   1.906000 (  1.906000)

MethodCache:
Test interpreted: 100k loops calling self's foo 100 times
  2.437000   0.000000   2.437000 (  2.437000)
  2.592000   0.000000   2.592000 (  2.593000)
  1.697000   0.000000   1.697000 (  1.697000)
  1.697000   0.000000   1.697000 (  1.697000)
  1.700000   0.000000   1.700000 (  1.700000)
  1.707000   0.000000   1.707000 (  1.707000)
  1.702000   0.000000   1.702000 (  1.702000)
  1.695000   0.000000   1.695000 (  1.695000)
  1.702000   0.000000   1.702000 (  1.702000)
  1.714000   0.000000   1.714000 (  1.714000)

So I'm trying to reconcile the situation. I certainly don't want to lose MethodCache performance, but I need to have the callback for inline caching to be efficient. The cache flush has to be triggered outside the call path, rather than having an additional guard in the code.

Any ideas?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to