zhangfengcdt commented on code in PR #7804:
URL: https://github.com/apache/datafusion-comet/pull/7804#discussion_r4759303267
##########
native/core/src/execution/jni_api.rs:
##########
@@ -1300,12 +1300,11 @@ unsafe fn export_batch(
Ok(num_rows as i64)
}
-/// Pull the next input from JVM. Note that we cannot pull input batches in
-/// `ScanStream.poll_next` when the execution stream is polled for output.
-/// Because the input source could be another native execution stream, which
-/// will be executed in another tokio blocking thread. It causes JNI throw
-/// Java exception. So we pull input batches here and insert them into scan
-/// operators before polling the stream,
+/// Pulls the next batch from the JVM into every JVM-fed scan whose slot is
empty. `next_batch`
+/// calls it only after a poll of the stream returns `Pending`. It cannot run
inside
Review Comment:
I measured a JVM-fed scan + project (a + 1 on one Long column) through
CometExec.getCometIterator, comparing release builds of the native library
(-Ctarget-cpu=native) with and without this change. Before and after ran
alternately in separate JVMs, 3 runs each, with 5 warmup and 15 timed tasks per
run. The figures are the median time per executePlan call:
| rows/batch | before | after | Δ |
|------------|-----------|-----------|-------|
| 1 | 4,992 ns | 4,962 ns | −0.6% |
| 64 | 5,169 ns | 5,265 ns | +1.9% |
| 1024 | 8,032 ns | 8,023 ns | −0.1% |
| 8192 | 26,801 ns | 26,793 ns | −0.0% |
Repeated runs of the same build varied by ~50–200 ns, so every difference
here is within noise. The extra Pending costs one poll of project → scan that
returns immediately, a waker allocation and a block_in_place. That is small
next to the JNI round trip and the Arrow FFI import done on every batch anyway.
This is one machine (Apple Silicon, JDK 17), so I'm happy to run it elsewhere
if you'd like more data.
--
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]