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
{{ message }}
Repository navigation
Commit 8877579
Browse filesBrowse the repository at this point in the historyBrowse files
perf(pyo3): avoid runtime entry for buffered fetch and drained close (#477)
Python result fetching enters Tokio and releases/reacquires the GIL even
when a batch is already buffered.
**Before:** Every `fetch_next_batch()` call enters the runtime,
including buffered data and EOF. Closing a drained executed handle
enters it again after exhaustion has already finalized telemetry and
scheduled cleanup.
**After:** Both Python result handles probe for an available batch
first. Buffered data and EOF return directly. Pending reads retain the
wait with the GIL released; drained close retains runtime release and
skips the completed kernel close operation.
CloudFetch uses nonblocking buffer, shard and error-lock attempts,
returning `Pending` on contention. The waiting path skips empty chunks,
and both paths deliver earlier chunks before a later link-fetch error.
Shared guards are released before logging, including for uncached
loggers that can acquire the GIL before filtering. Batch order,
accounting, terminal errors and statement DELETE cleanup are preserved.
Unsupported formats retain `InvalidArgument` across Python fetch/drain
paths, matching Node.
One buffered batch, EOF and drained close avoid three runtime entries
and GIL release/reacquire pairs while the session remains open and
provider locks are available. Isolated end-to-end throughput gain is
unmeasured. Buffered batches requiring column rewrites perform that
synchronous work with the GIL held.
**Validation**
- Kernel: 1,323 Rust tests passed; 64 live/optional cases ignored. PyO3:
31 Rust tests passed. Formatting and clippy pass with warnings denied.
- Rebuilt CPython 3.12 extension: 21 offline Python tests passed; 37
live cases skipped. Coverage includes both result handles, delayed
inline/CloudFetch continuation, empty chunks, errors, EOF cleanup before
handle closure, partial cleanup and final runtime release.
- Bounded lock-contention tests verify `Pending`, ordered recovery and
accounting. Binding tests verify runtime bypass and that waiting
releases the GIL; restoring unconditional runtime entry in either real
handle fails its guard.
- Fourteen local connector/logging checks passed, including mixed
row/Arrow reads, sync/async execution, standard/realtime routes and cold
DEBUG logging. No new warehouse workload was run.
The native binding and Python tests share one local HTTP fixture.
---------
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
0 commit comments