Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context-Guided Splitting: poc in TruffleRuby #1

Closed
wants to merge 105 commits into from

Conversation

sophie-kaleba
Copy link
Owner

@sophie-kaleba sophie-kaleba commented Nov 8, 2024

Part of the implementation resides in my fork of graal: PR #


Context-Guided Splitting is a variation of the current splitting heuristic used in GraalVM. It aims at reducing the amount of splits by favouring the reuse of previously split methods. Such a decision is guided by the notion of "context": each call is represented by a context. If a method was previously split under a context C, and is flagged for being split again, we check whether the current context and context C match. If they do, we dispatch to the previously split method, rather than triggering splitting again.

What does this PR do?

  • For each call, pick the user-provided arguments and compute a context signature, ie. a hash of the arguments' types (see RubyDynamicObject and ContextSignatureUtils)
  • If a RubyProc (block) is passed as an argument, we use the hashcode of its call-target rather than the plain hash of RubyProc's metaclass, to avoid false positives (see RubyProc)
  • Each arguments' hashcode is multiplied by a prime number (see ContextSignatureUtils). On our biggest benchmarks, this leads to less than 0.2% of collisions

The remainder of the approach, notably how the contexts are used to avoid splitting, is implemented as part of the graal repository. The related PR is available here

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