-
Notifications
You must be signed in to change notification settings - Fork 381
feat(dyn-batching): add dynamic batching config to async udfs #5919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Greptile SummaryThis PR adds dynamic batching configuration support to async UDFs by changing the Key Changes:
Issues Found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant Node as StreamingSinkNode
participant Sink as AsyncUdfSink
participant Config as ExecutionConfig
participant BatchMgr as BatchManager
participant Worker as Worker Thread
Client->>Node: start()
Node->>Sink: batching_strategy()
Sink->>Config: get_context().execution_config()
Config-->>Sink: {enable_dynamic_batching, dynamic_batching_strategy}
alt enable_dynamic_batching = true
Sink->>Sink: morsel_size_requirement()
alt Returns Flexible(min, max)
Sink-->>Node: Ok(LatencyConstrainedBatchingStrategy)
else Returns Strict(size)
Sink-->>Node: Err("cannot use strict batch size...")
end
else enable_dynamic_batching = false
Sink-->>Node: Ok(StaticBatchingStrategy)
end
Node->>BatchMgr: new(strategy)
Node->>Worker: spawn_workers()
Worker->>BatchMgr: get batches according to strategy
Worker->>Sink: execute(input, state)
Sink-->>Worker: StreamingSinkOutput
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 files reviewed, 1 comment
| let reqs = self.morsel_size_requirement().unwrap_or_default(); | ||
| let MorselSizeRequirement::Flexible(min_batch_size, max_batch_size) = reqs | ||
| else { | ||
| return Err(DaftError::ValueError( | ||
| "cannot use strict batch size requirement with dynamic batching" | ||
| .to_string(), | ||
| )); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This logic will reject scalar UDFs and UDFs with explicit batch sizes when dynamic batching is enabled. Looking at morsel_size_requirement() (lines 368-381), it returns Strict(1) for scalar UDFs and Strict(batch_size) when the user specifies a batch size. These will fail the Flexible pattern match and throw an error.
This means dynamic batching cannot be used with:
- Scalar UDFs (which return
Strict(1)) - UDFs with explicit
batch_sizeparameter (which returnStrict(batch_size))
Only non-scalar UDFs without a batch_size will work with dynamic batching. Is this intentional? The TODO comment on line 389 suggests this limitation was known, but the error message makes it seem like a hard failure rather than a graceful fallback.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/daft-local-execution/src/streaming_sink/async_udf.rs
Line: 390:397
Comment:
**logic:** This logic will reject scalar UDFs and UDFs with explicit batch sizes when dynamic batching is enabled. Looking at `morsel_size_requirement()` (lines 368-381), it returns `Strict(1)` for scalar UDFs and `Strict(batch_size)` when the user specifies a batch size. These will fail the `Flexible` pattern match and throw an error.
This means dynamic batching cannot be used with:
- Scalar UDFs (which return `Strict(1)`)
- UDFs with explicit `batch_size` parameter (which return `Strict(batch_size)`)
Only non-scalar UDFs without a batch_size will work with dynamic batching. Is this intentional? The TODO comment on line 389 suggests this limitation was known, but the error message makes it seem like a hard failure rather than a graceful fallback.
How can I resolve this? If you propose a fix, please make it concise.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5919 +/- ##
==========================================
+ Coverage 72.52% 72.60% +0.08%
==========================================
Files 970 970
Lines 126303 126526 +223
==========================================
+ Hits 91598 91866 +268
+ Misses 34705 34660 -45
🚀 New features to boost your workflow:
|
|
so I think we actually need a different batching strategy for async udfs. Since if they are scalar we set the morsel size to 1. cc @colin-ho any suggestions here? |
|
Oh oops i didn't see your comment. But i think its fine actually. I think the cases are
For scalar previously we always fix to 1, with dynamic batching we just start at 1 and can increase to hit latency |
Changes Made
I was trying to use async udfs the other day and noticed that there's no way to enable dynamic batching for them.
Related Issues