From be2512daa4bda96f19c734812565407abe1f3a58 Mon Sep 17 00:00:00 2001 From: yaohuiming Date: Wed, 10 Apr 2024 23:34:34 +0800 Subject: [PATCH 1/3] Add debug_span in poll_complete loop --- src/proto/streams/prioritize.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/proto/streams/prioritize.rs b/src/proto/streams/prioritize.rs index 14b37e22..6aaf803f 100644 --- a/src/proto/streams/prioritize.rs +++ b/src/proto/streams/prioritize.rs @@ -528,6 +528,9 @@ impl Prioritize { tracing::trace!("poll_complete"); loop { + let span = tracing::debug_span!("poll_complete_loop"); + let _e = span.enter(); + if let Some(mut stream) = self.pop_pending_open(store, counts) { self.pending_send.push_front(&mut stream); self.try_assign_capacity(&mut stream); From 9953b5af52a54ec8822d5b0390ef6567a5ece0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E5=B9=BF=E5=BA=86?= Date: Thu, 11 Apr 2024 22:30:16 +0800 Subject: [PATCH 2/3] explain why it can fix memory leak --- src/proto/streams/prioritize.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/proto/streams/prioritize.rs b/src/proto/streams/prioritize.rs index 6aaf803f..13f07993 100644 --- a/src/proto/streams/prioritize.rs +++ b/src/proto/streams/prioritize.rs @@ -528,6 +528,9 @@ impl Prioritize { tracing::trace!("poll_complete"); loop { + // Create a new span at the start of the loop to avoid continuously + // adding events to the same span due to tracing in the loop, which + // would lead to an ongoing increase in memory usage. let span = tracing::debug_span!("poll_complete_loop"); let _e = span.enter(); From 4c9f5518309f07f19625f00537d3e3b0a7e7a3e6 Mon Sep 17 00:00:00 2001 From: ZOt6 <57828206+YHM404@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:25:46 +0800 Subject: [PATCH 3/3] Update src/proto/streams/prioritize.rs Co-authored-by: Eliza Weisman --- src/proto/streams/prioritize.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/proto/streams/prioritize.rs b/src/proto/streams/prioritize.rs index 13f07993..68ce9c57 100644 --- a/src/proto/streams/prioritize.rs +++ b/src/proto/streams/prioritize.rs @@ -531,8 +531,7 @@ impl Prioritize { // Create a new span at the start of the loop to avoid continuously // adding events to the same span due to tracing in the loop, which // would lead to an ongoing increase in memory usage. - let span = tracing::debug_span!("poll_complete_loop"); - let _e = span.enter(); + let _span = tracing::debug_span!("poll_complete_loop").entered(); if let Some(mut stream) = self.pop_pending_open(store, counts) { self.pending_send.push_front(&mut stream);