From 0b8bbd87507850f7c9d434ab2e5f9ba7eb99fcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 11 Jul 2023 10:26:50 +0200 Subject: [PATCH] Toggle the puffin profiling with a feature flag --- meilisearch/Cargo.toml | 3 ++- meilisearch/src/main.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/meilisearch/Cargo.toml b/meilisearch/Cargo.toml index 1f51cea84..72c6e27e1 100644 --- a/meilisearch/Cargo.toml +++ b/meilisearch/Cargo.toml @@ -68,7 +68,7 @@ pin-project-lite = "0.2.9" platform-dirs = "0.3.0" prometheus = { version = "0.13.3", features = ["process"] } puffin = "0.16.0" -puffin_http = "0.13.0" +puffin_http = { version = "0.13.0", optional = true } rand = "0.8.5" rayon = "1.7.0" regex = "1.7.3" @@ -135,6 +135,7 @@ zip = { version = "0.6.4", optional = true } [features] default = ["analytics", "meilisearch-types/all-tokenizations", "mini-dashboard"] analytics = ["segment"] +profile-with-puffin = ["dep:puffin_http"] mini-dashboard = [ "actix-web-static-files", "static-files", diff --git a/meilisearch/src/main.rs b/meilisearch/src/main.rs index 5189113ad..3ae3d27cb 100644 --- a/meilisearch/src/main.rs +++ b/meilisearch/src/main.rs @@ -29,8 +29,9 @@ fn setup(opt: &Opt) -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> { let (opt, config_read_from) = Opt::try_build()?; - puffin::set_scopes_on(true); + #[cfg(feature = "profile-with-puffin")] let _server = puffin_http::Server::new(&format!("0.0.0.0:{}", puffin_http::DEFAULT_PORT))?; + puffin::set_scopes_on(cfg!(feature = "profile-with-puffin")); anyhow::ensure!( !(cfg!(windows) && opt.experimental_reduce_indexing_memory_usage),