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-11411-7fc78ca9ecf907de396119a25bc689527f0fd0ea in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 9c07b17255ee65a70c1885368c1d91ca737521de Author: Artem Osipov <[email protected]> AuthorDate: Thu Oct 8 13:54:22 2026 +0000 [Variant] Benchmark json_to_variant on representative JSON batches (#11411) ## Which issue does this PR relate to? Benchmark requested during review of #11177 (related to #11169). It also provides a direct kernel baseline for #11409. ## What changes are included? Extend the existing `parquet-variant-compute` Criterion benchmark for `json_to_variant` with six incremental JSON shapes: Int32, fixed-point decimals, escaped strings, a 1,024-element array, an 8 KiB string, and a 100 KiB duplicate-key object. Existing short-string and nested-structure cases remain unchanged. Each input is prebuilt outside the timed loop into up to 8,000 rows and approximately 1 MiB of JSON. The new cases use the existing `bench_function` naming convention and report bytes per document plus row count in their IDs. No separate serde/builder measurements, library behavior, or public API changes. ## Validation - `cargo +1.95.0 bench -p parquet-variant-compute --bench variant_kernels --offline -- "batch_json_string_to_variant (int32|fixed_point_decimals|escaped_strings|large_array_1024|large_string_8k|duplicate_key_100k)" --quick` (all six new cases ran) - `cargo +1.99.0 clippy -p parquet-variant-compute --bench variant_kernels --offline -- -D warnings` - `cargo +1.95.0 fmt --all -- --check` - Independent read-only review: approved, no blocking findings. --- parquet-variant-compute/benches/variant_kernels.rs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/parquet-variant-compute/benches/variant_kernels.rs b/parquet-variant-compute/benches/variant_kernels.rs index 95bd73e766..c1b5e6fda6 100644 --- a/parquet-variant-compute/benches/variant_kernels.rs +++ b/parquet-variant-compute/benches/variant_kernels.rs @@ -164,6 +164,42 @@ fn benchmark_batch_json_string_to_variant(c: &mut Criterion) { let _ = json_to_variant(&array_ref).unwrap(); }); }); + + let large_array = format!( + "[{}]", + (0..1024) + .map(|number| number.to_string()) + .collect::<Vec<_>>() + .join(",") + ); + let large_string = format!(r#"{{"payload":"{}","id":42}}"#, "x".repeat(8192)); + let duplicate_large = format!(r#"{{"a":"{}","a":0}}"#, "x".repeat(100_000)); + for (name, json) in [ + ("int32", r#"{"id":123456789}"#), + ( + "fixed_point_decimals", + r#"{"small":1.23,"medium":999999999.0,"large":0.9999999999999999999}"#, + ), + ( + "escaped_strings", + r#"{"line":"one\ntwo","quote":"\"value\"","unicode":"\u2764"}"#, + ), + ("large_array_1024", large_array.as_str()), + ("large_string_8k", large_string.as_str()), + ("duplicate_key_100k", duplicate_large.as_str()), + ] { + let rows = (1_048_576 / json.len()).clamp(1, 8_000); + let array_ref: ArrayRef = Arc::new(StringArray::from_iter_values(std::iter::repeat_n( + json, rows, + ))); + let id = format!( + "batch_json_string_to_variant {name} ({} bytes per document, {rows} rows)", + json.len() + ); + c.bench_function(&id, |b| { + b.iter(|| std::hint::black_box(json_to_variant(&array_ref).unwrap())); + }); + } } pub fn variant_get_bench(c: &mut Criterion) {
