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/lexer performance improvement #372

Merged
merged 3 commits into from
Oct 19, 2024

Conversation

ysugimoto
Copy link
Owner

This PR improves lexer performance.

  1. use sync.Pool to reduce memory allocation
  2. use bytes.Buffer to improve performance against append runes.

Copy link

Benchmark Comparison

Name Nanoseconds per operation (ns/op) Memory Size (B/op) Memory Allocation Times (allocs/op)
BenchmarkLexer-4 164541 -> 131838
( 20% improved 👍)
80009 -> 53994
( 33% improved 👍)
2631 -> 1654
( 38% improved 👍)
BenchmarkParser-4 337247 -> 306694
( 10% improved 👍)
399210 -> 372573
( 7% improved 👍)
5034 -> 4049
( 20% improved 👍)
BenchmarkLinter-4 774785 -> 729981
( 6% improved 👍)
577729 -> 550703
( 5% improved 👍)
8093 -> 7109
( 13% improved 👍)
BenchmarkFormatter-4 583969 -> 550283
( 6% improved 👍)
479716 -> 453058
( 6% improved 👍)
6709 -> 5724
( 15% improved 👍)

Copy link

Benchmark Comparison

Name Nanoseconds per operation (ns/op) Memory Size (B/op) Memory Allocation Times (allocs/op)
BenchmarkLexer-4 164279 -> 129582
( 22% improved 👍)
80009 -> 53994
( 33% improved 👍)
2631 -> 1654
( 38% improved 👍)
BenchmarkParser-4 339547 -> 306874
( 10% improved 👍)
399211 -> 372574
( 7% improved 👍)
5034 -> 4049
( 20% improved 👍)
BenchmarkLinter-4 772555 -> 738366
( 5% improved 👍)
578320 -> 550783
( 5% improved 👍)
8093 -> 7109
( 13% improved 👍)
BenchmarkFormatter-4 600372 -> 551978
( 9% improved 👍)
480096 -> 453710
( 6% improved 👍)
6709 -> 5725
( 15% improved 👍)

@ysugimoto ysugimoto merged commit b006e5e into main Oct 19, 2024
6 checks passed
@ysugimoto ysugimoto deleted the perf/lexer-performance-improvement branch October 19, 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.

1 participant