This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-11508-fedfd0dbb888d963e0cbb524430abc5ba73876b4 in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit ace8a3e81b5e8132e3c25a97b94af3f0d751fb0c Author: Bryan Dang <[email protected]> AuthorDate: Thu Oct 15 20:17:05 2026 +0000 bench(variant): add `VariantPath` parsing benchmark (#11508) # Which issue does this PR close? - Part of #9493. # Rationale for this change #11232 changes how `VariantPath` strings are parsed, and there is currently no benchmark covering path parsing. As requested in https://github.com/apache/arrow-rs/pull/11232#issuecomment-5879196321, 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]> --- parquet-variant/Cargo.toml | 4 +++ parquet-variant/benches/variant_path.rs | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/parquet-variant/Cargo.toml b/parquet-variant/Cargo.toml index dba33c7213..46d552a591 100644 --- a/parquet-variant/Cargo.toml +++ b/parquet-variant/Cargo.toml @@ -65,5 +65,9 @@ harness = false name = "variant_validation" harness = false +[[bench]] +name = "variant_path" +harness = false + [lints] workspace = true diff --git a/parquet-variant/benches/variant_path.rs b/parquet-variant/benches/variant_path.rs new file mode 100644 index 0000000000..97065595f5 --- /dev/null +++ b/parquet-variant/benches/variant_path.rs @@ -0,0 +1,43 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use criterion::*; + +use parquet_variant::VariantPath; + +fn bench_parse_path(c: &mut Criterion) { + let mut group = c.benchmark_group("variant_path_parse"); + for (name, path) in [ + // Dot notation never enters the bracket parser + ("dot_fields", "foo.bar.baz"), + ("bracket_quoted_fields", "['foo']['bar']['baz']"), + ("bracket_indexes", "[0][1][2]"), + ("bracket_wildcards", "[*][*][*]"), + // Escapes require building an unescaped copy of the field name + ("bracket_escaped_field", r"['escaped\]field']"), + ("mixed", "a['b.c'].d[2]['3']"), + ] { + group.bench_function(name, |b| { + b.iter(|| VariantPath::try_from(std::hint::black_box(path)).unwrap()); + }); + } + group.finish(); +} + +criterion_group!(benches, bench_parse_path); + +criterion_main!(benches);
