Skip to content

perf(variant): avoid bracket path string allocations - #11232

Merged
sdf-jkl merged 14 commits into
apache:mainfrom
DKER2:perf/variant-path-lazy-bracket-allocation
Oct 27, 2026
Merged

sdf-jkl merged 14 commits into
apache:mainfrom
DKER2:perf/variant-path-lazy-bracket-allocation

Conversation

@DKER2

@DKER2 DKER2 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

parse_in_bracket currently allocates a String for every bracket expression, including indexes, wildcards, and quoted fields that require no unescaping. VariantPathElement::Field already stores Cow<str>, so unescaped field names can borrow directly from the input path.

What changes are included in this PR?

  • Defer creation of the unescaped String until the first backslash is encountered.
  • Borrow the original bracket-content slice when no escape processing is required.
  • Preserve ownership for escaped fields and strip their surrounding quotes in place.
  • Add tests proving unescaped bracket fields use Cow::Borrowed while escaped fields use Cow::Owned.

This branch includes main with #11231 (closing brackets inside quoted fields). The quote tracking added there relied on the eagerly built buffer, so it is adapted here: an opening quote is now detected by its offset in the bracket content rather than by the buffer being empty, and quoted fields containing ] (e.g. ['a]b']) still borrow.

Are these changes tested?

Yes. The existing path parsing tests cover behavior, and a new test asserts the ownership of each case: empty, plain, and ]-containing quoted fields are borrowed, and an escaped field is owned.

The benchmark for this change is in #11508 (cargo bench -p parquet-variant --bench variant_path), split out as requested so it is available on main as a baseline. I will merge main here once it lands so the numbers can be reproduced.

Earlier local measurements, taken with a temporary Criterion harness on aarch64 macOS before #11231 was merged in:

Case Before After Change
Three quoted bracket fields 300.22 ns 54.10 ns -81.7%
Three bracket indexes 146.13 ns 45.57 ns -68.2%
Escaped bracket field 140.41 ns 111.37 ns -24.9%
Dot-path control 38.68 ns 40.88 ns Within noise

Are there any user-facing changes?

No semantic or public API changes. Parsed paths remain the same; unescaped bracket fields now borrow their names instead of allocating owned strings.

AI usage

OpenAI Codex was used to inspect the parser, help implement the lazy allocation path, construct ownership tests, and run validation and benchmarks. Claude Code was used to adapt the change to #11231 after merging main. I reviewed the resulting code and behavior and can own and debug the change.

@github-actions github-actions Bot added the parquet-variant parquet-variant* crates label Sep 27, 2026
@DKER2 DKER2 closed this Sep 27, 2026
@DKER2 DKER2 reopened this Sep 27, 2026
@sdf-jkl

sdf-jkl commented Sep 28, 2026

Copy link
Copy Markdown
Member

Thanks @DKER2, could you add a separate PR with the bench you used to measure the perf? I'd like to have it before we proceed here.

DKER2 and others added 3 commits October 11, 2026 13:05
Covers dot notation, bracket fields, indexes, wildcards and escaped
bracket fields so changes to the path parser can be measured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DKER2

DKER2 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

run benchmark variant_path

@adriangbot

Copy link
Copy Markdown

