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

Commit f736248

Browse files
committed
Refactor search benchmarks
1 parent a8defb5 commit f736248

File tree

6 files changed

+999
-417
lines changed

6 files changed

+999
-417
lines changed

benchmarks/benches/formatting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn bench_formatting(c: &mut criterion::Criterion) {
5555
group.bench_function(conf.name, |b| {
5656
b.iter(|| {
5757
let mut matcher = conf.matching_words.build(conf.text);
58-
matcher.format(option.clone());
58+
matcher.format(*option);
5959
})
6060
});
6161
}

benchmarks/benches/indexing.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn setup_dir(path: impl AsRef<Path>) {
3030

3131
fn setup_index() -> Index {
3232
let path = "benches.mmdb";
33-
setup_dir(&path);
33+
setup_dir(path);
3434
let mut options = EnvOpenOptions::new();
3535
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB
3636
options.max_readers(10);
@@ -62,7 +62,7 @@ fn setup_settings<'t>(
6262
builder.execute(|_| (), || false).unwrap();
6363
}
6464

65-
fn setup_index_with_settings<'t>(
65+
fn setup_index_with_settings(
6666
primary_key: &str,
6767
searchable_fields: &[&str],
6868
filterable_fields: &[&str],
@@ -121,7 +121,7 @@ fn indexing_songs_default(c: &mut Criterion) {
121121
let sortable_fields = [];
122122

123123
setup_index_with_settings(
124-
&primary_key,
124+
primary_key,
125125
&searchable_fields,
126126
&filterable_fields,
127127
&sortable_fields,
@@ -166,7 +166,7 @@ fn reindexing_songs_default(c: &mut Criterion) {
166166
let sortable_fields = [];
167167

168168
let index = setup_index_with_settings(
169-
&primary_key,
169+
primary_key,
170170
&searchable_fields,
171171
&filterable_fields,
172172
&sortable_fields,
@@ -232,7 +232,7 @@ fn deleting_songs_in_batches_default(c: &mut Criterion) {
232232
let sortable_fields = [];
233233

234234
let index = setup_index_with_settings(
235-
&primary_key,
235+
primary_key,
236236
&searchable_fields,
237237
&filterable_fields,
238238
&sortable_fields,
@@ -295,7 +295,7 @@ fn indexing_songs_in_three_batches_default(c: &mut Criterion) {
295295
let sortable_fields = [];
296296

297297
let index = setup_index_with_settings(
298-
&primary_key,
298+
primary_key,
299299
&searchable_fields,
300300
&filterable_fields,
301301
&sortable_fields,
@@ -377,7 +377,7 @@ fn indexing_songs_without_faceted_numbers(c: &mut Criterion) {
377377
let sortable_fields = [];
378378

379379
setup_index_with_settings(
380-
&primary_key,
380+
primary_key,
381381
&searchable_fields,
382382
&filterable_fields,
383383
&sortable_fields,
@@ -422,7 +422,7 @@ fn indexing_songs_without_faceted_fields(c: &mut Criterion) {
422422
let sortable_fields = [];
423423

424424
setup_index_with_settings(
425-
&primary_key,
425+
primary_key,
426426
&searchable_fields,
427427
&filterable_fields,
428428
&sortable_fields,
@@ -466,7 +466,7 @@ fn indexing_wiki(c: &mut Criterion) {
466466
let sortable_fields = [];
467467

468468
setup_index_with_settings(
469-
&primary_key,
469+
primary_key,
470470
&searchable_fields,
471471
&filterable_fields,
472472
&sortable_fields,
@@ -511,7 +511,7 @@ fn reindexing_wiki(c: &mut Criterion) {
511511
let sortable_fields = [];
512512

513513
let index = setup_index_with_settings(
514-
&primary_key,
514+
primary_key,
515515
&searchable_fields,
516516
&filterable_fields,
517517
&sortable_fields,
@@ -578,7 +578,7 @@ fn deleting_wiki_in_batches_default(c: &mut Criterion) {
578578
let sortable_fields = [];
579579

580580
let index = setup_index_with_settings(
581-
&primary_key,
581+
primary_key,
582582
&searchable_fields,
583583
&filterable_fields,
584584
&sortable_fields,
@@ -641,7 +641,7 @@ fn indexing_wiki_in_three_batches(c: &mut Criterion) {
641641
let sortable_fields = [];
642642

643643
let index = setup_index_with_settings(
644-
&primary_key,
644+
primary_key,
645645
&searchable_fields,
646646
&filterable_fields,
647647
&sortable_fields,
@@ -732,7 +732,7 @@ fn indexing_movies_default(c: &mut Criterion) {
732732
let sortable_fields = [];
733733

734734
setup_index_with_settings(
735-
&primary_key,
735+
primary_key,
736736
&searchable_fields,
737737
&filterable_fields,
738738
&sortable_fields,
@@ -776,7 +776,7 @@ fn reindexing_movies_default(c: &mut Criterion) {
776776
let sortable_fields = [];
777777

778778
let index = setup_index_with_settings(
779-
&primary_key,
779+
primary_key,
780780
&searchable_fields,
781781
&filterable_fields,
782782
&sortable_fields,
@@ -841,7 +841,7 @@ fn deleting_movies_in_batches_default(c: &mut Criterion) {
841841
let sortable_fields = [];
842842

843843
let index = setup_index_with_settings(
844-
&primary_key,
844+
primary_key,
845845
&searchable_fields,
846846
&filterable_fields,
847847
&sortable_fields,
@@ -903,7 +903,7 @@ fn indexing_movies_in_three_batches(c: &mut Criterion) {
903903
let sortable_fields = [];
904904

905905
let index = setup_index_with_settings(
906-
&primary_key,
906+
primary_key,
907907
&searchable_fields,
908908
&filterable_fields,
909909
&sortable_fields,
@@ -1011,7 +1011,7 @@ fn indexing_nested_movies_default(c: &mut Criterion) {
10111011
let sortable_fields = ["popularity", "runtime", "vote_average", "release_date"];
10121012

10131013
setup_index_with_settings(
1014-
&primary_key,
1014+
primary_key,
10151015
&searchable_fields,
10161016
&filterable_fields,
10171017
&sortable_fields,
@@ -1078,7 +1078,7 @@ fn deleting_nested_movies_in_batches_default(c: &mut Criterion) {
10781078
let sortable_fields = ["popularity", "runtime", "vote_average", "release_date"];
10791079

10801080
let index = setup_index_with_settings(
1081-
&primary_key,
1081+
primary_key,
10821082
&searchable_fields,
10831083
&filterable_fields,
10841084
&sortable_fields,
@@ -1148,7 +1148,7 @@ fn indexing_nested_movies_without_faceted_fields(c: &mut Criterion) {
11481148
let sortable_fields = [];
11491149

11501150
setup_index_with_settings(
1151-
&primary_key,
1151+
primary_key,
11521152
&searchable_fields,
11531153
&filterable_fields,
11541154
&sortable_fields,
@@ -1192,7 +1192,7 @@ fn indexing_geo(c: &mut Criterion) {
11921192
let sortable_fields = ["_geo", "population", "elevation"];
11931193

11941194
setup_index_with_settings(
1195-
&primary_key,
1195+
primary_key,
11961196
&searchable_fields,
11971197
&filterable_fields,
11981198
&sortable_fields,
@@ -1237,7 +1237,7 @@ fn reindexing_geo(c: &mut Criterion) {
12371237
let sortable_fields = ["_geo", "population", "elevation"];
12381238

12391239
let index = setup_index_with_settings(
1240-
&primary_key,
1240+
primary_key,
12411241
&searchable_fields,
12421242
&filterable_fields,
12431243
&sortable_fields,
@@ -1304,7 +1304,7 @@ fn deleting_geo_in_batches_default(c: &mut Criterion) {
13041304
let sortable_fields = ["_geo", "population", "elevation"];
13051305

13061306
let index = setup_index_with_settings(
1307-
&primary_key,
1307+
primary_key,
13081308
&searchable_fields,
13091309
&filterable_fields,
13101310
&sortable_fields,

benchmarks/benches/search_geo.rs

Lines changed: 86 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod utils;
33

44
use criterion::{criterion_group, criterion_main};
55
use milli::update::Settings;
6-
use utils::Conf;
6+
use utils::{IndexConf, IndexSettingsConf, SearchBenchConf};
77

88
#[global_allocator]
99
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
@@ -29,94 +29,93 @@ fn base_conf(builder: &mut Settings) {
2929
builder.set_sortable_fields(sortable_fields);
3030
}
3131

32-
#[rustfmt::skip]
33-
const BASE_CONF: Conf = Conf {
34-
dataset: datasets_paths::SMOL_ALL_COUNTRIES,
35-
dataset_format: "jsonl",
36-
queries: &[
37-
"",
38-
],
39-
configure: base_conf,
40-
primary_key: Some("geonameid"),
41-
..Conf::BASE
42-
};
43-
4432
fn bench_geo(c: &mut criterion::Criterion) {
45-
#[rustfmt::skip]
46-
let confs = &[
47-
// A basic placeholder with no geo
48-
utils::Conf {
49-
group_name: "placeholder with no geo",
50-
..BASE_CONF
51-
},
52-
// Medium aglomeration: probably the most common usecase
53-
utils::Conf {
54-
group_name: "asc sort from Lille",
55-
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):asc"]),
56-
..BASE_CONF
57-
},
58-
utils::Conf {
59-
group_name: "desc sort from Lille",
60-
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):desc"]),
61-
..BASE_CONF
62-
},
63-
// Big agglomeration: a lot of documents close to our point
64-
utils::Conf {
65-
group_name: "asc sort from Tokyo",
66-
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):asc"]),
67-
..BASE_CONF
68-
},
69-
utils::Conf {
70-
group_name: "desc sort from Tokyo",
71-
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):desc"]),
72-
..BASE_CONF
73-
},
74-
// The furthest point from any civilization
75-
utils::Conf {
76-
group_name: "asc sort from Point Nemo",
77-
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):asc"]),
78-
..BASE_CONF
79-
},
80-
utils::Conf {
81-
group_name: "desc sort from Point Nemo",
82-
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):desc"]),
83-
..BASE_CONF
84-
},
85-
// Filters
86-
utils::Conf {
87-
group_name: "filter of 100km from Lille",
88-
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 100000)"),
89-
..BASE_CONF
90-
},
91-
utils::Conf {
92-
group_name: "filter of 1km from Lille",
93-
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 1000)"),
94-
..BASE_CONF
95-
},
96-
utils::Conf {
97-
group_name: "filter of 100km from Tokyo",
98-
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 100000)"),
99-
..BASE_CONF
100-
},
101-
utils::Conf {
102-
group_name: "filter of 1km from Tokyo",
103-
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 1000)"),
104-
..BASE_CONF
105-
},
106-
utils::Conf {
107-
group_name: "filter of 100km from Point Nemo",
108-
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 100000)"),
109-
..BASE_CONF
110-
},
111-
utils::Conf {
112-
group_name: "filter of 1km from Point Nemo",
113-
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 1000)"),
114-
..BASE_CONF
115-
},
116-
];
33+
let index_conf = IndexConf {
34+
dataset: datasets_paths::SMOL_ALL_COUNTRIES,
35+
dataset_format: "jsonl",
36+
primary_key: Some("geonameid"),
37+
configure: base_conf,
38+
..IndexConf::BASE
39+
};
40+
41+
let confs = vec![(
42+
IndexSettingsConf::BASE,
43+
vec![
44+
// A basic placeholder with no geo
45+
SearchBenchConf { group_name: "placeholder with no geo", ..SearchBenchConf::BASE },
46+
// Medium aglomeration: probably the most common usecase
47+
SearchBenchConf {
48+
group_name: "asc sort from Lille",
49+
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):asc"]),
50+
..SearchBenchConf::BASE
51+
},
52+
SearchBenchConf {
53+
group_name: "desc sort from Lille",
54+
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):desc"]),
55+
..SearchBenchConf::BASE
56+
},
57+
// Big agglomeration: a lot of documents close to our point
58+
SearchBenchConf {
59+
group_name: "asc sort from Tokyo",
60+
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):asc"]),
61+
..SearchBenchConf::BASE
62+
},
63+
SearchBenchConf {
64+
group_name: "desc sort from Tokyo",
65+
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):desc"]),
66+
..SearchBenchConf::BASE
67+
},
68+
// The furthest point from any civilization
69+
SearchBenchConf {
70+
group_name: "asc sort from Point Nemo",
71+
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):asc"]),
72+
..SearchBenchConf::BASE
73+
},
74+
SearchBenchConf {
75+
group_name: "desc sort from Point Nemo",
76+
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):desc"]),
77+
..SearchBenchConf::BASE
78+
},
79+
// Filters
80+
SearchBenchConf {
81+
group_name: "filter of 100km from Lille",
82+
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 100000)"),
83+
..SearchBenchConf::BASE
84+
},
85+
SearchBenchConf {
86+
group_name: "filter of 1km from Lille",
87+
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 1000)"),
88+
..SearchBenchConf::BASE
89+
},
90+
SearchBenchConf {
91+
group_name: "filter of 100km from Tokyo",
92+
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 100000)"),
93+
..SearchBenchConf::BASE
94+
},
95+
SearchBenchConf {
96+
group_name: "filter of 1km from Tokyo",
97+
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 1000)"),
98+
..SearchBenchConf::BASE
99+
},
100+
SearchBenchConf {
101+
group_name: "filter of 100km from Point Nemo",
102+
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 100000)"),
103+
..SearchBenchConf::BASE
104+
},
105+
SearchBenchConf {
106+
group_name: "filter of 1km from Point Nemo",
107+
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 1000)"),
108+
..SearchBenchConf::BASE
109+
},
110+
],
111+
)];
117112

118-
utils::run_benches(c, confs);
113+
utils::run_benches(index_conf, c, &confs);
119114
}
120115

121-
criterion_group!(benches, bench_geo);
116+
criterion_group!(
117+
name = benches;
118+
config = { criterion::Criterion::default().sample_size(10) };
119+
targets = bench_geo
120+
);
122121
criterion_main!(benches);

0 commit comments

Comments
 (0)