Skip to content

Commit 0ea5fb7

Browse files
authored
Merge pull request #15 from Quad9DNS/hashbrown-integration
Replace std HashMap with hashbrown for performance boost
2 parents cf4b735 + 554b736 commit 0ea5fb7

File tree

8 files changed

+41
-16
lines changed

8 files changed

+41
-16
lines changed

Cargo.lock

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ confusables = { version = "0.1.0" }
2323
criterion = { version = "0.5.1" }
2424
exitcode = { version = "1.1.2" }
2525
futures = { version = "0.3.31" }
26+
hashbrown = { version = "0.16.1" }
2627
lazy_static = { version = "1.5.0" }
2728
metrics = { version = "0.24.2" }
2829
metrics-exporter-prometheus = { version = "0.17.0" }

bin/stringsimile-service/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ async-stream.workspace = true
9797
clap = { workspace = true, features = ["derive"] }
9898
exitcode.workspace = true
9999
futures.workspace = true
100-
metrics.workspace = true
100+
hashbrown.workspace = true
101101
metrics-exporter-prometheus.workspace = true
102102
metrics-util.workspace = true
103+
metrics.workspace = true
103104
rdkafka = { workspace = true, optional = true }
104105
serde.workspace = true
105106
serde_json.workspace = true
@@ -108,8 +109,8 @@ snafu.workspace = true
108109
sysinfo.workspace = true
109110
tokio = { workspace = true, features = ["full"] }
110111
tokio-stream = { workspace = true, features = ["io-util", "sync"] }
111-
tracing.workspace = true
112112
tracing-subscriber.workspace = true
113+
tracing.workspace = true
113114
walkdir.workspace = true
114115

115116
[dev-dependencies]

bin/stringsimile-service/src/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use hashbrown::HashMap;
12
use std::{
2-
collections::HashMap,
33
fs::File,
44
io::{BufReader, Seek},
55
panic,

crates/stringsimile-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version.workspace = true
88
[dependencies]
99
stringsimile-matcher.workspace = true
1010

11+
hashbrown.workspace = true
1112
serde = { workspace = true, features = ["derive"] }
1213
serde_json.workspace = true
1314
snafu.workspace = true

crates/stringsimile-matcher/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rules-bitflip = ["dep:lazy_static"]
2424
confusables = { workspace = true, optional = true }
2525
lazy_static = { workspace = true, optional = true }
2626
metrics.workspace = true
27+
hashbrown.workspace = true
2728
rphonetic = { workspace = true, optional = true }
2829
serde = { workspace = true, features = ["derive"] }
2930
serde_json.workspace = true

crates/stringsimile-matcher/src/rules/bitflip.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//! Bitflip rule implementation
22
3-
use std::{
4-
collections::{HashMap, HashSet},
5-
fmt::Debug,
6-
io::Error,
7-
};
3+
use hashbrown::{HashMap, HashSet};
4+
use std::{fmt::Debug, io::Error};
85

96
use serde::{Deserialize, Serialize};
107

@@ -83,7 +80,7 @@ impl BitflipRule {
8380
.flat_map(move |(i, c)| {
8481
let string = target_str.to_owned();
8582
bitflips
86-
.get(&(c.try_into().unwrap()))
83+
.get::<u8>(&(c.try_into().unwrap()))
8784
.into_iter()
8885
.flatten()
8986
.map(move |c| {

crates/stringsimile-matcher/src/ruleset.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Group of related rules
22
3-
use std::{
4-
collections::{BTreeMap, HashMap},
5-
ops::Deref,
6-
};
3+
use hashbrown::HashMap;
4+
use std::{collections::BTreeMap, ops::Deref};
75

86
use metrics::{Counter, counter};
97
use serde_json::{Map, Value};

0 commit comments

Comments
 (0)