Alan McKean wrote:
I currently have two strategies implemented for serialization and persistence. Both require storing the runtime in a thread local variable 'currentRuntime'. They fetch the runtime from there when they need it via a Ruby.getCurrentRuntime() call. I would like to hear your critiques and comments.

As you know, my primary concern is of the extra four bytes per object (presumably the metaclass name would be interned and shared) and the performance hit retrieving metaclass with the extra null check. But if it can be proven those impacts are minimal, no worries.

Another less attractive option that would avoid adding a field would be to add an intermediate object.

class MetaClassReference {
  public final String metaclassName;
  public transient RubyClass metaclass;
}

class RubyObject {
 ..
 private final MetaClassReference metaclassRef;
 ..
 public RubyClass getMetaClass() {
   if (metaclassRef.metaclass == null) {
     metaclassRef = <lookup metaclass>(metaclassRef.metaclassName;
   }
   return metaclassRef.metaclass;
 }
}

But what it saves us in a field it may take away in the additional field accesses.

Largely I think benchmarking and profiling will show us how much of an impact we're dealing with here.

I prefer the first solution. It's simpler. Whaddya think? I will be happy to post a diff showing what I have done.

Please do post!

- Charlie

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

   http://xircles.codehaus.org/manage_email

Reply via email to