Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Document how to create the spring binstub #165

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

lakim
Copy link
Contributor

@lakim lakim commented Apr 5, 2020

Hey there,

Thanks for the great tool.
I wanted to speedup standardrb, especially when running in VS Code for linting and to format on save (needs rubyide/vscode-ruby#548).

I created spring-commands-standard to configure spring to generate the bin/standardrb binstub.

Example on a 13 lines file:

# Before
$ time bundle exec standardrb --fix path/to/file.rb
bundle exec standardrb --fix   1,33s user 0,35s system 102% cpu 1,650 total

# After
$ time bin/standardrb --fix path/to/file.rb
Running via Spring preloader in process 32323
bin/standardrb --fix   0,35s user 0,15s system 68% cpu 0,723 total

See the PR to update spring's README: rails/spring#612

@searls
Copy link
Contributor

searls commented Apr 5, 2020

Cool!

Rubocop has some pretty sophisticated caching built-in (which standard benefits from for free), so that leads me to ask how does this performance improvement compare if you just run the same standard command twice (where the second invocation should be much faster) before calling it with Spring?

@lakim
Copy link
Contributor Author

lakim commented Apr 5, 2020

Here's what I have:

$ spring stop
Spring stopped.

$ time bin/standardrb --fix path/to/file.rb
Running via Spring preloader in process 27904
bin/standardrb --fix   0,30s user 0,13s system 13% cpu 3,269 total

$ time bin/standardrb --fix path/to/file.rb
Running via Spring preloader in process 28086
bin/standardrb --fix   0,29s user 0,10s system 59% cpu 0,660 total

So the first binstub call is pretty expensive (around 2x more than a regular bundle exec standardrb.
But subsequent calls are roughly 2x faster than bundle exec standardrb.
No real benchmark here, but a few runs on my machine on a small file.

@searls
Copy link
Contributor

searls commented Apr 6, 2020

I can't tell from what you've posted if this benefit is due to rubocop caching or not, but I'm happy to link to your resource anyway if you think it's helping

@searls searls merged commit 0fe30d4 into standardrb:master Apr 6, 2020
@lakim lakim deleted the spring-support branch April 6, 2020 12:32
@lakim
Copy link
Contributor Author

lakim commented Apr 6, 2020

Great, thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants