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

perf: refactor to avoid excessive walking #877

Merged
merged 1 commit into from
Jul 1, 2024
Merged

Conversation

anderseknert
Copy link
Member

Store result of vars found in walk into an intermediate object, keyed by rule index and the variable's "context".

The result is quite an improvement:

❯ hyperfine --warmup 2 'regal_main lint bundle' 'regal_new lint bundle'
Benchmark 1: regal_main lint bundle
  Time (mean ± σ):      4.387 s ±  0.174 s    [User: 31.888 s, System: 0.906 s]
  Range (min … max):    4.260 s …  4.820 s    10 runs

Benchmark 2: regal_new lint bundle
  Time (mean ± σ):      3.502 s ±  0.120 s    [User: 24.250 s, System: 0.688 s]
  Range (min … max):    3.308 s …  3.700 s    10 runs

Summary
  regal_new lint bundle ran
    1.25 ± 0.07 times faster than regal_main lint bundle

Store result of vars found in `walk` into an intermediate object,
keyed by rule index and the variable's "context".

Signed-off-by: Anders Eknert <[email protected]>
Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

Nicely done ✨

@anderseknert anderseknert merged commit 300eef2 into main Jul 1, 2024
3 checks passed
@anderseknert anderseknert deleted the walk-vars-once branch July 1, 2024 07:45
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.

2 participants