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

Layout/SpaceAroundMethodCallOperator is slow #8021

Closed
marcandre opened this issue May 24, 2020 · 4 comments · Fixed by #8300
Closed

Layout/SpaceAroundMethodCallOperator is slow #8021

marcandre opened this issue May 24, 2020 · 4 comments · Fixed by #8300

Comments

@marcandre
Copy link
Contributor

This cop inspects in O(n^2) instead of O(n) as it should (culprit is this loop) (where n is the order of send nodes / tokens)

As an example, about 10% of rake internal_investigation is currently spent in this cop alone. This would be way worse if the source files were not kept kind of small.

@saurabhmaurya15 would you like to look at this? Using tokens may have been a nice generic way of handling things but we can't afford it. We must use node.loc.

@marcandre
Copy link
Contributor Author

marcandre commented May 25, 2020

Note: one could use token(node).find as a quick improvement for processed_source.find_token, but ideally this could be done without tokens I think

@saurabhmaurya15
Copy link
Contributor

@marcandre Can you help me out with how you did profiling on this? I can give it a shot then.

@marcandre
Copy link
Contributor Author

I need to create a rake task to do this properly, but I want to finish #7868 beforehand. In the meantime there's a rake task for testing a particular cop you could use. If you manage not to use tokens at all it would be a big improvement. Or wait a few days and there will be a rake task to measure the cops...

@ric2b
Copy link
Contributor

ric2b commented Jun 22, 2020

Also ran into the same issue, enabling this cop pushed rubocop runs (cache disabled) from ~1 or 2 minutes to over 20 minutes on my codebase.

It took a bit or work to figure out the culprit (doing bisection with --except) because the debug option (-d) only shows which files are being evaluated, it would be nice to have a "verbose debug" option that also printed which cops were running.

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 a pull request may close this issue.

3 participants