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

Use HashMap for literals look up #3277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

987Nabil
Copy link
Contributor

A state machine can not improve literal path matching, since it is only fast for misses, but we need the best performance for hits. This is best done with hash maps.

This PR adds a benchmark for literal path matching and replaces the current ListMap with HashMap. This leads to a significant performance increase, as can be seen below

Run on MacBook Pro M1 Max
Old implementation:
[info] Benchmark                                   Mode  Cnt   Score    Error  Units
[info] RoutesBenchmark.benchmarkSmallDataZioApi   thrpt    3  45.794 ± 16.348  ops/s
[info] RoutesBenchmark.benchmarkSmallDataZioApi2  thrpt    3  63.488 ± 10.817  ops/s
[info] RoutesBenchmark.notFound1                  thrpt    3  60.807 ± 13.060  ops/s
[info] RoutesBenchmark.notFound2                  thrpt    3  60.809 ± 13.525  ops/s

HashMap instead of ListMap:
[info] Benchmark                                   Mode  Cnt   Score    Error  Units
[info] RoutesBenchmark.benchmarkSmallDataZioApi   thrpt    3  67.768 ±  9.438  ops/s
[info] RoutesBenchmark.benchmarkSmallDataZioApi2  thrpt    3  78.646 ± 15.662  ops/s
[info] RoutesBenchmark.notFound1                  thrpt    3  79.978 ±  3.829  ops/s
[info] RoutesBenchmark.notFound2                  thrpt    3  87.911 ±  9.178  ops/s

closes #2960
/claim #2960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Literal path matching via state machine
1 participant