Skip to content

Commit

Permalink
benchmarks: import jetscii's benchmarks
Browse files Browse the repository at this point in the history
There was some discussion about how to compare jetscii with Teddy and
some interesting benchmark results[1]. I decided to import the
benchmarks and see what things look like here.

[1]: shepmaster/jetscii#57
  • Loading branch information
BurntSushi committed Oct 20, 2023
1 parent 964a2d5 commit f227162
Show file tree
Hide file tree
Showing 13 changed files with 161,270 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vim/coc-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"aho-corasick-debug/Cargo.toml",
"benchmarks/engines/rust-aho-corasick/Cargo.toml",
"benchmarks/engines/rust-daachorse/Cargo.toml",
"benchmarks/engines/rust-jetscii/Cargo.toml",
"benchmarks/engines/naive/Cargo.toml",
"benchmarks/shared/Cargo.toml",
"fuzz/Cargo.toml",
Expand Down
174 changes: 174 additions & 0 deletions benchmarks/definitions/jetscii.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
analysis = '''
These benchmarks were ported out of the jetscii crate, specifically from
[Dr-Emann's PR]. There were some irregularities in the benchmark results, so
I thought it might be interesting to include it here.
We add "real" variants of each benchmark as well using a small XML data set on
mental health. The original benchmarks search a haystack consisting entirely of
`a` repeated, with the last byte corresponding to one of the needle bytes. This
is useful for measuring pure throughput, but less good for approximating real
world performance. In this case, for at least `xml-delim3` and `xml-delim5`, it
seems like an XML haystack would be better suited.
[Dr-Emann's PR]: https://github.com/shepmaster/jetscii/pull/57
'''

[[bench]]
model = "count"
name = "space-repeateda"
regex = [' ']
haystack = { contents = "a", repeat = 5_242_880, append = " " }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "xmldelim3-repeateda"
regex = ['<', '>', '&']
haystack = { contents = "a", repeat = 5_242_880, append = "&" }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "xmldelim5-repeateda"
regex = ['<', '>', '&', "'", '"']
haystack = { contents = "a", repeat = 5_242_880, append = '"' }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "big16-repeateda"
regex = [
'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P',
]
haystack = { contents = "a", repeat = 5_242_880, append = "P" }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "big16earlyshort-repeateda"
regex = [
'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P',
]
haystack = { contents = "Pa" }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "big16earlylong-repeateda"
regex = [
'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P',
]
haystack = { contents = "a", repeat = 14, append = "P" }
count = 1
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "space-mentalhealth"
regex = [' ']
haystack = { path = "catalog.data.gov/mental-health-4weeks.xml" }
count = 1_181_201
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "xmldelim3-mentalhealth"
regex = ['<', '>', '&']
haystack = { path = "catalog.data.gov/mental-health-4weeks.xml" }
count = 604_714
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "xmldelim5-mentalhealth"
regex = ['<', '>', '&', "'", '"']
haystack = { path = "catalog.data.gov/mental-health-4weeks.xml" }
count = 688_252
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]

[[bench]]
model = "count"
name = "big16-mentalhealth"
regex = [
'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P',
]
haystack = { path = "catalog.data.gov/mental-health-4weeks.xml" }
count = 176_447
engines = [
"daachorse/bytewise/leftmost-first",
"rust/aho-corasick/dfa/leftmost-first",
"rust/aho-corasick/packed/leftmost-first",
"rust/old-aho-corasick/packed/leftmost-first",
"rust/jetscii/ascii-chars/prebuilt",
]
36 changes: 36 additions & 0 deletions benchmarks/engines.toml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,42 @@
bin = "cargo"
args = ["clean"]

# Engines based on the `jetscii` Rust crate. This is somewhat more appropriately
# compared with routines in `memchr`, but there is some overlap in use cases
# with Teddy's packed searcher for multiple single-byte needles.

[[engine]]
name = "rust/jetscii/ascii-chars/prebuilt"
cwd = "./engines/rust-jetscii"
[engine.version]
bin = "./target/release/main"
args = ["--version"]
[engine.run]
bin = "./target/release/main"
args = ["ascii-chars-prebuilt"]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
[[engine.clean]]
bin = "cargo"
args = ["clean"]

[[engine]]
name = "rust/jetscii/ascii-chars/oneshot"
cwd = "./engines/rust-jetscii"
[engine.version]
bin = "./target/release/main"
args = ["--version"]
[engine.run]
bin = "./target/release/main"
args = ["ascii-chars-oneshot"]
[[engine.build]]
bin = "cargo"
args = ["build", "--release"]
[[engine.clean]]
bin = "cargo"
args = ["clean"]

# Naive engines. Useful for comparisons and to determine the crossover point
# where a multi-substring algorithm is beneficial over multi single-substring
# algorithms. We include both the `memchr` crate and `std`.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/engines/naive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ path = "../../shared"
[profile.release]
debug = true
codegen-units = 1
lto = "thin"
lto = "fat"
2 changes: 1 addition & 1 deletion benchmarks/engines/rust-aho-corasick/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ path = "../../shared"
[profile.release]
debug = true
codegen-units = 1
lto = "thin"
lto = "fat"
2 changes: 1 addition & 1 deletion benchmarks/engines/rust-daachorse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ path = "../../shared"
[profile.release]
debug = true
codegen-units = 1
lto = "thin"
lto = "fat"
54 changes: 54 additions & 0 deletions benchmarks/engines/rust-jetscii/Cargo.lock

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

23 changes: 23 additions & 0 deletions benchmarks/engines/rust-jetscii/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
publish = false
name = "main"
version = "0.5.3"
edition = "2021"

[workspace]

[dependencies]
anyhow = "1.0.72"
jetscii = "=0.5.3"

[dependencies.shared]
path = "../../shared"

[[bin]]
name = "main"
path = "main.rs"

[profile.release]
debug = true
codegen-units = 1
lto = "fat"
Loading

0 comments on commit f227162

Please sign in to comment.