rubocop / rubocop-ast

RuboCop's AST extensions and NodePattern functionality
https://docs.rubocop.org/rubocop-ast
MIT License
104 stars 52 forks source link

Optimize forwarded calls #313

Closed marcandre closed 1 month ago

marcandre commented 1 month ago

Fixes [#312]

@Earlopain do you have a minute to review the PR? 🙏

bbatsov commented 1 month ago

Did you manage to get the same 3% speedup?

Earlopain commented 1 month ago

This looks fine to me, benchmarking confirms:

Current:
$ hyperfine -w 3 -r 20 "bundle exec rubocop Rakefile" 
Benchmark 1: bundle exec rubocop Rakefile
  Time (mean ± σ):      2.907 s ±  0.133 s    [User: 2.458 s, System: 0.242 s]
  Range (min … max):    2.802 s …  3.408 s    20 runs

PR:  
$ hyperfine -w 3 -r 20 "bundle exec rubocop Rakefile" 
Benchmark 1: bundle exec rubocop Rakefile
  Time (mean ± σ):      2.695 s ±  0.084 s    [User: 2.297 s, System: 0.229 s]
  Range (min … max):    2.596 s …  2.918 s    20 runs

This is with the changes from rubocop itself already applied. It's a weaker machine than the other benchmark so numbers are different and apparently matter even more since it's about 7% just with this change. I haven't tested but it's probably that file system operations are similarly fast while the CPU is not (or something similar to that effect).

Either way, still achives the original goal. Thanks!

marcandre commented 1 month ago

Thanks!

Released as 1.32.2

I'd recommend using that in rubocop too.