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

[feature-proposal] faster startup #1363

Open
orgua opened this issue Jan 22, 2024 · 1 comment
Open

[feature-proposal] faster startup #1363

orgua opened this issue Jan 22, 2024 · 1 comment

Comments

@orgua
Copy link
Collaborator

orgua commented Jan 22, 2024

as this linter can be used by IDEs and it is called repeatingly, the startup-overhead should be minimized. benchmarking the whole program vs the next deeper routine:

############# lint_path(demo.md) - Linux, 147 checks
parallel took 71.520 ms -> run0
parallel took 78.004 ms -> run1
parallel took 80.381 ms -> run2
parallel-cached took 1.847 ms -> run0
parallel-cached took 1.336 ms -> run1
parallel-cached took 1.252 ms -> run2

############# proselint(demo.md) - parallel, Linux, 147 checks
parallel took 166.188 ms
parallel-cached took 64.538 ms

Comparing the <2ms vs. 64 ms from the cached runs shows it best. Profiling reveals that some of it is caused by click. As the project does not need much cli-magic it would be best to use basic builtins instead of click. Performance should also improve when regex-str of "static" checks are precompiled into patters and memoized.

@orgua orgua changed the title [feature] faster startup [feature-proposal] faster startup Jan 23, 2024
@Nytelife26 Nytelife26 added this to the 1.0.0 milestone Apr 23, 2024
@Nytelife26
Copy link
Member

Nytelife26 commented May 23, 2024

with click:

CLI initialisation and parsing took 0.00055 s

with argparse:

CLI initialisation and parsing took 0.00112 s

argparse after stat optimisations:

CLI initialisation and parsing took 0.00107 s

running without any parsing at all (baseline):

CLI initialisation and parsing took 0.00002 s

custom implementation, similar to getopt:

CLI initialisation and parsing took 0.00011 s

click is faster than using argparse, it would seem. getopt has much lower figures, close to that of the baseline (average 0.00005 s in my testing), but its implementation details are not very well suited for our purposes. a custom implementation provides a healthy medium, so CLI overhead is now nearly eliminated in the refactor.

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