Use mimalloc for benchmarks on macOS

This commit is contained in:
Loïc Lecrenier 2022-08-10 12:31:09 +02:00
parent 950d8e4c44
commit 8f73251012
6 changed files with 24 additions and 0 deletions

View File

@ -13,6 +13,10 @@ csv = "1.1.6"
[target.'cfg(target_os = "linux")'.dependencies] [target.'cfg(target_os = "linux")'.dependencies]
jemallocator = "0.3.2" jemallocator = "0.3.2"
[target.'cfg(target_os = "macos")'.dependencies]
mimalloc = { version = "0.1.29", default-features = false }
[dev-dependencies] [dev-dependencies]
heed = { git = "https://github.com/meilisearch/heed", tag = "v0.12.1" } heed = { git = "https://github.com/meilisearch/heed", tag = "v0.12.1" }
criterion = { version = "0.3.5", features = ["html_reports"] } criterion = { version = "0.3.5", features = ["html_reports"] }

View File

@ -6,6 +6,10 @@ use milli::{FormatOptions, MatcherBuilder, MatchingWord, MatchingWords};
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[cfg(target_os = "macos")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
struct Conf<'a> { struct Conf<'a> {
name: &'a str, name: &'a str,
text: &'a str, text: &'a str,

View File

@ -18,6 +18,10 @@ use roaring::RoaringBitmap;
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[cfg(target_os = "macos")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
const BENCHMARK_ITERATION: usize = 10; const BENCHMARK_ITERATION: usize = 10;
fn setup_dir(path: impl AsRef<Path>) { fn setup_dir(path: impl AsRef<Path>) {

View File

@ -9,6 +9,10 @@ use utils::Conf;
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[cfg(target_os = "macos")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn base_conf(builder: &mut Settings) { fn base_conf(builder: &mut Settings) {
let displayed_fields = let displayed_fields =
["geonameid", "name", "asciiname", "alternatenames", "_geo", "population"] ["geonameid", "name", "asciiname", "alternatenames", "_geo", "population"]

View File

@ -9,6 +9,10 @@ use utils::Conf;
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[cfg(target_os = "macos")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn base_conf(builder: &mut Settings) { fn base_conf(builder: &mut Settings) {
let displayed_fields = let displayed_fields =
["id", "title", "album", "artist", "genre", "country", "released", "duration"] ["id", "title", "album", "artist", "genre", "country", "released", "duration"]

View File

@ -9,6 +9,10 @@ use utils::Conf;
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[cfg(target_os = "macos")]
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn base_conf(builder: &mut Settings) { fn base_conf(builder: &mut Settings) {
let displayed_fields = ["title", "body", "url"].iter().map(|s| s.to_string()).collect(); let displayed_fields = ["title", "body", "url"].iter().map(|s| s.to_string()).collect();
builder.set_displayed_fields(displayed_fields); builder.set_displayed_fields(displayed_fields);