diff --git a/quickwit/quickwit-serve/src/developer_api/mod.rs b/quickwit/quickwit-serve/src/developer_api/mod.rs
index 63bb8b6583..fd4a329952 100644
--- a/quickwit/quickwit-serve/src/developer_api/mod.rs
+++ b/quickwit/quickwit-serve/src/developer_api/mod.rs
@@ -19,7 +19,10 @@
mod debug;
mod log_level;
+
+#[cfg_attr(not(feature = "pprof"), path = "pprof_disabled.rs")]
mod pprof;
+
mod rebuild_plan;
mod server;
diff --git a/quickwit/quickwit-serve/src/developer_api/pprof.rs b/quickwit/quickwit-serve/src/developer_api/pprof.rs
index 17b40de310..5dca73806b 100644
--- a/quickwit/quickwit-serve/src/developer_api/pprof.rs
+++ b/quickwit/quickwit-serve/src/developer_api/pprof.rs
@@ -17,22 +17,23 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
+use std::sync::OnceLock;
+
+use regex::Regex;
use warp::Filter;
-/// pprof/start disabled
-/// pprof/flamegraph disabled
-#[cfg(not(feature = "pprof"))]
-pub fn pprof_handlers() -> impl Filter + Clone
-{
- let not_implemented_handler = || {
- warp::reply::with_status(
- "Quickwit was compiled without the `pprof` feature",
- warp::http::StatusCode::NOT_IMPLEMENTED,
- )
- };
- let start_profiler = { warp::path!("pprof" / "start").map(not_implemented_handler) };
- let stop_profiler = { warp::path!("pprof" / "flamegraph").map(not_implemented_handler) };
- start_profiler.or(stop_profiler)
+fn remove_trailing_numbers(thread_name: &mut String) {
+ static REMOVE_TRAILING_NUMBER_PTN: OnceLock = OnceLock::new();
+ let captures_opt = REMOVE_TRAILING_NUMBER_PTN
+ .get_or_init(|| Regex::new(r"^(.*?)[-\d]+$").unwrap())
+ .captures(thread_name);
+ if let Some(captures) = captures_opt {
+ *thread_name = captures[1].to_string();
+ }
+}
+
+fn frames_post_processor(frames: &mut pprof::Frames) {
+ remove_trailing_numbers(&mut frames.thread_name);
}
/// pprof/start to start cpu profiling.
@@ -43,7 +44,6 @@ pub fn pprof_handlers() -> impl Filter impl Filter + Clone
{
use std::sync::{Arc, Mutex};
@@ -133,7 +133,11 @@ pub fn pprof_handlers() -> impl Filter impl Filter.
+
+use warp::Filter;
+
+fn not_implemented_handler() -> impl warp::Reply {
+ warp::reply::with_status(
+ "Quickwit was compiled without the `pprof` feature",
+ warp::http::StatusCode::NOT_IMPLEMENTED,
+ )
+}
+
+/// pprof/start disabled
+/// pprof/flamegraph disabled
+pub fn pprof_handlers() -> impl Filter + Clone
+{
+ let start_profiler = { warp::path!("pprof" / "start").map(not_implemented_handler) };
+ let stop_profiler = { warp::path!("pprof" / "flamegraph").map(not_implemented_handler) };
+ start_profiler.or(stop_profiler)
+}