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

Commit

Permalink
Refactor search benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclec committed Dec 22, 2022
1 parent a8defb5 commit f736248
Show file tree
Hide file tree
Showing 6 changed files with 999 additions and 417 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benches/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn bench_formatting(c: &mut criterion::Criterion) {
group.bench_function(conf.name, |b| {
b.iter(|| {
let mut matcher = conf.matching_words.build(conf.text);
matcher.format(option.clone());
matcher.format(*option);
})
});
}
Expand Down
44 changes: 22 additions & 22 deletions benchmarks/benches/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn setup_dir(path: impl AsRef<Path>) {

fn setup_index() -> Index {
let path = "benches.mmdb";
setup_dir(&path);
setup_dir(path);
let mut options = EnvOpenOptions::new();
options.map_size(100 * 1024 * 1024 * 1024); // 100 GB
options.max_readers(10);
Expand Down Expand Up @@ -62,7 +62,7 @@ fn setup_settings<'t>(
builder.execute(|_| (), || false).unwrap();
}

fn setup_index_with_settings<'t>(
fn setup_index_with_settings(
primary_key: &str,
searchable_fields: &[&str],
filterable_fields: &[&str],
Expand Down Expand Up @@ -121,7 +121,7 @@ fn indexing_songs_default(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -166,7 +166,7 @@ fn reindexing_songs_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -232,7 +232,7 @@ fn deleting_songs_in_batches_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -295,7 +295,7 @@ fn indexing_songs_in_three_batches_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -377,7 +377,7 @@ fn indexing_songs_without_faceted_numbers(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -422,7 +422,7 @@ fn indexing_songs_without_faceted_fields(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -466,7 +466,7 @@ fn indexing_wiki(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -511,7 +511,7 @@ fn reindexing_wiki(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -578,7 +578,7 @@ fn deleting_wiki_in_batches_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -641,7 +641,7 @@ fn indexing_wiki_in_three_batches(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -732,7 +732,7 @@ fn indexing_movies_default(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -776,7 +776,7 @@ fn reindexing_movies_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -841,7 +841,7 @@ fn deleting_movies_in_batches_default(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -903,7 +903,7 @@ fn indexing_movies_in_three_batches(c: &mut Criterion) {
let sortable_fields = [];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1011,7 +1011,7 @@ fn indexing_nested_movies_default(c: &mut Criterion) {
let sortable_fields = ["popularity", "runtime", "vote_average", "release_date"];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1078,7 +1078,7 @@ fn deleting_nested_movies_in_batches_default(c: &mut Criterion) {
let sortable_fields = ["popularity", "runtime", "vote_average", "release_date"];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1148,7 +1148,7 @@ fn indexing_nested_movies_without_faceted_fields(c: &mut Criterion) {
let sortable_fields = [];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1192,7 +1192,7 @@ fn indexing_geo(c: &mut Criterion) {
let sortable_fields = ["_geo", "population", "elevation"];

setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1237,7 +1237,7 @@ fn reindexing_geo(c: &mut Criterion) {
let sortable_fields = ["_geo", "population", "elevation"];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down Expand Up @@ -1304,7 +1304,7 @@ fn deleting_geo_in_batches_default(c: &mut Criterion) {
let sortable_fields = ["_geo", "population", "elevation"];

let index = setup_index_with_settings(
&primary_key,
primary_key,
&searchable_fields,
&filterable_fields,
&sortable_fields,
Expand Down
173 changes: 86 additions & 87 deletions benchmarks/benches/search_geo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod utils;

use criterion::{criterion_group, criterion_main};
use milli::update::Settings;
use utils::Conf;
use utils::{IndexConf, IndexSettingsConf, SearchBenchConf};

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

#[rustfmt::skip]
const BASE_CONF: Conf = Conf {
dataset: datasets_paths::SMOL_ALL_COUNTRIES,
dataset_format: "jsonl",
queries: &[
"",
],
configure: base_conf,
primary_key: Some("geonameid"),
..Conf::BASE
};

fn bench_geo(c: &mut criterion::Criterion) {
#[rustfmt::skip]
let confs = &[
// A basic placeholder with no geo
utils::Conf {
group_name: "placeholder with no geo",
..BASE_CONF
},
// Medium aglomeration: probably the most common usecase
utils::Conf {
group_name: "asc sort from Lille",
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):asc"]),
..BASE_CONF
},
utils::Conf {
group_name: "desc sort from Lille",
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):desc"]),
..BASE_CONF
},
// Big agglomeration: a lot of documents close to our point
utils::Conf {
group_name: "asc sort from Tokyo",
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):asc"]),
..BASE_CONF
},
utils::Conf {
group_name: "desc sort from Tokyo",
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):desc"]),
..BASE_CONF
},
// The furthest point from any civilization
utils::Conf {
group_name: "asc sort from Point Nemo",
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):asc"]),
..BASE_CONF
},
utils::Conf {
group_name: "desc sort from Point Nemo",
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):desc"]),
..BASE_CONF
},
// Filters
utils::Conf {
group_name: "filter of 100km from Lille",
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 100000)"),
..BASE_CONF
},
utils::Conf {
group_name: "filter of 1km from Lille",
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 1000)"),
..BASE_CONF
},
utils::Conf {
group_name: "filter of 100km from Tokyo",
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 100000)"),
..BASE_CONF
},
utils::Conf {
group_name: "filter of 1km from Tokyo",
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 1000)"),
..BASE_CONF
},
utils::Conf {
group_name: "filter of 100km from Point Nemo",
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 100000)"),
..BASE_CONF
},
utils::Conf {
group_name: "filter of 1km from Point Nemo",
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 1000)"),
..BASE_CONF
},
];
let index_conf = IndexConf {
dataset: datasets_paths::SMOL_ALL_COUNTRIES,
dataset_format: "jsonl",
primary_key: Some("geonameid"),
configure: base_conf,
..IndexConf::BASE
};

let confs = vec![(
IndexSettingsConf::BASE,
vec![
// A basic placeholder with no geo
SearchBenchConf { group_name: "placeholder with no geo", ..SearchBenchConf::BASE },
// Medium aglomeration: probably the most common usecase
SearchBenchConf {
group_name: "asc sort from Lille",
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):asc"]),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "desc sort from Lille",
sort: Some(vec!["_geoPoint(50.62999333378238, 3.086269263384099):desc"]),
..SearchBenchConf::BASE
},
// Big agglomeration: a lot of documents close to our point
SearchBenchConf {
group_name: "asc sort from Tokyo",
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):asc"]),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "desc sort from Tokyo",
sort: Some(vec!["_geoPoint(35.749512532692144, 139.61664952543356):desc"]),
..SearchBenchConf::BASE
},
// The furthest point from any civilization
SearchBenchConf {
group_name: "asc sort from Point Nemo",
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):asc"]),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "desc sort from Point Nemo",
sort: Some(vec!["_geoPoint(-48.87561645055408, -123.39275749319793):desc"]),
..SearchBenchConf::BASE
},
// Filters
SearchBenchConf {
group_name: "filter of 100km from Lille",
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 100000)"),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "filter of 1km from Lille",
filter: Some("_geoRadius(50.62999333378238, 3.086269263384099, 1000)"),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "filter of 100km from Tokyo",
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 100000)"),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "filter of 1km from Tokyo",
filter: Some("_geoRadius(35.749512532692144, 139.61664952543356, 1000)"),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "filter of 100km from Point Nemo",
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 100000)"),
..SearchBenchConf::BASE
},
SearchBenchConf {
group_name: "filter of 1km from Point Nemo",
filter: Some("_geoRadius(-48.87561645055408, -123.39275749319793, 1000)"),
..SearchBenchConf::BASE
},
],
)];

utils::run_benches(c, confs);
utils::run_benches(index_conf, c, &confs);
}

criterion_group!(benches, bench_geo);
criterion_group!(
name = benches;
config = { criterion::Criterion::default().sample_size(10) };
targets = bench_geo
);
criterion_main!(benches);
Loading

0 comments on commit f736248

Please sign in to comment.