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

Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache #8023

Merged
merged 2 commits into from Jul 29, 2023

Conversation

krk
Copy link
Contributor

@krk krk commented Jul 4, 2023

Backport "Speed up rebuilding the loaded feature index" (1f8823f) and "Add a realpath cache to reduce number of syscalls" (#8017) to Ruby 3.2.

@hsbt hsbt changed the title Ruby32 - Speed up rebuilding the loaded feature index and realpath cache Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache Jul 4, 2023
@hsbt hsbt added the Backport label Jul 4, 2023
@krk
Copy link
Contributor Author

krk commented Jul 12, 2023

Is it possible to include the current PR in Ruby 3.2.3?

@hsbt
Copy link
Member

hsbt commented Jul 13, 2023

@krk
Copy link
Contributor Author

krk commented Jul 17, 2023

Thanks, created https://bugs.ruby-lang.org/issues/19771

@XrXr XrXr requested a review from nagachika July 24, 2023 23:14
jeremyevans and others added 2 commits July 29, 2023 13:37
Rebuilding the loaded feature index slowed down with the bug fix
for #17885 in 79a4484.  The
slowdown was extreme if realpath emulation was used, but even when
not emulated, it could be about 10x slower.

This adds loaded_features_realpath_map to rb_vm_struct. This is a
hidden hash mapping loaded feature paths to realpaths. When
rebuilding the loaded feature index, look at this hash to get
cached realpath values, and skip calling rb_check_realpath if a
cached value is found.

Fixes [Bug #19246]
Number of lstat and stat syscalls for each 'require'd file is doubled,
because rb_realpath_internal is called from two places with the same
arguments in require_internal; once for checking the realpaths cache,
and once in load_iseq_eval when iseq is not found.

Introduce rb_realpath_internal_cached function to reuse the realpath_map
cache which memoizes rb_realpath_internal function, leading to less
syscalls and increased startup performance depending on the cost of the syscalls
in a particular environment.
@nagachika nagachika added this pull request to the merge queue Jul 29, 2023
Merged via the queue into ruby:ruby_3_2 with commit 8346d16 Jul 29, 2023
78 of 79 checks passed
matzbot pushed a commit that referenced this pull request Jul 29, 2023
MSP-Greg added a commit to MSP-Greg/ruby that referenced this pull request Aug 19, 2023
MSP-Greg added a commit to MSP-Greg/ruby that referenced this pull request Aug 21, 2023
MSP-Greg added a commit to MSP-Greg/ruby that referenced this pull request Aug 21, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 21, 2023
… realpath cache (#8023)" (#8252)

* Re-apply "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)"

* [CI] mingw.yml - remove IBM437 encoding for test-all, use cmd shell for test & test-all

* Skip failing test on mingw with readline.so

Co-authored-by: nagachika <nagachika@ruby-lang.org>

---------

Co-authored-by: nagachika <nagachika@ruby-lang.org>
nagachika added a commit that referenced this pull request Aug 24, 2023
nagachika added a commit that referenced this pull request Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 participants