You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
DataFusion has traditionally been developed using techniques from Batch processing systems and tries to maximize throughput by being as efficient as possible per tuple. This often involves techniques such as batching rows together to amortize the overhead of each row
However, it also seems increasingly common to try and use DataFusion for streaming systems, similar to Apache Flink, which typically have "unbounded queries" that run indefinitely and place a high value on values being produced quickly (to minimize latency) rather than simply raw per-row computation.
I think we have a bunch of features for streaming documented / tested in isolation already (see below) but the overall design and goal is not clearly documented or tested and thus the overall experience is regressing
The recent presentation on youtube from @sap1ens also mentioned this mismatch between streaming and batch oriented workflows for several built in operators:
It turns out that unfortunately we are making it worse for streaming engines recently by making things better for batch execution (typically by moving buffering into the execution nodes)
Given how many systems seem to want to use DataFusion for streaming systems (rather than batch oriented ones) and the natural tension between batching (maximize throughput) vs streaming (minimize latency) I think if we should formalize / test / document the best way to configure DataFusion for streaming.
Describe alternatives you've considered
Better documentation / tests
Maybe part of this epic could be just to document what we have better
Drain-on-pending (suggested by @ahirner in this comment): keep coalescing while input is Poll::Ready, but flush the
residual whenever the input returns Pending instead of holding it.
Size-or-deadline (suggested by @goutamadwant (comment) / @calvinchengx (comment)): flush at batch_size OR after a
configurable maximum batch age, whichever comes first.
Richer emission triggers (suggested by @jayzhan211 in this comment): time-based, idle-based (N empty polls), or
watermark / checkpoint-barrier-based, if DataFusion later grows control-message propagation
Is your feature request related to a problem or challenge?
DataFusion has traditionally been developed using techniques from Batch processing systems and tries to maximize throughput by being as efficient as possible per tuple. This often involves techniques such as batching rows together to amortize the overhead of each row
However, it also seems increasingly common to try and use DataFusion for streaming systems, similar to Apache Flink, which typically have "unbounded queries" that run indefinitely and place a high value on values being produced quickly (to minimize latency) rather than simply raw per-row computation.
I think we have a bunch of features for streaming documented / tested in isolation already (see below) but the overall design and goal is not clearly documented or tested and thus the overall experience is regressing
The recent presentation on youtube from @sap1ens also mentioned this mismatch between streaming and batch oriented workflows for several built in operators:
It turns out that unfortunately we are making it worse for streaming engines recently by making things better for batch execution (typically by moving buffering into the execution nodes)
RepartitionExecRepartitionExecwithholds all output from an unbounded input untilbatch_sizerows accumulate #24044FilterExec(DF 52), Remove FilterExec from CoalesceBatches optimization rule, add fetch support #18630 / Remove coalesce batches rule and deprecate CoalesceBatchesExec #19622 removedCoalesceBatchesentirely so buffering is now inside the operatorThere is some basic infrastructure today, but it isn't used / respected everywhere and there isn't an over arching strategy / description of its use
However, given that we are regressing behavior for streaming I think we should consider formalizing this functionality more
Example Streaming Systems
Describe the solution you'd like
Given how many systems seem to want to use DataFusion for streaming systems (rather than batch oriented ones) and the natural tension between batching (maximize throughput) vs streaming (minimize latency) I think if we should formalize / test / document the best way to configure DataFusion for streaming.
Describe alternatives you've considered
Better documentation / tests
Maybe part of this epic could be just to document what we have better
UNBOUNDEDtables) #9016Config Flag
Maybe it would be worth some sort of "bounded configuration mode" setting to make implementing streaming systems easier
For example,
streamingoroptimize_for_latency(maybe repurpose datafusion.execution.coalesce_batches (source) -- since Remove coalesce batches rule and deprecate CoalesceBatchesExec #19622 I don't think anything reads itBetter propagation / policies
Several potential policies for when operators should flush partially-full batches came up in the context of #24044:
fix: avoid buffering unbounded repartition output indefinitely #24193 for
RepartitionExec): simple and fixes thecorrectness issue, but @calvinchengx (comment) and @jayzhan211 (comment) note it may not be applicable to all cases
Poll::Ready, but flush theresidual whenever the input returns
Pendinginstead of holding it.batch_sizeOR after aconfigurable maximum batch age, whichever comes first.
watermark / checkpoint-barrier-based, if DataFusion later grows control-message propagation
Make more operators respect buffering
Additional context
We have discussed this in the past
execution_modewithemission_typeandboundedness#13823Related Issues
UNBOUNDEDtables) #9016RepartitionExecwithholds all output from an unbounded input untilbatch_sizerows accumulate #24044 (fix proposed in fix: avoid buffering unbounded repartition output indefinitely #24193)AccumulatorsandScalarValueserializable #11369