Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/node/primitives/src/delta_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ impl DeltaBuffer {
pub fn push(&mut self, delta: BufferedDelta) -> bool {
if self.deltas.len() >= self.capacity {
// Evict oldest delta (front of queue)
let _evicted = self.deltas.pop_front();
self.drops += 1;
// Only increment drops if we actually evicted something
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Nit: Edge case handling could be documented or prevented at construction

The pop_front().is_some() check only triggers when capacity == 0 (otherwise len >= capacity guarantees non-empty deque); consider adding a debug_assert or constructor validation for capacity > 0 rather than silently handling this edge case.

Suggested fix:

Add `debug_assert!(self.capacity > 0, "DeltaBuffer with zero capacity");` or validate in `new()`

if self.deltas.pop_front().is_some() {
self.drops += 1;
}
self.deltas.push_back(delta);
false
} else {
Expand Down
1 change: 1 addition & 0 deletions crates/node/tests/sync_sim/sim_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ impl SimRuntime {
for (_delta_id, operations) in buffered_ops {
for op in operations {
n.apply_storage_op(op);
self.metrics.work.record_write();
}
}

Expand Down
Loading