Copilot commented on code in PR #1627:
URL: https://github.com/apache/horaedb/pull/1627#discussion_r2106186527


##########
src/server/src/http.rs:
##########
@@ -627,6 +634,30 @@ impl Service {
             )
     }
 
+    // GET /debug/pprof/heap/{seconds}
+    fn pprof_heap(
+        &self,
+    ) -> impl Filter<Extract = (impl warp::Reply,), Error = warp::Rejection> + 
Clone {
+        warp::path!("debug" / "pprof" / "heap" / ..)
+            .and(warp::path::param::<u64>())

Review Comment:
   [nitpick] Using `..` in the `warp::path!` macro combined with a separate 
`param` can be error-prone; consider using `warp::path!("debug" / "pprof" / 
"heap" / u64)` to bind the segment directly for clearer routing.
   ```suggestion
           warp::path!("debug" / "pprof" / "heap" / u64)
   ```



##########
src/components/profile/src/lib.rs:
##########
@@ -183,4 +183,34 @@ impl Profiler {
         })?;
         Ok(())
     }
+
+    pub fn dump_heap_pprof(&self, seconds: u64) -> Result<Vec<u8>> {
+        // concurrent profiling is disabled.
+        let lock_guard = self
+            .heap_prof_lock
+            .try_lock()
+            .map_err(|e| Error::Internal {
+                msg: format!("failed to acquire heap_prof_lock, err:{e}"),
+            })?;
+        info!("Profiler::dump_heap_pprof start heap profiling");
+
+        let _guard = ProfLockGuard::new(lock_guard)?;
+
+        // wait for seconds for collect the profiling data
+        thread::sleep(time::Duration::from_secs(seconds));

Review Comment:
   [nitpick] Since `Duration` is already imported, you can simplify this to 
`thread::sleep(Duration::from_secs(seconds));` for consistency with existing 
imports.
   ```suggestion
           thread::sleep(Duration::from_secs(seconds));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to