Skip to content

Conversation

@PaurushGarg
Copy link

@PaurushGarg PaurushGarg commented Dec 2, 2025

This PR implements max_samples limit enforcement to prevent OOM by tracking samples at the operator level.

Changes:

  • Added SampleTracker in query/ package with Add(), Remove(), and CheckLimit() methods
  • Added MaxSamples field to Engine.Opts (default 0 = unlimited)
  • Added ErrMaxSamplesExceeded error for limit violations

Tracking Implementation:

Uses delta-based tracking (similar to peak_samples pattern) in three operators:

  • vectorSelector: Tracks StepVector samples across batches
  • matrixSelector: Tracks ring buffer samples (sliding window)
  • subquery: Tracks ring buffer samples (sliding window)

Operator queries buffer.SampleCount(), compares to previous count, and tracks the delta using Add()/Remove().

@MichaHoffmann
Copy link
Contributor

I think we should not support this at the engine here especially not at a logical level - if anything this needs to be pushed down into storage.

Signed-off-by: Paurush Garg <[email protected]>
@PaurushGarg PaurushGarg force-pushed the maxSamplesLimit branch 2 times, most recently from 119b8ef to 42785ef Compare January 29, 2026 01:14
@PaurushGarg
Copy link
Author

PaurushGarg commented Jan 29, 2026

I think we should not support this at the engine here especially not at a logical level - if anything this needs to be pushed down into storage.

Thanks for the feedback! Updated to track only at storage layer (vectorSelector, matrixSelector) similar to peak_samples - at operator level where samples are decoded. Also added tracking in subquery operator since it accumulates samples in ring buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants