Skip to content

perf(parquet): slice up contiguous buffer for decimals and fsb#10364

Open
MassivePizza wants to merge 8 commits into
apache:mainfrom
massive-com:parquet-contiguous-decimal
Open

perf(parquet): slice up contiguous buffer for decimals and fsb#10364
MassivePizza wants to merge 8 commits into
apache:mainfrom
massive-com:parquet-contiguous-decimal

Conversation

@MassivePizza

@MassivePizza MassivePizza commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

N/A

Rationale for this change

Converting decimals and FixedLenByteArrays to individual allocs requires a lot of alloc+drop time and memory overhead.

What changes are included in this PR?

Allocate one big buffer, and cut it up into slices of bytes::Bytes. This amortizes the alloc upfront, and effectively eliminates the drop overhead by turning a dealloc to an Arc decrement per slice.

This still has moderate memory overhead. Bytes is 32 bytes, while the slices usually expose less than 16 bytes at a time e.g. UUIDs or decimal128, but a lot more effort would be required to implement a (perhaps borrowed?) alternative that behaves like FixedLenByteArray.

There are a few other ideas worth exploring, primarily custom ColumnValueEncoders that converts on the fly to avoid the temporary allocs all together.

There is also a small outlining+inlining in compare_greater to help out in the get_min_max loop. Extracted to #10389.

Are these changes tested?

