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

pregenerate the pycodestyle plugin to avoid call overhead #1545

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

asottile
Copy link
Member

this saves 10-12% off the execution time of flake8 -j1 src/

  • best of 10 before: 1.469s
  • best of 10 after: 1.301s

the implementation is a tiny bit fragile, though not exceedingly so as we pin pycodestyle.

@andersk
Copy link
Contributor

andersk commented Jan 25, 2022

Would it be even better to generate that code and exec() it at runtime? That could give you a way to remove the overhead for deselected plugins (#751).

@asottile
Copy link
Member Author

Would it be even better to generate that code and exec() it at runtime? That could give you a way to remove the overhead for deselected plugins (#751).

#751 is basically impossible without refactoring how pycodestyle works (checks in pycodestyle do not all fall under unique prefixes and criss cross over)

the codegen is also relatively slow so doing it at runtime would eliminate most of the performance gain

Copy link
Member

@sigmavirus24 sigmavirus24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm never really a fan of code generation but the improvement is hard to deny. I suspect most of the speed comes from fewer entry_points given how abysmal that's always been (regardless of how much faster importlib is than setuptools/pkg_resources).

@asottile
Copy link
Member Author

surprisingly, most of the speedup comes from not needing to call keywords_for and building small kwargs dictionaries many many times

@asottile asottile merged commit 577631c into main Jan 28, 2022
@asottile asottile deleted the codegen-pycodestyle-plugin branch January 28, 2022 02:26
@asottile asottile added this to the 5.0.0 milestone Jul 30, 2022
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 this pull request may close these issues.

None yet

3 participants