zhengruifeng opened a new pull request, #513:
URL: https://github.com/apache/spark-connect-rust/pull/513

   ## What changed
   
   JIRA: https://issues.apache.org/jira/browse/SPARK-61452
   
   - Cache the Python `datetime` classes and immutable UTC/naive epoch objects 
used when collected Spark values are materialized.
   - Cache `decimal.Decimal` for collected decimal values.
   - Reuse the cached objects through `PyOnceLock` instead of importing modules 
and resolving attributes for every field.
   
   ## Performance
   
   Release-mode microbenchmark of the actual `row::value_to_py` path on x86_64 
with Python 3.13.12. Each result is the median of 200,000 conversions over 7-9 
rounds; the comparison was repeated in two fresh Python processes.
   
   | Value type | Before | After | Speedup | Time reduction |
   | --- | ---: | ---: | ---: | ---: |
   | Date | 526-545 ns/value | 195-196 ns/value | 2.68-2.79x | 62.8-64.2% |
   | Decimal | 541-550 ns/value | 195-198 ns/value | 2.78x | 64.0-64.1% |
   | Day-time interval | 644-650 ns/value | 295-296 ns/value | 2.18-2.21x | 
54.1-54.6% |
   | Timestamp | 3,479-3,583 ns/value | 1,965-1,994 ns/value | 1.77-1.80x | 
43.5-44.4% |
   | Timestamp NTZ | 1,252-1,390 ns/value | 444-462 ns/value | 2.82-3.01x | 
64.5-66.8% |
   
   This isolates Python scalar materialization. End-to-end `collect()` also 
includes RPC, Arrow decoding, and row construction, so its overall percentage 
improvement depends on the returned schema and workload.
   
   ## Tests
   
   - `cargo build -p pyspark-rs --release --locked`
   - `cargo fmt --all --check`
   - `cargo test -p apache-spark-connect --release --lib`
   - `cargo test -p apache-spark-connect --release --no-run`
   - `cargo test -p apache-spark-connect --release --features wasm-udf --no-run`
   - Offline Python suite: 3,116 passed, 8 skipped, 14 subtests passed
   
   This pull request and its description were written by Isaac.
   


-- 
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