Moved to a separate PR (apache#11508) so the benchmark lands on main first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DKER2

DKER2 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@sdf-jkl here's the benchmark you asked for in #11232.

sdf-jkl pushed a commit to DKER2/arrow-rs that referenced this pull request Oct 16, 2026
# Which issue does this PR close?

- Part of apache#9493.

# Rationale for this change

apache#11232 changes how `VariantPath` strings are parsed, and there is
currently no benchmark covering path parsing. As requested in
apache#11232 (comment),
this adds the benchmark on its own so it is available on `main` as a
baseline before that PR proceeds.

# What changes are included in this PR?

A new Criterion target, `variant_path`, in `parquet-variant`. It parses
six path strings with `VariantPath::try_from`:

| Case | Path |
|---|---|
| `dot_fields` | `foo.bar.baz` |
| `bracket_quoted_fields` | `['foo']['bar']['baz']` |
| `bracket_indexes` | `[0][1][2]` |
| `bracket_wildcards` | `[*][*][*]` |
| `bracket_escaped_field` | `['escaped\]field']` |
| `mixed` | `a['b.c'].d[2]['3']` |

Run with `cargo bench -p parquet-variant --bench variant_path`.

For reference, results on `main` (aarch64 macOS):

| Case | Time |
|---|---:|
| `dot_fields` | 30.6 ns |
| `bracket_quoted_fields` | 259 ns |
| `bracket_indexes` | 140 ns |
| `bracket_wildcards` | 137 ns |
| `bracket_escaped_field` | 144 ns |
| `mixed` | 293 ns |

# Are these changes tested?

This PR only adds a benchmark; no library code changes.

# Are there any significant user-facing changes?

No.

# AI usage

Claude Code was used to write the benchmark and run it. I reviewed the
result and can own and debug the change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@sdf-jkl

sdf-jkl commented Oct 16, 2026

Copy link
Copy Markdown
Member

run benchmark variant_path

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_path

Sharding factor: 1 (1 workers).

Comparing perf/variant-path-lazy-bracket-allocation (371aeb4) to 8f4bb0c (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: variant_path

Comparing perf/variant-path-lazy-bracket-allocation (371aeb4) to 8f4bb0c (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1
Details
group                                       base                                   changed
-----                                       ----                                   -------
variant_path_parse/bracket_escaped_field    1.24     87.9±2.07ns        ? ?/sec    1.00     70.7±0.69ns        ? ?/sec
variant_path_parse/bracket_indexes          2.20     86.3±0.82ns        ? ?/sec    1.00     39.3±0.32ns        ? ?/sec
variant_path_parse/bracket_quoted_fields    2.75    135.8±2.44ns        ? ?/sec    1.00     49.3±0.11ns        ? ?/sec
variant_path_parse/bracket_wildcards        2.32     82.6±1.10ns        ? ?/sec    1.00     35.6±0.28ns        ? ?/sec
variant_path_parse/dot_fields               1.00     31.0±0.10ns        ? ?/sec    1.02     31.7±0.06ns        ? ?/sec
variant_path_parse/mixed                    1.67    152.3±1.09ns        ? ?/sec    1.00     91.5±0.25ns        ? ?/sec

Per-runner information
variant_path — shard 1/1

Node: gk3-benchmark-cluster-nap-1kma86l2-48dd0048-2jmx

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

uname:

Linux bench-c6218442915-3509-cw6ww 6.12.94+ #1 SMP Fri Aug 21 08:00:16 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_path
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
Resource Usage

base (merge-base)

Metric Value
Wall time 65.0s
Peak memory 9.4 MiB
Avg memory 7.9 MiB
CPU user 61.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 60.0s
Peak memory 9.9 MiB
Avg memory 7.9 MiB
CPU user 56.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the wait @DKER2 🙏

Overall the approach looks good but we can tweak it a little.

Comment thread parquet-variant/src/path.rs Outdated
Comment on lines +331 to +351
match &path[0] {
VariantPathElement::Field {
name: Cow::Borrowed(name),
} => assert_eq!(*name, ""),
other => panic!("expected borrowed field, got {other:?}"),
}

match &path[1] {
VariantPathElement::Field {
name: Cow::Borrowed(name),
} => assert_eq!(*name, "plain"),
other => panic!("expected borrowed field, got {other:?}"),
}

match &path[2] {
VariantPathElement::Field {
name: Cow::Owned(name),
} => assert_eq!(name, "escaped]field"),
other => panic!("expected owned field, got {other:?}"),
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can move the three asserts into one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smth like these here could do:

use VariantPathElement::Field;

assert!(matches!(
    &path[..],
    [
        Field { name: Cow::Borrowed("") },
        Field { name: Cow::Borrowed("plain") },
        Field { name: Cow::Owned(escaped) },
        Field { name: Cow::Borrowed("a]b") },
    ] if escaped == "escaped]field"
));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for overlooking this one earlier @sdf-jkl - collapsed the four match blocks into a single matches! like you suggested in 8ffc6b9.

quote = None;
unescaped.push(c);
if let Some(unescaped) = &mut unescaped {
unescaped.push(c);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of pushing each char to the unescaped one by one we can count the offsets where the string starts and ends or encounters a new backslash.

It shows improvement when I prototyped locally

@DKER2 DKER2 Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that make sense for speed performance, change the implementation to count the offset instead. But the improvement is mainly on CPU utilization as we still need to introduce additional memory (which is small for int) for a cursor to tracks how far we’ve copied into unescaped.

@DKER2 DKER2 Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a case like ['abc\]xyz'] need this

@alamb alamb added the performance Speed or memory optimizations label Oct 16, 2026
@DKER2

DKER2 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks lemme take a look

DKER2 and others added 3 commits October 24, 2026 15:26
Address review feedback: instead of pushing each char into the
unescaped buffer, track where the current run of literal chars starts
and copy it with `push_str` on each escape and at the closing bracket.

Also collapse the bracket field ownership asserts into one and cover
multiple escapes between multi-byte chars.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DKER2

DKER2 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@sdf-jkl updated the implementation, can you help to run the benchmark if needed

@sdf-jkl

sdf-jkl commented Oct 26, 2026

Copy link
Copy Markdown
Member

run benchmark variant_path

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_path

Sharding factor: 1 (1 workers).

Comparing perf/variant-path-lazy-bracket-allocation (4431da4) to 9a95c6d (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: variant_path

Comparing perf/variant-path-lazy-bracket-allocation (4431da4) to 9a95c6d (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1
Details
group                                       base                                   changed
-----                                       ----                                   -------
variant_path_parse/bracket_escaped_field    1.31     89.4±3.30ns        ? ?/sec    1.00     68.1±0.14ns        ? ?/sec
variant_path_parse/bracket_indexes          2.05     86.8±1.02ns        ? ?/sec    1.00     42.3±0.22ns        ? ?/sec
variant_path_parse/bracket_quoted_fields    2.57    134.7±3.64ns        ? ?/sec    1.00     52.5±0.23ns        ? ?/sec
variant_path_parse/bracket_wildcards        2.18     82.6±1.30ns        ? ?/sec    1.00     37.9±0.28ns        ? ?/sec
variant_path_parse/dot_fields               1.02     31.8±0.30ns        ? ?/sec    1.00     31.1±0.10ns        ? ?/sec
variant_path_parse/mixed                    1.66    153.6±1.59ns        ? ?/sec    1.00     92.5±1.06ns        ? ?/sec

Per-runner information
variant_path — shard 1/1

Node: gk3-benchmark-cluster-nap-1qhpgbsz-2dfa3b45-h8h6

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

uname:

Linux bench-c6422033962-3874-kw827 6.12.105+ #1 SMP Sat Sep  5 07:54:11 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_path
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
Resource Usage

base (merge-base)

Metric Value
Wall time 65.0s
Peak memory 9.4 MiB
Avg memory 7.9 MiB
CPU user 61.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 60.0s
Peak memory 9.9 MiB
Avg memory 7.8 MiB
CPU user 56.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl

sdf-jkl commented Oct 26, 2026

Copy link
Copy Markdown
Member

run benchmark variant_path

baseline:
ref: 371aeb4
changed:
ref: 7347a4e

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_path

Sharding factor: 1 (1 workers).

Comparing 7347a4e (7347a4e) to 371aeb4 diff

Run configuration
run benchmark variant_path
baseline:
  ref: 371aeb4bcceb1306d4c5a4e0bc9211ebf01f9188
changed:
  ref: 7347a4e2927be901111c1ff827f4ef273ce4ac20
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: variant_path

Comparing 7347a4e (7347a4e) to 371aeb4 diff

Run configuration
run benchmark variant_path
baseline:
  ref: 371aeb4bcceb1306d4c5a4e0bc9211ebf01f9188
changed:
  ref: 7347a4e2927be901111c1ff827f4ef273ce4ac20
shards: 1
Details
group                                       base                                   changed
-----                                       ----                                   -------
variant_path_parse/bracket_escaped_field    1.03     69.5±3.23ns        ? ?/sec    1.00     67.4±0.20ns        ? ?/sec
variant_path_parse/bracket_indexes          1.00     42.2±4.22ns        ? ?/sec    1.00     42.1±0.24ns        ? ?/sec
variant_path_parse/bracket_quoted_fields    1.00     51.4±4.26ns        ? ?/sec    1.05     53.9±1.14ns        ? ?/sec
variant_path_parse/bracket_wildcards        1.02     38.9±4.31ns        ? ?/sec    1.00     38.2±0.26ns        ? ?/sec
variant_path_parse/dot_fields               1.00     31.2±0.11ns        ? ?/sec    1.00     31.1±0.09ns        ? ?/sec
variant_path_parse/mixed                    1.00     85.5±2.93ns        ? ?/sec    1.10     93.9±0.31ns        ? ?/sec

Per-runner information
variant_path — shard 1/1

Node: gk3-benchmark-cluster-nap-akit9iic-f7d08e37-fgpr

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

uname:

Linux bench-c6423073631-3880-d8hnf 6.12.105+ #1 SMP Sat Sep  5 07:54:11 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_path
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
Resource Usage

base (merge-base)

Metric Value
Wall time 65.0s
Peak memory 9.4 MiB
Avg memory 7.6 MiB
CPU user 59.8s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 60.0s
Peak memory 9.9 MiB
Avg memory 7.8 MiB
CPU user 56.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl

sdf-jkl commented Oct 26, 2026

Copy link
Copy Markdown
Member

Thanks @DKER2, I benchmarked both your implementation and what I tried locally and it seems that neither improve on your original implementation.

could you revert to your original impl?

DKER2 and others added 2 commits October 27, 2026 10:16
Benchmarks showed copying unescaped content in runs does not improve on
the original per-char approach. This reverts 7347a4e and 4431da4.
@DKER2

DKER2 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Hey @sdf-jkl, reverted

@sdf-jkl

sdf-jkl commented Oct 27, 2026

Copy link
Copy Markdown
Member

Run benchmark variant_path

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_path

Sharding factor: 1 (1 workers).

Comparing perf/variant-path-lazy-bracket-allocation (b8c3169) to 87b8013 (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: variant_path

Comparing perf/variant-path-lazy-bracket-allocation (b8c3169) to 87b8013 (merge-base) diff

Run configuration
run benchmark variant_path
shards: 1
Details
group                                       base                                   changed
-----                                       ----                                   -------
variant_path_parse/bracket_escaped_field    1.35     91.1±0.73ns        ? ?/sec    1.00     67.6±0.83ns        ? ?/sec
variant_path_parse/bracket_indexes          2.17     86.4±0.96ns        ? ?/sec    1.00     39.9±0.34ns        ? ?/sec
variant_path_parse/bracket_quoted_fields    2.72    134.3±2.79ns        ? ?/sec    1.00     49.3±0.24ns        ? ?/sec
variant_path_parse/bracket_wildcards        2.29     82.0±1.11ns        ? ?/sec    1.00     35.8±0.24ns        ? ?/sec
variant_path_parse/dot_fields               1.01     31.3±0.12ns        ? ?/sec    1.00     31.1±0.10ns        ? ?/sec
variant_path_parse/mixed                    1.68    152.5±1.59ns        ? ?/sec    1.00     90.9±1.05ns        ? ?/sec

Per-runner information
variant_path — shard 1/1

Node: gk3-benchmark-cluster-nap-dg6by4rp-0606c2db-t44r

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

uname:

Linux bench-c6441646898-3922-vgjrb 6.12.105+ #1 SMP Sat Sep 19 07:55:25 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_path
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
Resource Usage

base (merge-base)

Metric Value
Wall time 65.0s
Peak memory 9.4 MiB
Avg memory 7.4 MiB
CPU user 58.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 60.0s
Peak memory 9.9 MiB
Avg memory 7.7 MiB
CPU user 55.1s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DKER2 LGTM!

Could you please add a quick test simplification?

Comment thread parquet-variant/src/path.rs Outdated
Comment on lines +331 to +351
match &path[0] {
VariantPathElement::Field {
name: Cow::Borrowed(name),
} => assert_eq!(*name, ""),
other => panic!("expected borrowed field, got {other:?}"),
}

match &path[1] {
VariantPathElement::Field {
name: Cow::Borrowed(name),
} => assert_eq!(*name, "plain"),
other => panic!("expected borrowed field, got {other:?}"),
}

match &path[2] {
VariantPathElement::Field {
name: Cow::Owned(name),
} => assert_eq!(name, "escaped]field"),
other => panic!("expected owned field, got {other:?}"),
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smth like these here could do:

use VariantPathElement::Field;

assert!(matches!(
    &path[..],
    [
        Field { name: Cow::Borrowed("") },
        Field { name: Cow::Borrowed("plain") },
        Field { name: Cow::Owned(escaped) },
        Field { name: Cow::Borrowed("a]b") },
    ] if escaped == "escaped]field"
));

@DKER2

DKER2 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for overlooking this one earlier @sdf-jkl - collapsed the four match blocks into a single matches!

@sdf-jkl
sdf-jkl added this pull request to the merge queue Oct 27, 2026
Merged via the queue into apache:main with commit dc59495 Oct 27, 2026
21 checks passed
@sdf-jkl

sdf-jkl commented Oct 27, 2026

Copy link
Copy Markdown
Member

Thanks for bearing with me @DKER2 🎉

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

Labels

parquet-variant parquet-variant* crates performance Speed or memory optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] Optimize parse_in_bracket to avoid unnecessary String allocations

4 participants