Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(error-tracking): log large symbol set parses in cymbal (#113129)

Hugues Pouillot16317272e58b
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/caching.rs b/rust/cymbal/src/core/symbolication/symbol_store/caching.rs
index 58c1ab6c20d5..5c66053e2092 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/caching.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/caching.rs
@@ -1,7 +1,9 @@
use std::{any::Any, collections::HashMap, sync::Arc, time::Instant};
use async_trait::async_trait;
+use bytes::Bytes;
use tokio::sync::Mutex;
+use tracing::info;
use crate::metric_consts::{
STORE_CACHED_BYTES, STORE_CACHE_EVICTIONS, STORE_CACHE_EVICTION_RUNS, STORE_CACHE_HITS,
@@ -10,6 +12,12 @@ use crate::metric_consts::{
use super::{chunk_id::SymbolSetCacheKey, Fetcher, Parser, Provider};
+// Parsing can transiently need many times the fetched size (e.g. ProguardCache::write), and
+// none of that is held against the cache budget. We log large parses before they start, so
+// the last log line of an OOM-killed pod names the symbol set that was being parsed.
+const LARGE_FETCHED_BYTES: usize = 10_000_000;
+const LARGE_PARSED_BYTES: usize = 50_000_000;
+
// This is a type-specific symbol provider layer, designed to
// wrap some inner provider and provide a type-safe caching layer
pub struct Caching<P> {
@@ -24,7 +32,7 @@ impl<P> Caching<P>
where
P: Fetcher + Parser<Source = P::Fetched, Err = <P as Fetcher>::Err>,
P::Ref: SymbolSetCacheKey + Send,
- P::Fetched: Send,
+ P::Fetched: Countable + Send,
P::Set: Countable + Any + Send + Sync,
{
pub fn new(inner: P, cache: Arc<Mutex<SymbolSetCache>>) -> Self {
@@ -37,7 +45,7 @@ impl<P> Provider for Caching<P>
where
P: Fetcher + Parser<Source = P::Fetched, Err = <P as Fetcher>::Err>,
P::Ref: SymbolSetCacheKey + Send,
- P::Fetched: Send,
+ P::Fetched: Countable + Send,
P::Set: Countable + Any + Send + Sync,
{
type Ref = P::Ref;
@@ -58,8 +66,28 @@ where
// concurrent fetches to occur. De-duping fetches is handled by the
// `AtMostOne` provider wrapper in the production catalog.
let found = self.inner.fetch(team_id, r).await?;
+ let fetched_bytes = found.byte_count();
+ let set_type = set_type_name::<P::Set>();
+ if fetched_bytes >= LARGE_FETCHED_BYTES {
+ info!(
+ team_id,
+ cache_key, set_type, fetched_bytes, "Parsing large symbol set"
+ );
+ }
+ let parse_start = Instant::now();
let parsed = self.inner.parse(found).await?;
let bytes = parsed.byte_count();
+ if fetched_bytes >= LARGE_FETCHED_BYTES || bytes >= LARGE_PARSED_BYTES {
+ info!(
+ team_id,
+ cache_key,
+ set_type,
+ fetched_bytes,
+ cached_bytes = bytes,
+ parse_ms = parse_start.elapsed().as_millis() as u64,
+ "Parsed large symbol set"
+ );
+ }
let mut cache = self.cache.lock().await; // Re-acquire the cache-wide lock to insert, dropping the ref_lock
@@ -170,6 +198,17 @@ impl Countable for Vec<u8> {
}
}
+impl Countable for Bytes {
+ fn byte_count(&self) -> usize {
+ self.len()
+ }
+}
+
+fn set_type_name<T>() -> &'static str {
+ let name = std::any::type_name::<T>();
+ name.rsplit("::").next().unwrap_or(name)
+}
+
#[cfg(test)]
mod tests {
use std::{
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs b/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
index 0cd452855747..6928b4a626bb 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
@@ -72,6 +72,9 @@ impl FetchedMapping {
let mut cache_bytes = Vec::new();
proguard::ProguardCache::write(&mapping, &mut cache_bytes)
.map_err(|_| ProguardError::InvalidMapping)?;
+ // The writer grows the Vec by doubling, so capacity can be up to twice the length.
+ // The cache counts `len()`, so drop the spare capacity to keep the count accurate.
+ cache_bytes.shrink_to_fit();
proguard::ProguardCache::parse(&cache_bytes).map_err(|_| ProguardError::InvalidMapping)?;
Ok(Self { cache_bytes })
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/saving.rs b/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
index 3d48159bd2af..e5dbe2feefdb 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
@@ -24,7 +24,7 @@ use crate::{
symbolication::symbol_store::{chunk_id::SymbolSetKey, BlobClient},
};
-use super::{Fetcher, Parser};
+use super::{caching::Countable, Fetcher, Parser};
pub(crate) const MAX_REF_BYTES: usize = 2048;
@@ -123,6 +123,12 @@ pub struct Saveable {
pub save_ref: Option<String>,
}
+impl Countable for Saveable {
+ fn byte_count(&self) -> usize {
+ self.data.len()
+ }
+}
+
impl<F> Saving<F> {
pub fn new(
inner: F,