Skip to Content
EngineBuffer Manager

Buffer Manager

The Buffer Manager controls temporary data produced while a query executes. Joins, sorts, grouping, aggregations and other operators may process much more data than the final result returned to the client.

It keeps intermediate data in memory and, when disk buffering is enabled, persists batches that no longer fit the in-memory working set.

Buffer Manager decision flow for memory, file or RocksDB storage

Buffer Manager storage and the query result cache solve different problems. The buffer supports an active query; the result cache reuses a completed result. Buffer files are temporary execution state, not a durable application database.

Configure memory and spill v26.7+

Buffer settings belong to the application configuration:

buffer: useDisk: true encrypt: true directory: "/var/lib/kubling/buffer" memoryBufferSpaceMb: 512 maxReservedHeapMb: 256
PropertyPurposeDefault when omitted
useDiskAllows intermediate data to spill to persistent buffer storagetrue
encryptEnables encryption for engine-managed buffer filestrue
directoryRoot directory for persistent buffer storageSystem temporary directory
memoryBufferSpaceMbFixed memory budget, in MiB, for the engine buffer cacheCalculated automatically
maxReservedHeapMbMaximum heap, in MiB, reserved for intermediate query processing before spillCalculated automatically

memoryBufferSpaceMb must be greater than zero when configured. maxReservedHeapMb must be between 1 and 2097151 MiB. Omitting either setting preserves automatic sizing.

These are engine query-processing budgets, not a container memory limit. Leave headroom for the JVM, providers, scripting, result caches and other process workloads. A fixed budget that fits in isolation can still be unsafe under concurrent queries.

Memory-only mode

buffer: useDisk: false

Memory-only mode removes the disk fallback. Use it only when the complete concurrent working set is bounded and fits the available memory. A configured RocksDB backend is ignored when useDisk is false.

Default file-backed mode

buffer: useDisk: true directory: "/var/lib/kubling/buffer"

This is the default buffering model. For containers, use a writable volume with enough capacity for the expected concurrent spill rather than relying on an ephemeral system temporary directory.

RocksDB-backed buffer

RocksDB can replace the default file-backed persistent buffer while keeping the same in-memory front. Enable it only with disk buffering:

buffer: useDisk: true directory: "/var/lib/kubling/buffer" rocksBackedBuffer: enabled: true maxStorageSpace: 10737418240 maxOpsPerCommit: 10000 maxOpenFiles: 1024 writeBufferSize: 67108864 backgroundThreads: 2 inlineLobThresholdBytes: 1048576
PropertyDefaultUnitEffect
enabledfalse—Selects RocksDB instead of the default persistent buffer
maxStorageSpace10737418240bytesMaximum RocksDB buffer storage
maxOpsPerCommit10000operationsBatched writes before commit
maxOpenFiles1024filesRocksDB open-file limit
writeBufferSize67108864bytesRocksDB memtable size
backgroundThreads2threadsCompaction and flush workers
inlineLobThresholdBytes1048576bytesLargest supported LOB kept inside a RocksDB tuple batch

LOB values above inlineLobThresholdBytes use the file store instead of being inlined into the tuple batch. Increasing the threshold may reduce separate LOB objects but creates larger batches and can increase memory and serialization work.

RocksDB-backed buffering is not the embedded RocksDB Data Source. One stores temporary query batches; the other exposes persistent application tables.

Observe buffer use

The regular metrics endpoint exposes process-wide Buffer Manager state:

MetricMeaning
kubling.bm.mem.usageEstimated Buffer Manager memory use in MiB
kubling.bm.disk.usageCurrent persistent buffer use in MiB
kubling.bm.disk.write.totalPersistent write operations since process start
kubling.bm.disk.read.totalPersistent read operations since process start

See Metrics for exporter details.

For query-correlated evidence, enable the Performance Tracer in a controlled environment. Its buffer events distinguish logical activity from successful physical persistence:

  • PHYSICAL_WRITE records persistence caused by aging
  • SPILL records persistence caused by memory pressure
  • bytes is the engine batch-size estimate and elements is its row count

Each event is emitted after the first successful persistence of the batch.

Tune from evidence

Start with automatic memory sizing and the default file-backed buffer. Change one dimension at a time and compare the same representative workload.

ObservationAction to evaluate
Memory grows and disk counters remain zeroConfirm useDisk, storage availability and whether the workload has reached spill conditions
Frequent spills with acceptable disk capacityReview concurrent query volume and memory budgets before increasing them
Disk usage approaches available capacityReduce concurrency, increase the mounted volume or review the RocksDB storage limit
A small workload slows after changing backendRe-test with the default file-backed buffer; persistence is a stability mechanism, not a guaranteed speedup

The complete configuration reference is available under Main Application Configuration.

Last updated on