Skip to content

bench(variant): add VariantPath parsing benchmark - #11508

Merged
sdf-jkl merged 1 commit into
apache:mainfrom
DKER2:bench/variant-path-parse
Oct 16, 2026
Merged

sdf-jkl merged 1 commit into
apache:mainfrom
DKER2:bench/variant-path-parse

Conversation

@DKER2

@DKER2 DKER2 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#11232 changes how VariantPath strings are parsed, and there is currently no benchmark covering path parsing. As requested in #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

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]>
@github-actions github-actions Bot added the parquet-variant parquet-variant* crates label Oct 11, 2026
DKER2 added a commit to DKER2/arrow-rs that referenced this pull request Oct 11, 2026
Moved to a separate PR (apache#11508) so the benchmark lands on main first.

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

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

Thank you @DKER2 🙏

@sdf-jkl
sdf-jkl added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 15, 2026
@sdf-jkl
sdf-jkl added this pull request to the merge queue Oct 16, 2026
Merged via the queue into apache:main with commit 069345b Oct 16, 2026
25 checks passed
@Jefffrey Jefffrey added the development-process Internal changes; PRs with this label are excluded from changelog label Oct 17, 2026
codewarnab pushed a commit to codewarnab/arrow-rs that referenced this pull request Oct 27, 2026
# Which issue does this PR close?

- Closes apache#9493.

# 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 apache#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 apache#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 apache#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 apache#11231 after
merging `main`. I reviewed the resulting code and behavior and can own
and debug the change.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Kosta Tarasov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

development-process Internal changes; PRs with this label are excluded from changelog parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants