Conversation
|
No prob, will review. Have you managed to measure anything yet? |
|
quick test of ... gets us around 5% on my machine |
|
|
||
| static RubyModule define(final Ruby runtime) { | ||
| final RubyModule Iterable = Java.getProxyClass(runtime, java.lang.Iterable.class); | ||
| static RubyModule define(final Ruby runtime, final RubyModule Iterable) { |
There was a problem hiding this comment.
Could we use a different name for these? I find it extremely confusing when I look at the code and I see "Iterable" meaning two different things.
There was a problem hiding this comment.
Note that at this point in the code, Iterable now means three different things: the inner class, the variable, and (to me at a glance) the actual Java Iterable class. It's quite confusing.
There was a problem hiding this comment.
Same comment applies to all other such names below. I understand that it might look a bit nicer to some, but this flies against typical Java local variable naming convention.
It's somewhat confusing that the extension classes have the same names as the Java class they extend, but that seems like less of an issue to me than the local variables having yet again the same name.
There was a problem hiding this comment.
okay, will take a look into that
|
|
||
| private static final boolean IMMEDIATE = false; | ||
|
|
||
| private static final JavaExtensions INSTANCE = new JavaExtensions(); |
There was a problem hiding this comment.
This should not be static; a better place would be for it to live on the javasupport Java instance attached to the runtime.
It is weak on the value, but it also anchors a class as its key. The classes we currently extend are system-level classes, but this may be used in the future for classes loaded as part of JRuby or within extensions (e.g. jruby-openssl) that load into their own classloaders, and this reference will prevent them from being collected.
It also is not compatible with multiple JRuby instances in the same JVM, since only the first one will register (and eventually apply) an extension. The others will race to insert the extension or remove it when applying that extension.
There was a problem hiding this comment.
Oh somehow my review used an older version that was still static. I see you have fixed that, thanks!
✔️
exactly - its plugged in right around proxy-class initialization which is already race condition tuned (some tests are in place) |
| assert previous == null; | ||
| } | ||
|
|
||
| public static void define(final Class javaClass, final RubyModule proxyClass) { |
There was a problem hiding this comment.
Seems like runtime could be a parameter here to match put().
There was a problem hiding this comment.
It also seems to line up more with Iterable stuff below which also have runtime.
enebo
left a comment
There was a problem hiding this comment.
Seems reasonable to me. I guess only fear is proxy class initialization concurrency, but that has not actually changed at all in this PR so seems fine.
3325389 to
ab086b7
Compare
also ... we could safely add more extensions now and do not have to worry much about bloating load times
did not run any numbers yet, but hopefully we do not do much JI internally on
gem list,rakeetc