Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented May 26, 2024

The Marshal.dump logic we have predates nearly all improvements we have made over time, including:

  • Efficient instance variable storage
  • Passing ThreadContext on the stack
  • Caching dynamic method calls from Java

This PR refactors and overhauls MarshalStream for efficiency and reduced object allocation.

headius added 2 commits May 25, 2024 10:08
MarshalStream holds a lot of state and requires allocation of a
large number of objects just to dump a graph of Ruby objects. This
is a first step toward passing more of that state on the stack and
enabling zero-allocation dumping of all object types.
This eliminates all remaining usage of the Variable collection
from RubyBasicObject.getMarshalVariables. Includes some additional
cleanup and refactored logic.
@headius headius added this to the JRuby 10.0.0.0 milestone May 26, 2024
headius added 8 commits May 26, 2024 06:44
Avoid creating all those Integer objects.
Additional improvements here:

* rubyName no longer reverses the parents list before iterating.
* Factored out common path string-building logic.
* Smaller initial parents list (more than 5 parents is very rare).
There's only one way to do it so just save the context in the
stream.
Two lambdas for dumping variables is two too many. This reduces it
to one.
This is the first of many globally-used symbols to be added to the
SymbolTable. This commit also moves creation of the SymbolTable to
just after the creation of the Symbol class, so these global
symbols can be final references.
@headius headius requested a review from enebo May 26, 2024 16:39
headius added 3 commits May 28, 2024 11:40
If not captured immediately, contained objects will be dumped and
clear this state, breaking the variable count just acquired.
@headius headius merged commit d860015 into jruby:9.5-dev May 28, 2024
@headius headius deleted the fast_marshal branch May 28, 2024 20:16
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