Should be covered by existing tests. There are also new benches included (extracted to #10388):

decimal bench
Benchmarking decimal/default: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 5.4s, or reduce sample count to 90.
decimal/default         time:   [53.676 ms 53.979 ms 54.306 ms]
                        thrpt:  [1.0790 GiB/s 1.0855 GiB/s 1.0916 GiB/s]
                 change:
                        time:   [−44.611% −44.247% −43.885%] (p = 0.00 < 0.05)
                        thrpt:  [+78.204% +79.362% +80.542%]
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe
Benchmarking decimal/bloom_filter: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 6.8s, or reduce sample count to 70.
decimal/bloom_filter    time:   [66.597 ms 66.838 ms 67.095 ms]
                        thrpt:  [894.26 MiB/s 897.70 MiB/s 900.94 MiB/s]
                 change:
                        time:   [−40.229% −39.907% −39.555%] (p = 0.00 < 0.05)
                        thrpt:  [+65.440% +66.408% +67.306%]
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  8 (8.00%) high mild
  2 (2.00%) high severe
Benchmarking decimal/parquet_2: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 10.8s, or reduce sample count to 40.
decimal/parquet_2       time:   [105.82 ms 106.23 ms 106.66 ms]
                        thrpt:  [562.52 MiB/s 564.84 MiB/s 567.02 MiB/s]
                 change:
                        time:   [−48.804% −48.523% −48.229%] (p = 0.00 < 0.05)
                        thrpt:  [+93.160% +94.263% +95.329%]
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
Benchmarking decimal/zstd: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 6.4s, or reduce sample count to 70.
decimal/zstd            time:   [61.806 ms 62.013 ms 62.282 ms]
                        thrpt:  [963.36 MiB/s 967.55 MiB/s 970.78 MiB/s]
                 change:
                        time:   [−60.257% −59.907% −59.556%] (p = 0.00 < 0.05)
                        thrpt:  [+147.25% +149.42% +151.62%]
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  1 (1.00%) low severe
  2 (2.00%) low mild
  5 (5.00%) high mild
  3 (3.00%) high severe
Benchmarking decimal/zstd_parquet_2: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 11.9s, or reduce sample count to 40.
decimal/zstd_parquet_2  time:   [119.51 ms 119.87 ms 120.29 ms]
                        thrpt:  [498.82 MiB/s 500.54 MiB/s 502.07 MiB/s]
                 change:
                        time:   [−55.716% −55.352% −54.992%] (p = 0.00 < 0.05)
                        thrpt:  [+122.18% +123.98% +125.82%]
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  2 (2.00%) low mild
  2 (2.00%) high mild
  7 (7.00%) high severe
Benchmarking decimal/cdc: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.8s, or reduce sample count to 60.
decimal/cdc             time:   [77.810 ms 78.092 ms 78.389 ms]
                        thrpt:  [765.42 MiB/s 768.33 MiB/s 771.11 MiB/s]
                 change:
                        time:   [−35.689% −35.360% −35.011%] (p = 0.00 < 0.05)
                        thrpt:  [+53.873% +54.703% +55.494%]
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  10 (10.00%) high mild
fsb bench
fsb/default             time:   [5.4152 ms 5.4276 ms 5.4407 ms]
                        thrpt:  [2.8943 GiB/s 2.9013 GiB/s 2.9079 GiB/s]
                 change:
                        time:   [−27.824% −27.512% −27.215%] (p = 0.00 < 0.05)
                        thrpt:  [+37.391% +37.953% +38.550%]
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  1 (1.00%) low mild
  5 (5.00%) high mild
  1 (1.00%) high severe
fsb/bloom_filter        time:   [5.8681 ms 5.8908 ms 5.9154 ms]
                        thrpt:  [2.6621 GiB/s 2.6732 GiB/s 2.6835 GiB/s]
                 change:
                        time:   [−25.701% −25.298% −24.896%] (p = 0.00 < 0.05)
                        thrpt:  [+33.148% +33.866% +34.592%]
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  3 (3.00%) high mild
  3 (3.00%) high severe
fsb/parquet_2           time:   [8.6936 ms 8.7692 ms 8.8503 ms]
                        thrpt:  [1.7793 GiB/s 1.7957 GiB/s 1.8113 GiB/s]
                 change:
                        time:   [−31.621% −31.005% −30.286%] (p = 0.00 < 0.05)
                        thrpt:  [+43.444% +44.939% +46.243%]
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  9 (9.00%) high mild
  1 (1.00%) high severe
fsb/zstd                time:   [7.1760 ms 7.2043 ms 7.2360 ms]
                        thrpt:  [2.1762 GiB/s 2.1858 GiB/s 2.1944 GiB/s]
                 change:
                        time:   [−21.480% −21.068% −20.631%] (p = 0.00 < 0.05)
                        thrpt:  [+25.994% +26.692% +27.356%]
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe
fsb/zstd_parquet_2      time:   [9.2977 ms 9.4085 ms 9.5422 ms]
                        thrpt:  [1.6503 GiB/s 1.6737 GiB/s 1.6937 GiB/s]
                 change:
                        time:   [−30.266% −29.333% −28.383%] (p = 0.00 < 0.05)
                        thrpt:  [+39.632% +41.508% +43.401%]
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  4 (4.00%) high mild
  3 (3.00%) high severe
fsb/cdc                 time:   [7.9524 ms 7.9700 ms 7.9878 ms]
                        thrpt:  [1.9714 GiB/s 1.9758 GiB/s 1.9802 GiB/s]
                 change:
                        time:   [−21.280% −20.793% −20.375%] (p = 0.00 < 0.05)
                        thrpt:  [+25.589% +26.251% +27.033%]
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mildaa

Are there any user-facing changes?

No.

@github-actions github-actions Bot added parquet Changes to the parquet crate arrow Changes to the arrow crate labels Jul 17, 2026
Comment thread parquet/src/column/writer/mod.rs Outdated
Comment thread parquet/benches/arrow_writer.rs
Comment thread parquet/src/arrow/arrow_writer/mod.rs Outdated
@MassivePizza
MassivePizza force-pushed the parquet-contiguous-decimal branch from 50edfd3 to f62743e Compare July 20, 2026 13:43
@github-actions github-actions Bot removed the arrow Changes to the arrow crate label Jul 20, 2026
@MassivePizza
MassivePizza marked this pull request as draft July 20, 2026 16:06
This allows optimizations since iterators uphold invariants.
Revert this when MSRV is bumped to at least 1.93.
alamb pushed a commit that referenced this pull request Jul 20, 2026
# Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->

- Related to
#10364 (review).

# Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

# What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

# Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?

If this PR claims a performance improvement, please include evidence
such as benchmark results.
-->

# Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.

If there are any breaking changes to public APIs, please call them out.
-->
@MassivePizza
MassivePizza marked this pull request as ready for review July 22, 2026 16:01
@etseidl

etseidl commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

run benchmark arrow_writer

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5048483940-1227-vfmcg 6.12.85+ #1 SMP Mon May 11 08:17:35 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing parquet-contiguous-decimal (0495502) to cd17899 (merge-base) diff
BENCH_NAME=arrow_writer
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_writer
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants