Contributor
Xinyu Wang

Optimize Kernel::require API for Ruby 3


Mentors
Koichi Sasada
Organization
Ruby

The most frequently used Ruby Core APIs Kernel::require and Kernel::require_relative are doing the same work: it’s to resolve the file path, read the file, compile ruby source to bytecode or load a shared object, evaluate and add an entry to $LOADED_FEATURES . But if using Ruby stdlib benchmark to profile their performance, we can figure out a fact: require a relative path is almost 10 times slower than require an absolute path and about 4 times slower than require_relative the same path. This proposal aims to figure out the reason and optimize it.