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

eskip: improve lexer performance #2755

Merged
merged 2 commits into from
Jan 16, 2024
Merged

eskip: improve lexer performance #2755

merged 2 commits into from
Jan 16, 2024

Commits on Jan 15, 2024

  1. eskip: use larger predicate for BenchmarkParsePredicates

    Signed-off-by: Alexander Yastrebov <[email protected]>
    AlexanderYastrebov committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    d7f1f12 View commit details
    Browse the repository at this point in the history
  2. eskip: optimize lexer performance

    * do not use fmt.Sprintf in ParseFilters and ParsePredicates
    * avoid allocations for fixed tokens
    * optimize scanWhile loop
    * add scanEscaped fast path
    * optimize scanRegexp and scanEscaped using strings.Builder
    * optimize scanWhitespace
    * optimize selectScanner using switch
    
    ```
    goos: linux
    goarch: amd64
    pkg: github.com/zalando/skipper/eskip
    cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
                      │   HEAD~1    │                HEAD                 │
                      │   sec/op    │   sec/op     vs base                │
    ParsePredicates-8   29.88µ ± 3%   11.33µ ± 2%  -62.09% (p=0.000 n=10)
    
                      │    HEAD~1    │                 HEAD                 │
                      │     B/op     │     B/op      vs base                │
    ParsePredicates-8   4.863Ki ± 0%   2.008Ki ± 0%  -58.71% (p=0.000 n=10)
    
                      │   HEAD~1    │                HEAD                │
                      │  allocs/op  │ allocs/op   vs base                │
    ParsePredicates-8   198.00 ± 0%   33.00 ± 0%  -83.33% (p=0.000 n=10)
    ```
    
    Signed-off-by: Alexander Yastrebov <[email protected]>
    AlexanderYastrebov committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    ace2d1a View commit details
    Browse the repository at this point in the history