Skip to content

Performance improvements #15

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

Merged
merged 2 commits into from
Nov 6, 2017
Merged

Performance improvements #15

merged 2 commits into from
Nov 6, 2017

Conversation

veelenga
Copy link
Member

@veelenga veelenga commented Nov 6, 2017

Two main improvements:

  1. Cache parsed AST in a Source. So Parser will parse content only once.
  2. Use one unified visitor with multiple callbacks instead of multiple visitors to traverse AST.

This improves performance significantly, for example running it on a Crystal repository now takes ~1 second, instead of 6 seconds that it was before (1179 files).

Benchmarks:

== Compare:
  1 source  12.69k (  78.8µs) (± 1.12%)       fastest
 3 sources   6.21k (161.15µs) (± 1.34%)  2.04× slower
 5 sources   1.87k (533.92µs) (± 1.24%)  6.78× slower
10 sources 869.12  (  1.15ms) (± 2.20%) 14.60× slower
20 sources  487.1  (  2.05ms) (± 1.12%) 26.05× slower
30 sources 361.01  (  2.77ms) (± 1.06%) 35.15× slower
40 sources 361.28  (  2.77ms) (± 0.86%) 35.12× slower
== Measure:
  0.010000   0.020000   0.030000 (  0.018274)

in comparison to master:

== Compare:
  1 source    1.2k (832.79µs) (± 2.44%)       fastest
 3 sources 697.94  (  1.43ms) (± 2.08%)  1.72× slower
 5 sources 204.45  (  4.89ms) (± 5.59%)  5.87× slower
10 sources  103.1  (   9.7ms) (± 3.42%) 11.65× slower
20 sources  61.21  ( 16.34ms) (± 1.62%) 19.62× slower
30 sources  47.33  ( 21.13ms) (± 1.53%) 25.37× slower
40 sources  47.56  ( 21.03ms) (± 1.16%) 25.25× slower
== Measure:
  0.060000   0.040000   0.100000 (  0.073773)

Two main changes:

1. Cache parsed AST in a Source. So Parser will parse content only once.
2. Use one unified visitor with multiple callbacks instead of multiple
visitors to traverse AST.

This improves performance significantly, for example running it on
Crystal repository takes ~1 second, which 6 times faster than before.
@veelenga veelenga merged commit adfe654 into master Nov 6, 2017
@veelenga veelenga deleted the feat/performance branch November 6, 2017 18:55
@Sija Sija added the refactor label Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants