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

rubocop --server speedups #11178

Closed
gurgeous opened this issue Nov 14, 2022 · 3 comments
Closed

rubocop --server speedups #11178

gurgeous opened this issue Nov 14, 2022 · 3 comments
Assignees

Comments

@gurgeous
Copy link

Can we do more? (see #10706). Here's a simple benchmark script against rubocop-daemon:

#!/bin/bash

# note: brew install hyperfine
pkill -f "rubocop --server"
pkill -f rubocop-daemon
rm -rf $HOME/.cache/rubocop*
touch empty.rb

hyperfine --warmup 3 -i "./rubocop-daemon-wrapper empty.rb"
hyperfine --warmup 3 -i "rubocop --server empty.rb"

and the output on my M1:

Benchmark 1: ./rubocop-daemon-wrapper empty.rb
  Time (mean ± σ):      26.7 ms ±   1.9 ms    [User: 3.4 ms, System: 8.0 ms]
  Range (min … max):    25.2 ms …  44.7 ms    100 runs

Benchmark 1: rubocop --server empty.rb
  Time (mean ± σ):     198.3 ms ±   1.8 ms    [User: 100.5 ms, System: 87.1 ms]
  Range (min … max):   195.7 ms … 201.7 ms    15 runs
@gurgeous
Copy link
Author

Example: we can save 10-15ms per run by not requiring rainbow (or only requiring when necessary)

@gurgeous
Copy link
Author

I wonder if we can shave some time off of Cache.cache_root_dir_from_config. Only load yaml & erb if CacheRootDirectory is in the file contents? That would save another 20-30ms per client run if that string is not present.

@koic koic self-assigned this Jan 25, 2023
koic added a commit that referenced this issue Jan 25, 2023
Follow up #11178 (comment)

The below loading time is definitely unnecessary until an error occurs.

```console
% ruby -v
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin19]
% ruby -rbenchmark -e "Benchmark.bm { _1.report { require 'rainbow' }}"
       user     system      total        real
   0.058754   0.049051   0.107805 (  0.109943)
```
@koic koic closed this as completed in b1d4a02 Jan 30, 2023
@gurgeous
Copy link
Author

Excellent! I love micro-optimizations. This kind of speedup makes a big difference for users IMO

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

No branches or pull requests

2 participants