andygrove commented on code in PR #6883:
URL: https://github.com/apache/datafusion-comet/pull/6883#discussion_r4357502249


##########
native/local/src/lib.rs:
##########
@@ -0,0 +1,300 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Query-scoped execution, independent of Spark tasks and JNI.
+//!
+//! A caller supplies a fresh, fully planned graph for each execution and 
receives one
+//! result stream. The caller owns the Tokio runtime and must keep it running 
until
+//! cleanup finishes. Spark admission and JNI live outside this crate.
+
+pub mod handle;
+
+use std::collections::VecDeque;
+use std::panic::AssertUnwindSafe;
+use std::pin::Pin;
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::{Arc, Mutex, MutexGuard};
+use std::task::{Context, Poll};
+
+use datafusion::arrow::datatypes::SchemaRef;
+use datafusion::arrow::record_batch::RecordBatch;
+use datafusion::common::{DataFusionError, Result};
+use datafusion::execution::TaskContext;
+use datafusion::physical_plan::stream::RecordBatchStreamAdapter;
+use datafusion::physical_plan::{
+    execute_stream, ExecutionPlan, ExecutionPlanProperties, RecordBatchStream,
+    SendableRecordBatchStream,
+};
+use futures::future::poll_fn;
+use futures::{FutureExt, Stream, StreamExt};
+use tokio::task::JoinHandle;
+
+/// Batches each root partition may run ahead of the one being delivered, when 
results are
+/// delivered in partition order.
+const PARTITION_BUFFER: usize = 2;

Review Comment:
   Since `b456e6d03` the handoff only serves a full `collect`, so every 
partition is read to the end anyway. But only the front partition's channel is 
drained, and the others stop after `PARTITION_BUFFER` batches until their turn. 
For a streaming block where the native work dominates, such as `spark.range(0, 
80000000, 1, 8).filter("sha2(cast(id as string), 256) like 'ff%'").collect()` 
at `local[8]`, I think that leaves about one partition working at a time, where 
ordinary Comet runs all eight tasks in parallel. Could you measure a query like 
that with the flag on and off? If local is slower, could started partitions run 
to completion, with what they buffer bounded by `spark.driver.maxResultSize` 
rather than two batches? The bound on how many partitions start would still 
protect the memory pool. The "each up to two batches ahead" sentence in 
`local-execution.md` would change with it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to