Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Dec 18, 2023

The exception thrown here when we cannot find a class can be very expensive at boot time. For most third-party extensions, this exception will be raised twice for every bound method, due to double-checking the classloader under lock a second time. By first looking for a .class resource, we can avoid the expensive exception if it is unlikely to succeed.

@headius headius force-pushed the reduce_invoker_exceptions branch from afba384 to f8c3015 Compare December 18, 2023 09:24
The exception thrown here when we cannot find a class can be very
expensive at boot time. For most third-party extensions, this
exception will be raised twice for every bound method, due to
double-checking the classloader under lock a second time. By first
looking for a .class resource, we can avoid the expensive
exception if it is unlikely to succeed.
This helps avoid exceptions when probing for possibly-defined
invokers. Just using findResource will not pick up generated
classes, so this instead provides a hasClass that will either use
findResource or a set of all class names that have been defined at
runtime in this classloader.
@headius headius force-pushed the reduce_invoker_exceptions branch from f8c3015 to 793a9a5 Compare December 20, 2023 21:09
@headius headius marked this pull request as ready for review December 20, 2023 21:39
@headius
Copy link
Member Author

headius commented Dec 20, 2023

This is complete. It does not appear to affect a single command-line launch of JRuby significantly, but for repeat launches in the same VM the results improve: for gem list, from 0.581s to 0.539s per instance (my M1 system with a few hundred gems).

This number will increase with the number of gem-based extension methods bound. In this case it is primarily from booting stringio and strscan, I believe.

@headius headius merged commit 4365e40 into jruby:master Dec 21, 2023
@headius headius deleted the reduce_invoker_exceptions branch December 21, 2023 16:23
@headius headius added this to the JRuby 9.4.6.0 milestone Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant