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
Performance issues with 1.31.0 (Layout/FirstHashElementIndentation and Layout/FirstArrayElementIndentation) #10764
Comments
I'm curious if you get the same results now that 1.31.1 was released? Did #10750 help? |
Thanks for the heads up! I just checked with 1.31.1 and I'm still seeing 9 second runs on that file. :( |
Are you able to share the file or an anonymized version of it? |
I've created a test file to reproduce this issue at https://gist.github.com/seandilda/a5872778c19fd82624809d856f0b7435 With 1.31.1, and both cops enabled, it takes 4.5s |
I guess a part of the logic for searching an offensive node is expensive. For a small file, that may not be a big deal, but for a large file. rubocop/lib/rubocop/cop/mixin/multiline_element_indentation.rb Lines 70 to 76 in 023e0ea
|
…Indentation and Layout/FirstArrayElementIndentation Fixes rubocop#10764. In rubocop v1.31.0, `MultilineElementIndentation` that is used by `Layout/FirstHashElementIndentation` and `Layout/FirstArrayElementIndentation` walks all nodes through in the code to find a hash pair node where its value part begins with the given left-brace; That computation is expensive, so I made a change so that the hash pair is passed by each class that includes `MultilineElementIndentation`.
…tion and Layout/FirstArrayElementIndentation Fixes #10764. In rubocop v1.31.0, `MultilineElementIndentation` that is used by `Layout/FirstHashElementIndentation` and `Layout/FirstArrayElementIndentation` walks all nodes through in the code to find a hash pair node where its value part begins with the given left-brace; That computation is expensive, so I made a change so that the hash pair is passed by each class that includes `MultilineElementIndentation`.
After updating to 1.31.0, my editor started complaining about rubocop timeouts. Some testing has narrowed the issue to the recent changes in
Layout/FirstHashElementIndentation
andLayout/FirstArrayElementIndentation
.Here are some timings from running
time rubocop --cache false testfile.rb
on a file I'm currently working on.Layout/FirstHashElementIndentation
enabledLayout/FirstArrayElementIndentation
enabledtrue
true
true
true
true
false
false
true
false
false
Expected behavior
RuboCop 1.31.0 should run at the same speed as 1.30.1
Actual behavior
Version 1.31.0 is several times slower when
Layout/FirstHashElementIndentation
and/orLayout/FirstArrayElementIndentation
is enabledSteps to reproduce the problem
Run
rubocop --cache false
on a file using a large number of hashes and arrays.RuboCop version
The text was updated successfully, but these errors were encountered: