v0.34.0_8

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-18 08:26:35 +02:00
1 parent b6a3e12225
commit 480c3ec769
92 files changed
+298 -10035

No files matched your search

+16 -8
View File
@@ -138,11 +138,21 @@ impl Logs {
pub fn push(&self, entry: LogEntry) {
let has_viewers = self.live.receiver_count() != 0;
let has_sink = self.settings.load().enabled();
// The usual history-only configuration needs no deep copy at all.
// When external consumers are present, clone exactly for history and
// keep the original entry available for streaming/sink delivery.
// Reserve the bounded sink slot BEFORE cloning a log entry. Under
// saturation, the failed enqueue must not copy 30+ owned fields.
let sink_permit = if has_sink {
match self.sink.try_reserve() {
Ok(permit) => Some(permit),
Err(_) => {
self.sink_dropped.fetch_add(1, Ordering::Relaxed);
None
}
}
} else {
None
};
let mut external = Some(entry);
let history_entry = if has_viewers || has_sink {
let history_entry = if has_viewers || sink_permit.is_some() {
external.as_ref().expect("entry").clone()
} else {
external.take().expect("entry")
@@ -165,10 +175,8 @@ impl Logs {
if has_viewers {
let _ = self.live.send(entry.clone());
}
// Snapshot the sink choice once. This preserves sink drop
// accounting and avoids a second ArcSwap load per request.
if has_sink && self.sink.try_send(entry).is_err() {
self.sink_dropped.fetch_add(1, Ordering::Relaxed);
if let Some(permit) = sink_permit {
permit.send(entry);
}
}
}