Skip to content

perf(variant): skip re-validating children of fully validated objects and lists - #12430

Open
sdf-jkl wants to merge 1 commit into
apache:mainfrom
sdf-jkl:variant-skip-child-revalidation
Open

sdf-jkl wants to merge 1 commit into
apache:mainfrom
sdf-jkl:variant-skip-child-revalidation

Conversation

@sdf-jkl

@sdf-jkl sdf-jkl commented Nov 24, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

VariantObject::iter_try and VariantList::iter_try call with_full_validation() on every child, and ValueBuilder::try_append_variant then recurses into each child object or list and calls iter_try again. A value nested d levels deep is fully validated about d times. With #11106, unshred_variant takes this path for fallback values, even though it has already fully validated each value with Variant::try_new_with_metadata.

Full validation of an object or list recursively validates all of its children, so every child of a validated value is already valid. The accessors build each child with only shallow checks, so the child loses that fact and gets validated again. This is the same problem #10879 fixed for metadata dictionary entries.

What changes are included in this PR?

VariantObject and VariantList mark a child as fully validated when they build it from a fully validated parent. with_full_validation on such a child returns immediately, so iter_try, try_field and try_get no longer re-validate subtrees. Children of unvalidated parents are built and validated as before.

This conflicts with #12309 from @cetra3, which rewrites the code that builds child values. The resolution adds the same one-line call where #12309 builds children, and I am happy to do it in whichever PR lands second.

Are these changes tested?

test_children_inherit_full_validation checks that the fields and list elements of a validated value report is_fully_validated(), and that those of an unvalidated value do not. It fails if either the object or the list half of the change is removed.

unshred_variant_nested_fallback from variant_kernels (local x86, codegen-units=1):

time
before #11106 89.7 ms
#11106 159.8 ms
#11106 and this PR 87.1 ms

Removing the with_full_validation() calls from both iter_try implementations entirely gives about the same time (88.8 ms), so the re-validation accounts for the whole regression.

Are there any significant user-facing changes?

Children returned by the accessors of a fully validated VariantObject or VariantList (field, get, iter and their fallible versions) now report is_fully_validated() == true. They reported false before, although they were valid. No public API changes.

AI usage disclosure

Claude Code helped find the cause, write the change and test, and run the benchmarks. I reviewed the change and the measurements.

🤖 Generated with Claude Code

… and lists

Full validation of an object or list validates all of its children, but
the accessors built each child with only shallow checks, so `iter_try`,
`try_field` and `try_get` validated it again. Nested values were
validated once per nesting level. Children of a fully validated parent
are now marked validated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boring-cyborg boring-cyborg Bot added the parquet-variant parquet-variant* crates label Nov 24, 2026
@sdf-jkl
sdf-jkl marked this pull request as ready for review November 24, 2026 00:12
@sdf-jkl

sdf-jkl commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

run benchmark variant_kernels
env:
BENCH_FILTER: "unshred_variant"
baseline:
ref: 0265766
changed:
ref: 1cc5154

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: variant_kernels

Sharding factor: 1 (1 workers).

Comparing 1cc5154 (1cc5154) to 0265766 diff

Run configuration
run benchmark variant_kernels
baseline:
  ref: 0265766e6318b2403b264827c87558cca5a00f35
changed:
  ref: 1cc51548c93339139fd5158c31b7b99c94fef23f
env:
  BENCH_FILTER: unshred_variant
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_kernels

Comparing 1cc5154 (1cc5154) to 0265766 diff

Run configuration
run benchmark variant_kernels
baseline:
  ref: 0265766e6318b2403b264827c87558cca5a00f35
changed:
  ref: 1cc51548c93339139fd5158c31b7b99c94fef23f
env:
  BENCH_FILTER: unshred_variant
shards: 1
Details
group                                               base                                   changed
-----                                               ----                                   -------
unshred_variant_list                                1.00     10.0±0.04ms        ? ?/sec    1.00     10.0±0.04ms        ? ?/sec
unshred_variant_list_of_objects                     1.01     22.7±0.33ms        ? ?/sec    1.00     22.5±0.10ms        ? ?/sec
unshred_variant_nested_fallback                     1.76    281.0±1.81ms        ? ?/sec    1.00    159.7±0.67ms        ? ?/sec
unshred_variant_object                              1.00      5.4±0.04ms        ? ?/sec    1.02      5.5±0.05ms        ? ?/sec
unshred_variant_partial_object                      1.00     44.4±0.16ms        ? ?/sec    1.01     44.7±0.55ms        ? ?/sec
unshred_variant_partial_object_unsorted_metadata    1.00    197.9±2.11ms        ? ?/sec    1.00    198.0±2.17ms        ? ?/sec
unshred_variant_primitive                           1.00    424.2±7.56µs        ? ?/sec    1.00    425.2±3.45µs        ? ?/sec

Per-runner information
variant_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-2sxr124t-a09394a8-p7bf

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

uname:

Linux bench-c7117851205-5668-6zmzm 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_kernels
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 125.0s
Peak memory 379.4 MiB
Avg memory 56.1 MiB
CPU user 120.8s
CPU sys 0.2s
Peak spill 0 B

branch

Metric Value
Wall time 110.0s
Peak memory 428.9 MiB
Avg memory 55.1 MiB
CPU user 106.0s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

This branch has not been deployed

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

Labels

parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants