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

YJIT: Disable code GC #8865

Merged
merged 1 commit into from Nov 8, 2023
Merged

YJIT: Disable code GC #8865

merged 1 commit into from Nov 8, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Nov 7, 2023

Changes

This PR disables code GC in the default mode, and adds --yjit-code-gc to optionally turn it on.

Background

Enabling Code GC can be helpful for the following two purposes:

  1. Throw away code that is used only during application boot
  2. Reoder code to improve locality for the current "phase" of the application usage

We haven't observed any real impact of (2) in production or local benchmarks. (1) has a more measurable impact, but this isn't that significant either at least on SFR. Also, the combination of #8705 and rails/rails#49947 may semi-automatically achieve (1) on Rails going forward. So it may not necessarily be useful to enable code GC in Ruby 3.3+.

On the other hand, you may want to disable code GC in the following two scenarios:

  • --yjit-exec-mem-size is too small for the application, which runs code GC too frequently.
  • Reforking with Pitchfork: It gives better CoW efficiency.

We've already learned from #8522 that skipping compilation of long-tail cold code doesn't significantly impact production performance. Similarly, when experimenting with disabling code GC in production, it performed just as well as enabling it.

So, given that it not only is the behavior we use (for reforking with Pitchfork) but also removes the burden of monitoring code_gc_count from casual YJIT users, we thought it's better to disable code GC by default.

Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
@k0kubun k0kubun marked this pull request as ready for review November 8, 2023 00:18
@matzbot matzbot requested a review from a team November 8, 2023 00:18
@maximecb maximecb merged commit 50402db into ruby:master Nov 8, 2023
99 checks passed
@XrXr XrXr deleted the yjit-disable-code-gc branch November 8, 2023 15:44
matzbot pushed a commit that referenced this pull request Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants