Skip to content

Add bytes-based flushing to source collectors#1102

Open
46bit wants to merge 2 commits into
ArroyoSystems:masterfrom
46bit:miki/bytes-based-collector-flushing
Open

Add bytes-based flushing to source collectors#1102
46bit wants to merge 2 commits into
ArroyoSystems:masterfrom
46bit:miki/bytes-based-collector-flushing

Conversation

@46bit

@46bit 46bit commented Jul 10, 2026

Copy link
Copy Markdown

What

Sources read data in and collect it up into batches. Batches are flushed based on configurable criteria: until now this has been the number of records collected and how long they have been waiting.

This commit adds another criteria for flushing, based on the memory usage of the records. source-batch-max-bytes, disabled by default, allows triggering flushing when a certain amount of data has been collected.

Why

This new feature enables two useful behaviours:

  1. Large records: reduce the risk of OOMs when memory-constrained
  2. Small records: create larger, more-efficient batches

How

Memory usage is estimated based on input bytes, rather than by instrumenting Arrow buffer memory.

Ideally we would implement this based on Arrow buffer usage. However, Arrow's ArrayBuilder trait doesn't expose memory size and we would need to maintain a lot of code ourselves to make it work. I think it's reasonable to use input bytes as an approximation.


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@46bit 46bit force-pushed the miki/bytes-based-collector-flushing branch from fd29177 to 9ebfc42 Compare July 10, 2026 16:23
46bit added 2 commits July 10, 2026 17:44
Sources read data in and collect it up into batches. Batches are flushed
based on configurable criteria: until now this has been the number of
records collected and how long they have been waiting.

This commit adds another criteria for flushing, based on the memory
usage of the records. `source-batch-max-bytes`, disabled by default,
allows triggering flushing when a certain amount of data has been
collected.

This new feature enables two useful behaviours:

1) Large records: reduce the risk of OOMs when memory-constrained
2) Small records: create larger, more-efficient batches

Memory usage is estimated based on input bytes, rather than by
instrumenting Arrow buffer memory.

Ideally we would implement this based on Arrow buffer usage. However,
Arrow's `ArrayBuilder` trait doesn't expose memory size and we would
need to maintain a lot of code ourselves to make it work. I think it's
reasonable to use input bytes as an approximation.
Apache policy removes old releases from downloads.apache.org (and its
CDN, dlcdn.apache.org) once a version branch is no longer current.
Switch to archive.apache.org, which retains all historical releases.
@46bit 46bit force-pushed the miki/bytes-based-collector-flushing branch from 9ebfc42 to 2ccfaf7 Compare July 10, 2026 16:45
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.

1 participant