cakeni opened a new pull request, #11538: URL: https://github.com/apache/arrow-rs/pull/11538
# Which issue does this PR close? Closes #7960. # Rationale for this change Finishing each Variant object allocates a temporary header buffer and splices it into the value buffer. Writing the header directly into its final location removes that allocation and the splice iterator. # What changes are included in this PR? Grow the existing value buffer, move this object's payload with `copy_within`, and write its header into the resulting slice. Field ordering, encoded offsets, nested builder rollback, and the wire format are preserved. The implementation uses safe standard-library operations. # Are these changes tested? A regression test covers nested objects with earlier and later siblings, empty objects, the 255/256 field-count and payload-size boundaries, wider field IDs, and three-byte offsets. Existing builder and interoperability tests exercise the encoded format. The existing `variant_builder` benchmarks were run in before/after/after/before order on Windows x64 with Rust 1.99.0, 30 samples, 1 s warm-up, and 3 s measurement. Mean times: | Benchmark | Before A → after A | Before B → after B | | --- | --- | --- | | Objects with the same schema | 36.642 → 36.190 ms (1.2% lower) | 37.704 → 36.181 ms (4.0% lower) | | List of same-schema objects | 25.544 → 24.215 ms (5.2% lower) | 25.704 → 23.989 ms (6.7% lower) | | 128 fields, validation disabled | 21.587 → 20.641 µs (4.4% lower) | 21.789 → 20.809 µs (4.5% lower) | | 128 fields, validation enabled | 21.325 → 20.615 µs (3.3% lower) | 21.470 → 20.931 µs (2.5% lower) | The runs were made after local test and lint builds finished. These are local desktop measurements, not a general speedup claim. # Are there any significant user-facing changes? No public API or encoded-format changes. -- 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]
