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

Disable Zeitwerk eager loading to improve performance #28

Merged
merged 1 commit into from
Sep 7, 2024

Conversation

hidakatsuya
Copy link
Owner

@hidakatsuya hidakatsuya commented Sep 7, 2024

# lib/rexer.rb
puts Benchmark::CAPTION
puts Benchmark.measure {
  loader = Zeitwerk::Loader.for_gem
  loader.setup
  loader.eager_load
}
$ rex state
      user     system      total        real
  0.225180   0.038047   0.263227 (  0.263247)
puts Benchmark::CAPTION
puts Benchmark.measure {
  loader = Zeitwerk::Loader.for_gem
  loader.setup
-  loader.eager_load
}
$ rex state
      user     system      total        real
  0.001415   0.000198   0.001613 (  0.001612)

For example, rex state will be about 30% faster.

v0.10.0

$ time rex state
...
real	0m0.470s
user	0m0.325s
sys	0m0.146s

This pull request:

$ time rex state
...
real	0m0.340s
user	0m0.252s
sys	0m0.089s

@hidakatsuya hidakatsuya self-assigned this Sep 7, 2024
@hidakatsuya hidakatsuya force-pushed the improve-performance-to-not-use-eager-loading branch from 353033b to 5a6e7d0 Compare September 7, 2024 08:28
@hidakatsuya hidakatsuya marked this pull request as ready for review September 7, 2024 09:28
@hidakatsuya hidakatsuya merged commit 8b7e55b into main Sep 7, 2024
3 checks passed
@hidakatsuya hidakatsuya deleted the improve-performance-to-not-use-eager-loading branch September 7, 2024 09:29
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