Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 0215074

Browse files
committed
Add more search benchmarks
1 parent 96ac4fd commit 0215074

File tree

3 files changed

+264
-5
lines changed

3 files changed

+264
-5
lines changed

benchmarks/benches/search_songs.rs

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod datasets_paths;
22
mod utils;
33

44
use criterion::{criterion_group, criterion_main};
5-
use milli::update::Settings;
5+
use milli::{update::Settings, CriterionImplementationStrategy};
66
use utils::Conf;
77

88
#[global_allocator]
@@ -81,6 +81,34 @@ fn bench_songs(c: &mut criterion::Criterion) {
8181
optional_words: false,
8282
..BASE_CONF
8383
},
84+
utils::Conf {
85+
group_name: "proximity set-based",
86+
queries: &[
87+
"black saint sinner lady ",
88+
"les dangeureuses 1960 ",
89+
"The Disneyland Sing-Along Chorus ",
90+
"Under Great Northern Lights ",
91+
"7000 Danses Un Jour Dans Notre Vie ",
92+
],
93+
criterion: Some(&["proximity"]),
94+
optional_words: false,
95+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
96+
..BASE_CONF
97+
},
98+
utils::Conf {
99+
group_name: "proximity iterative",
100+
queries: &[
101+
"black saint sinner lady ",
102+
"les dangeureuses 1960 ",
103+
"The Disneyland Sing-Along Chorus ",
104+
"Under Great Northern Lights ",
105+
"7000 Danses Un Jour Dans Notre Vie ",
106+
],
107+
criterion: Some(&["proximity"]),
108+
optional_words: false,
109+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
110+
..BASE_CONF
111+
},
84112
utils::Conf {
85113
group_name: "typo",
86114
queries: &[
@@ -120,12 +148,35 @@ fn bench_songs(c: &mut criterion::Criterion) {
120148
criterion: Some(&["released-timestamp:desc"]),
121149
..BASE_CONF
122150
},
151+
utils::Conf {
152+
group_name: "asc set-based",
153+
criterion: Some(&["released-timestamp:desc"]),
154+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
155+
..BASE_CONF
156+
},
157+
utils::Conf {
158+
group_name: "asc iterative",
159+
criterion: Some(&["released-timestamp:desc"]),
160+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
161+
..BASE_CONF
162+
},
123163
utils::Conf {
124164
group_name: "desc",
125165
criterion: Some(&["released-timestamp:desc"]),
126166
..BASE_CONF
127167
},
128-
168+
utils::Conf {
169+
group_name: "desc set-based",
170+
criterion: Some(&["released-timestamp:desc"]),
171+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
172+
..BASE_CONF
173+
},
174+
utils::Conf {
175+
group_name: "desc iterative",
176+
criterion: Some(&["released-timestamp:desc"]),
177+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
178+
..BASE_CONF
179+
},
129180
/* then we bench the asc and desc criterion on top of the default criterion */
130181
utils::Conf {
131182
group_name: "asc + default",
@@ -154,6 +205,11 @@ fn bench_songs(c: &mut criterion::Criterion) {
154205
filter: Some("released-timestamp != 1262347200 AND (NOT (released-timestamp = 946728000)) AND (duration-float = 1 OR (duration-float 1.1 TO 1.5 AND released-timestamp > 315576000))"),
155206
..BASE_CONF
156207
},
208+
utils::Conf {
209+
group_name: "big IN filter",
210+
filter: Some("NOT released-timestamp IN [-126230400, -1399075200, -160444800, -189388800, -220924800, -252460800, -283996800, -31536000, -347155200, -378691200, -473385600, -631152000, -694310400, -94694400, 0, 1000166400, 1009843200, 1041379200, 1070323200, 1072915200, 1075852800, 1078099200, 1088640000, 1096588800, 1099612800, 1104537600, 1121644800, 1136073600, 1150156800, 1159660800, 1162339200, 1167609600, 1171584000, 1183248000, 1184112000, 1190419200, 1199145600, 1203724800, 1204329600, 1216339200, 1228089600, 1230768000, 1233446400, 1247097600, 1247961600, 1252886400, 126230400, 1262304000, 1268956800, 1283212800, 1285027200, 1293840000, 1295913600, 1296518400, 1306886400, 1312156800, 1320105600, 1321228800, 1321660800, 1322179200, 1322438400, 1325376000, 1327536000, 1338336000, 1347840000, 1351728000, 1353801600, 1356048000, 1356998400, 1369440000, 1370044800, 1372636800, 1382572800, 1382659200, 1384905600, 1388534400, 1393804800, 1397260800, 1401148800, 1411948800, 1420070400, 1426377600, 1427846400, 1433116800, 1439078400, 1440028800, 1446336000, 1451606400, 1456704000, 1464739200, 1466899200, 1467676800, 1470355200, 1483228800, 1493942400, 1495756800, 1497484800, 1506816000, 1512432000, 1514764800, 1521158400, 1522972800, 1524182400, 1528416000, 1529539200, 1533859200, 1536105600, 1536278400, 1543622400, 1546300800, 1547164800, 1550188800, 1551398400, 1564704000, 1572566400, 157766400, 1577836800, 1585267200, 1587772800, 1597968000, 1601251200, 189302400, 220924800, 252460800, 283996800, 31536000, 315532800, 347155200, 378691200, 410227200, 436492800, 441763200, 473385600, 504921600, 536457600, 567993600, 599616000, 606009600, 63072000 63072000, 631152000, 662688000, 672192000, 694224000, 725846400, 738892800, 757382400, 788918400, 790128000, 797212800, 820454400, 852076800, 854755200, 864518400, 866592000, 868233600, 872121600, 883612800, 886291200, 893980800, 912470400, 915148800, 938736000, 946684800, 94694400, 959904000, 965088000, 978307200, 987033600]"),
211+
..BASE_CONF
212+
},
157213

158214
/* the we bench some global / normal search with all the default criterion in the default
159215
* order */
@@ -171,6 +227,16 @@ fn bench_songs(c: &mut criterion::Criterion) {
171227
.collect::<Vec<&str>>(),
172228
..BASE_CONF
173229
},
230+
utils::Conf {
231+
group_name: "basic without quote set-based",
232+
queries: &BASE_CONF
233+
.queries
234+
.iter()
235+
.map(|s| s.trim()) // we remove the space at the end of each request
236+
.collect::<Vec<&str>>(),
237+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
238+
..BASE_CONF
239+
},
174240
utils::Conf {
175241
group_name: "basic with quote",
176242
queries: basic_with_quote,
@@ -187,6 +253,83 @@ fn bench_songs(c: &mut criterion::Criterion) {
187253
],
188254
..BASE_CONF
189255
},
256+
utils::Conf {
257+
group_name: "prefix search set-based",
258+
queries: &[
259+
"s", // 500k+ results
260+
"a", //
261+
"b", //
262+
"i", //
263+
"x", // only 7k results
264+
],
265+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
266+
..BASE_CONF
267+
},
268+
utils::Conf {
269+
group_name: "prefix search iterative",
270+
queries: &[
271+
"s", // 500k+ results
272+
"a", //
273+
"b", //
274+
"i", //
275+
"x", // only 7k results
276+
],
277+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
278+
..BASE_CONF
279+
},
280+
utils::Conf {
281+
group_name: "words + prefix search",
282+
queries: &[
283+
"Someone I l",
284+
"billie e",
285+
"billie ei",
286+
"i am getting o",
287+
"i am getting ol",
288+
"i am getting old",
289+
"prologue 1 a 1",
290+
"prologue 1 a 10"
291+
],
292+
..BASE_CONF
293+
},
294+
utils::Conf {
295+
group_name: "words + prefix search set-based",
296+
queries: &[
297+
"Someone I l",
298+
"billie e",
299+
"billie ei",
300+
"i am getting o",
301+
"i am getting ol",
302+
"i am getting old",
303+
"prologue 1 a 1",
304+
"prologue 1 a 10"
305+
],
306+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
307+
..BASE_CONF
308+
},
309+
utils::Conf {
310+
group_name: "words + prefix search iterative",
311+
queries: &[
312+
"Someone I l",
313+
"billie e",
314+
"billie ei",
315+
"i am getting o",
316+
"i am getting ol",
317+
"i am getting old",
318+
"prologue 1 a 1",
319+
"prologue 1 a 10"
320+
],
321+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
322+
..BASE_CONF
323+
},
324+
utils::Conf {
325+
group_name: "large offset",
326+
queries: &[
327+
"rock and r",
328+
],
329+
offset: Some(770),
330+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
331+
..BASE_CONF
332+
},
190333
];
191334

192335
utils::run_benches(c, confs);

benchmarks/benches/search_wiki.rs

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod datasets_paths;
22
mod utils;
33

44
use criterion::{criterion_group, criterion_main};
5-
use milli::update::Settings;
5+
use milli::{update::Settings, CriterionImplementationStrategy};
66
use utils::Conf;
77

88
#[global_allocator]
@@ -59,6 +59,32 @@ fn bench_songs(c: &mut criterion::Criterion) {
5959
optional_words: false,
6060
..BASE_CONF
6161
},
62+
utils::Conf {
63+
group_name: "proximity set-based",
64+
queries: &[
65+
"herald sings ",
66+
"april paris ",
67+
"tea two ",
68+
"diesel engine ",
69+
],
70+
criterion: Some(&["proximity"]),
71+
optional_words: false,
72+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
73+
..BASE_CONF
74+
},
75+
utils::Conf {
76+
group_name: "proximity iterative",
77+
queries: &[
78+
"herald sings ",
79+
"april paris ",
80+
"tea two ",
81+
"diesel engine ",
82+
],
83+
criterion: Some(&["proximity"]),
84+
optional_words: false,
85+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
86+
..BASE_CONF
87+
},
6288
utils::Conf {
6389
group_name: "typo",
6490
queries: &[
@@ -104,8 +130,19 @@ fn bench_songs(c: &mut criterion::Criterion) {
104130
..BASE_CONF
105131
},
106132
utils::Conf {
107-
group_name: "basic with quote",
133+
group_name: "basic without quote set-based",
134+
queries: &BASE_CONF
135+
.queries
136+
.iter()
137+
.map(|s| s.trim()) // we remove the space at the end of each request
138+
.collect::<Vec<&str>>(),
139+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
140+
..BASE_CONF
141+
},
142+
utils::Conf {
143+
group_name: "basic with quote iterative",
108144
queries: basic_with_quote,
145+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
109146
..BASE_CONF
110147
},
111148
utils::Conf {
@@ -120,6 +157,70 @@ fn bench_songs(c: &mut criterion::Criterion) {
120157
],
121158
..BASE_CONF
122159
},
160+
utils::Conf {
161+
group_name: "prefix search set-based",
162+
queries: &[
163+
"t", // 453k results
164+
"c", // 405k
165+
"g", // 318k
166+
"j", // 227k
167+
"q", // 71k
168+
"x", // 17k
169+
],
170+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
171+
..BASE_CONF
172+
},
173+
utils::Conf {
174+
group_name: "prefix search iterative",
175+
queries: &[
176+
"t", // 453k results
177+
"c", // 405k
178+
"g", // 318k
179+
"j", // 227k
180+
"q", // 71k
181+
"x", // 17k
182+
],
183+
criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
184+
..BASE_CONF
185+
},
186+
// utils::Conf {
187+
// group_name: "words + prefix search",
188+
// queries: &[
189+
// "t", // 453k results
190+
// "c", // 405k
191+
// "g", // 318k
192+
// "j", // 227k
193+
// "q", // 71k
194+
// "x", // 17k
195+
// ],
196+
// ..BASE_CONF
197+
// },
198+
// utils::Conf {
199+
// group_name: "words + prefix search set-based",
200+
// queries: &[
201+
// "t", // 453k results
202+
// "c", // 405k
203+
// "g", // 318k
204+
// "j", // 227k
205+
// "q", // 71k
206+
// "x", // 17k
207+
// ],
208+
// criterion_implementation_strategy: CriterionImplementationStrategy::OnlySetBased,
209+
// ..BASE_CONF
210+
// },
211+
// utils::Conf {
212+
// group_name: "words + prefix search iterative",
213+
// queries: &[
214+
// "t", // 453k results
215+
// "c", // 405k
216+
// "g", // 318k
217+
// "j", // 227k
218+
// "q", // 71k
219+
// "x", // 17k
220+
// ],
221+
// criterion_implementation_strategy: CriterionImplementationStrategy::OnlyIterative,
222+
// ..BASE_CONF
223+
// },
123224
];
124225

125226
utils::run_benches(c, confs);

benchmarks/benches/utils.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use milli::heed::EnvOpenOptions;
1111
use milli::update::{
1212
IndexDocuments, IndexDocumentsConfig, IndexDocumentsMethod, IndexerConfig, Settings,
1313
};
14-
use milli::{Filter, Index, Object, TermsMatchingStrategy};
14+
use milli::{CriterionImplementationStrategy, Filter, Index, Object, TermsMatchingStrategy};
1515
use serde_json::Value;
1616

1717
pub struct Conf<'a> {
@@ -28,6 +28,10 @@ pub struct Conf<'a> {
2828
/// - if you specify something all the base configuration will be thrown out
2929
/// - if you don't specify anything (None) the default configuration will be kept
3030
pub criterion: Option<&'a [&'a str]>,
31+
/// the implementation strategy used by the criteria
32+
pub criterion_implementation_strategy: CriterionImplementationStrategy,
33+
pub limit: Option<usize>,
34+
pub offset: Option<usize>,
3135
/// the last chance to configure your database as you want
3236
pub configure: fn(&mut Settings),
3337
pub filter: Option<&'a str>,
@@ -49,6 +53,9 @@ impl Conf<'_> {
4953
configure: |_| (),
5054
filter: None,
5155
sort: None,
56+
offset: None,
57+
limit: None,
58+
criterion_implementation_strategy: CriterionImplementationStrategy::Dynamic,
5259
optional_words: true,
5360
primary_key: None,
5461
};
@@ -129,6 +136,14 @@ pub fn run_benches(c: &mut criterion::Criterion, confs: &[Conf]) {
129136
let sort = sort.iter().map(|sort| sort.parse().unwrap()).collect();
130137
search.sort_criteria(sort);
131138
}
139+
if let Some(limit) = conf.limit {
140+
search.limit(limit);
141+
}
142+
if let Some(offset) = conf.offset {
143+
search.offset(offset);
144+
}
145+
search
146+
.criterion_implementation_strategy(conf.criterion_implementation_strategy);
132147
let _ids = search.execute().unwrap();
133148
});
134149
});

0 commit comments

Comments
 (0)