fix(perfetto): Introduces memory/size limits for perfetto conversion#6244
Open
Dav1dde wants to merge 1 commit into
Open
fix(perfetto): Introduces memory/size limits for perfetto conversion#6244Dav1dde wants to merge 1 commit into
Dav1dde wants to merge 1 commit into
Conversation
Dav1dde
force-pushed
the
dav1d/memory-limits
branch
from
July 17, 2026 11:07
95277cf to
6619f2f
Compare
loewenheim
reviewed
Jul 17, 2026
| /// Returns [`BudgetExceeded`] if the memory budget is exhausted. | ||
| pub fn insert(&mut self, k: K, v: V) -> Result<Option<V>, BudgetExceeded> { | ||
| let key_size = k.size(); | ||
| self.budget.try_add(key_size + v.size())?; |
Contributor
There was a problem hiding this comment.
This can fail even though you theoretically have enough budget, because you're temporarily consuming the key's size twice. Probably doesn't matter much in practice.
Comment on lines
+228
to
+239
| macro_rules! impl_budget_size_vec_copy { | ||
| ($T:ty) => { | ||
| impl BudgetSize for Vec<$T> | ||
| where | ||
| $T: Copy, | ||
| { | ||
| fn size(&self) -> usize { | ||
| std::mem::size_of::<Vec<$T>>() + (self.len() * std::mem::size_of::<$T>()) | ||
| } | ||
| } | ||
| }; | ||
| } |
Contributor
There was a problem hiding this comment.
Couldn't this more generally be impl<T> BudgetSize for Vec<T> where T: BudgetSize (using T's size method instead of size_of, of course)? I think the logic should always be the same—the memory consumption of the Vec is the memory consumption of all items plus the overhead of the Vec itself.
| let cache = self.cache.entry(seq_id).or_default(); | ||
| // Technically this is off by-one, but significantly easier to handle. | ||
| if self.inner.len() >= consts::MAX_SEQUENCE_IDS { | ||
| return Err(BudgetExceeded); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: INGEST-1017