C
Charles Oliver Nutter
As some of you may have heard, we're considering disabling
ObjectSpace.each_object by default in JRuby. Primarily, this is for
performance; to support each_object, we have to bend over backwards,
maintaining lists of weak references to all objects in the system and
periodically cleaning out those lists. Here's some example performance,
from a fractal benchmark in the JRuby source:
With ObjectSpace: Ruby Elapsed 45.967000
Without ObjectSpace: Ruby Elapsed 4.280000
What's most frustrating about this is that almost *no* libraries or apps
use each_object, and it's a terrible performance hit for us.
The one really visible use of each_object is in test/unit, where the
default console-based runner does each_object(Class) to find all
subclasses of TestCase. Because this is a heavily-used library (to say
the least), I've made modifications to JRuby to always support
each_object(Class) by maintaining a bidirectional graph of parent and
child classes. So that much wouldn't go away (but I'd prefer an
implementation that uses Class#inherited, since it would be cleaner,
faster, and deterministic).
So...I'm writing this to see what the general Ruby world thinks of us
having ObjectSpace disabled by default, enableable via a command line
option (or perhaps through a library? -robjectspace?).
I think more and more of you may want to give JRuby another look over
the next few months, so I think we need to involve you in such decisions.
- Charlie
ObjectSpace.each_object by default in JRuby. Primarily, this is for
performance; to support each_object, we have to bend over backwards,
maintaining lists of weak references to all objects in the system and
periodically cleaning out those lists. Here's some example performance,
from a fractal benchmark in the JRuby source:
With ObjectSpace: Ruby Elapsed 45.967000
Without ObjectSpace: Ruby Elapsed 4.280000
What's most frustrating about this is that almost *no* libraries or apps
use each_object, and it's a terrible performance hit for us.
The one really visible use of each_object is in test/unit, where the
default console-based runner does each_object(Class) to find all
subclasses of TestCase. Because this is a heavily-used library (to say
the least), I've made modifications to JRuby to always support
each_object(Class) by maintaining a bidirectional graph of parent and
child classes. So that much wouldn't go away (but I'd prefer an
implementation that uses Class#inherited, since it would be cleaner,
faster, and deterministic).
So...I'm writing this to see what the general Ruby world thinks of us
having ObjectSpace disabled by default, enableable via a command line
option (or perhaps through a library? -robjectspace?).
I think more and more of you may want to give JRuby another look over
the next few months, so I think we need to involve you in such decisions.
- Charlie