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

Focus only on path routing. #227

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions BENCHMARKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,38 @@ Check out our [codspeed results](https://codspeed.io/DuskSystems/wayfind/benchma

## Context

For all benchmarks, we percent-decode the path before matching.
After matching, we convert any extracted parameters to strings.
For all benchmarks, we convert any extracted parameters to strings.

Some routers perform these operations automatically, while others require them to be done manually.
Some routers perform this operations automatically, while others require them to be done manually.

We do this to try and match behaviour as best as possible. This is as close to an "apples-to-apples" comparison as we can get.

## `matchit` inspired benches

In a router of 130 routes, benchmark matching 4 paths.
In a router of 130 templates, benchmark matching 4 paths.

| Library | Time | Alloc Count | Alloc Size | Dealloc Count | Dealloc Size |
|:-----------------|----------:|------------:|-----------:|--------------:|-------------:|
| wayfind | 475.73 ns | 5 | 329 B | 5 | 329 B |
| matchit | 551.32 ns | 5 | 480 B | 5 | 512 B |
| path-tree | 564.04 ns | 5 | 480 B | 5 | 512 B |
| xitca-router | 646.81 ns | 8 | 864 B | 8 | 896 B |
| ntex-router | 2.2001 µs | 19 | 1.312 KB | 19 | 1.344 KB |
| route-recognizer | 3.1331 µs | 161 | 8.569 KB | 161 | 8.601 KB |
| routefinder | 6.1604 µs | 68 | 5.088 KB | 68 | 5.12 KB |
| actix-router | 20.956 µs | 215 | 14 KB | 215 | 14.03 KB |
| wayfind | 329.54 ns | 5 | 329 B | 5 | 329 B |
| matchit | 372.73 ns | 5 | 480 B | 5 | 512 B |
| path-tree | 435.01 ns | 5 | 480 B | 5 | 512 B |
| xitca-router | 519.06 ns | 8 | 864 B | 8 | 896 B |
| ntex-router | 2.1569 µs | 19 | 1.312 KB | 19 | 1.344 KB |
| route-recognizer | 3.0280 µs | 161 | 8.569 KB | 161 | 8.601 KB |
| routefinder | 6.1353 µs | 68 | 5.088 KB | 68 | 5.12 KB |
| actix-router | 21.199 µs | 215 | 14 KB | 215 | 14.03 KB |

## `path-tree` inspired benches

In a router of 320 routes, benchmark matching 80 paths.
In a router of 320 templates, benchmark matching 80 paths.

| Library | Time | Alloc Count | Alloc Size | Dealloc Count | Dealloc Size |
|:-----------------|----------:|------------:|-----------:|--------------:|-------------:|
| wayfind | 7.0409 µs | 60 | 3.847 KB | 60 | 3.847 KB |
| path-tree | 8.4434 µs | 60 | 8.727 KB | 60 | 8.75 KB |
| matchit | 9.8761 µs | 141 | 19.09 KB | 141 | 19.11 KB |
| xitca-router | 11.651 µs | 210 | 26.79 KB | 210 | 26.81 KB |
| ntex-router | 35.669 µs | 202 | 20.82 KB | 202 | 20.84 KB |
| route-recognizer | 69.671 µs | 2873 | 192.9 KB | 2873 | 206.1 KB |
| routefinder | 87.075 µs | 526 | 49.68 KB | 526 | 49.71 KB |
| actix-router | 185.31 µs | 2202 | 130.1 KB | 2202 | 130.1 KB |
| wayfind | 4.6335 µs | 60 | 3.847 KB | 60 | 3.847 KB |
| path-tree | 7.0053 µs | 60 | 8.727 KB | 60 | 8.75 KB |
| matchit | 8.1093 µs | 141 | 19.09 KB | 141 | 19.11 KB |
| xitca-router | 9.9790 µs | 210 | 26.79 KB | 210 | 26.81 KB |
| ntex-router | 34.594 µs | 202 | 20.82 KB | 202 | 20.84 KB |
| route-recognizer | 67.158 µs | 2873 | 192.9 KB | 2873 | 206.1 KB |
| routefinder | 85.597 µs | 526 | 49.68 KB | 526 | 49.71 KB |
| actix-router | 186.41 µs | 2202 | 130.1 KB | 2202 | 130.1 KB |
124 changes: 12 additions & 112 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 2 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://doc.rust-lang.org/cargo/reference/workspaces.html
[workspace]
resolver = "2"
members = [".", "crates/*", "examples/*", "fuzz"]
members = [".", "examples/*", "fuzz"]

[workspace.package]
version = "0.7.0"
Expand Down Expand Up @@ -94,35 +94,14 @@ categories.workspace = true
workspace = true

[dependencies]
# Routers
wayfind-authority = { path = "crates/authority" }
wayfind-path = { path = "crates/path" }
wayfind-method = { path = "crates/method" }

# Decoding
wayfind-percent = { path = "crates/percent" }
wayfind-punycode = { path = "crates/punycode" }

# Data Structures
smallvec = { workspace = true }

[dev-dependencies]
wayfind-rails-macro = { path = "crates/rails-macro" }

# Testing
insta = { workspace = true }
similar-asserts = { workspace = true }

# Encoding
percent-encoding = "2.3"

# Serde
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Regex
fancy-regex = "0.14"

# Benchmarking
divan = "0.1"
criterion = { version = "0.5", features = ["html_reports"] }
Expand All @@ -131,21 +110,13 @@ codspeed-criterion-compat = "=2.7.2"

# Routers
actix-router = "=0.5.3"
matchit = "=0.8.5"
matchit = "=0.8.6"
ntex-router = "=0.5.3"
path-tree = "=0.8.1"
route-recognizer = "=0.3.1"
routefinder = "=0.5.4"
xitca-router = "=0.3.0"

[[bench]]
name = "gitlab_criterion"
harness = false

[[bench]]
name = "gitlab_divan"
harness = false

[[bench]]
name = "matchit_criterion"
harness = false
Expand Down
Loading