Skip to content

attempt to share loader for JIT-ed classes#5880

Merged
kares merged 2 commits intomasterfrom
jit-max-pp
Sep 27, 2019
Merged

attempt to share loader for JIT-ed classes#5880
kares merged 2 commits intomasterfrom
jit-max-pp

Conversation

@kares
Copy link
Member

@kares kares commented Sep 17, 2019

introduces a -Xjit.loader.mode which is either UNIQUE (default), SHARED or SHARED_SOURCE

most of it is making WeakValueMap implement Map as I originally did something else here ...
so I've kept that code and just did a fake Map for the single (shared) global class-loader.
that can be changed as needed to a cleaner (proper oop) way.

the SHARED_SOURCE was so far only tested with jruby's test suite, the JITed class-loader count went down to 10% ... and meta-space was much less fragmented - saving around 8% of allocated space.

was not sure whether we should attempt to somehow detect eval-ed pieces
and not share them with the same source file but rather always on their own?
given that SHARED_SOURCE isn't changed to be the new default, we can also decide later.

also if you have suggestions for better naming the option or the enum values.

@kares kares changed the title an attempt to share loader for JIT-ed classes attempt to share loader for JIT-ed classes Sep 17, 2019
@kares kares requested review from enebo and headius September 20, 2019 06:40
Copy link
Member

@headius headius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems good to me!

I don't know what to say about eval methods; in order for them to be a problem, they'd have to:

  • Be continually generated at runtime. This is very uncommon.
  • Be called enough to JIT. This seems unlikely now and even more unlikely with our time-based threshold changes.

On the flip side, many methods get generated using eval in a "safe" way (only once, usually to lazily metaprogram some methods) and we definitely want those to be eligible for JIT without a whole separate classloader (when running in a shared mode).

I think we go with this for now as-is. Folks that opt into shared classloading can help us uncover any weird eval edge cases.

@kares kares added this to the JRuby 9.2.9.0 milestone Sep 27, 2019
@kares kares added the jit label Sep 27, 2019
either for every JIT-ed class or based on source file
@kares kares merged commit a88704f into master Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants