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

Commits on Jul 29, 2023

  1. Speed up rebuilding the loaded feature index

    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]
    jeremyevans authored and nagachika committed Jul 29, 2023
    Configuration menu
    Copy the full SHA
    ef78881 View commit details
    Browse the repository at this point in the history
  2. Add a realpath cache to reduce number of syscalls.

    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.
    krk authored and nagachika committed Jul 29, 2023
    Configuration menu
    Copy the full SHA
    332e063 View commit details
    Browse the repository at this point in the history