Repository navigation
Conversation
a1fa295 to
4d0fdfd
Compare
|
run benchmark variant_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: variant_kernels Sharding factor: 1 (1 workers). Comparing variant-views-4-shred (4d0fdfd) to 093ef04 (merge-base) diff Run configurationrun benchmark variant_kernels
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
alamb
left a comment
There was a problem hiding this comment.
Looks good an dmakes sense to me -- thank yoU @cetra3
Note that I think we could apply a similar optimization (copy the original bytes rather than decode/reencode in some other places too (maybe as a follow on PR)
arrow-rs/parquet-variant-compute/src/unshred_variant.rs
Lines 333 to 349 in 4d0fdfd
And
arrow-rs/parquet-variant-compute/src/unshred_variant.rs
Lines 366 to 387 in 4d0fdfd
| .. | ||
| } = self; | ||
| seen.fill(false); | ||
| let object = obj.view(); |
There was a problem hiding this comment.
It is somewhat confusing that there is both obj (the view) and object in this sciopt
it might be easier to read either to redefine obj or use obj_view or something more distinguishing
| /// The caller must ensure that `field_id`, and every field id inside `value`, belong to the | ||
| /// metadata dictionary that this builder writes against. Copying a field out of an object that | ||
| /// uses that same dictionary, as shredding does, satisfies this. |
There was a problem hiding this comment.
| /// The caller must ensure that `field_id`, and every field id inside `value`, belong to the | |
| /// metadata dictionary that this builder writes against. Copying a field out of an object that | |
| /// uses that same dictionary, as shredding does, satisfies this. | |
| /// The caller must ensure that `field_id`, and every field id inside `value`, belong to the | |
| /// builder's metadata dictionary. For example, during shredding, when copying fields to the | |
| /// output (residual) variant that are not shredded |
| ))); | ||
| } | ||
| object_builder.insert_bytes(field_name, field_value); | ||
| object_builder.insert_encoded(object.field_id(i)?, object.field(i)?.bytes()?)?; |
There was a problem hiding this comment.
I think this is one key optimization -- just copy the original variant bytes rather than re-walking/re-encoding a parsed one 👍
| Variant::try_new_with_metadata_and_shallow_validation(metadata, self.value) | ||
| } | ||
|
|
||
| /// The exact encoding of this value, without any bytes that follow it. |
There was a problem hiding this comment.
the "without any bytes that follow it" is somewhat strange phrasing to me
It might be clearer if it just says "returns just the bytes that encode this variant value"
|
🤖 Benchmark completed (GKE) | trigger Target: variant_kernels Comparing variant-views-4-shred (4d0fdfd) to 093ef04 (merge-base) diff Run configurationrun benchmark variant_kernels
shards: 1
DetailsPer-runner informationvariant_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-fytca8go-9faf2da9-wvqf Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench variant_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
Add `VariantView`, `VariantMetadataView`, `VariantObjectView` and `VariantListView`. Building a view reads one header. Each accessor reads and bounds-checks only the bytes it needs, and compares field names as bytes. `VariantMetadata`, `VariantObject` and `VariantList` are now built by promoting a view, and their accessors delegate to it. `ObjectBuilder::finish` sorts fields with the new `MetadataBuilder::cmp_field_names`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`try_binary_search_range_by` now returns the comparison's error and `None` when nothing matches, and replaces `try_binary_search`. The view types read the header fields through accessors, so the fields stay private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4d0fdfd to
d32659d
Compare
`VariantView::to_variant`, `VariantMetadataView::into_metadata`, `VariantObjectView::into_object` and `VariantListView::into_list` can fail, so they become `try_to_variant`, `try_into_metadata`, `try_into_object` and `try_into_list`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`variant_get` reads each row of an unshredded column through `VariantView::get_path`. A row reads only the headers and field names along the path, and decodes only the value that it finds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`shred_variant` and `unshred_variant` copy each leftover object field by its field id and encoded bytes, through the new `ObjectBuilder::insert_encoded` and `VariantView::bytes`. A leftover field is no longer decoded into a `Variant` and encoded again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
d32659d to
76ad2d5
Compare
Which issue does this PR close?
This PR is stacked on #12309 and #12310. Its own change is the commit "perf(variant): copy leftover object fields by field id when shredding". It is a draft until they merge.
Rationale for this change
When
shred_variantandunshred_variantcopy an object field that is not shredded, they decode it into aVariant, look its name up in the metadata dictionary to get the field id back, and encode the value again. The output uses the same metadata dictionary as the input, so the field id and the encoded bytes are already correct.What changes are included in this PR?
ObjectBuilder::insert_encodedadds a field by its field id and its encoded bytes.VariantView::bytesreturns the exact encoding of a value.shred_variantandunshred_variantcopy leftover object fields through them. They match field names as bytes against a sorted list of the shredded field names.Are these changes tested?
The existing shredding tests cover the changed code.
VariantView::byteshas tests for every primitive type, and for the fields of an object and the elements of a list, whose encodings must tile the value region of their parent.Benchmarks (local run, this PR against #12310, x86_64 Linux):
shred_variant_partial_object_8k_rowsshred_variant_unmatched_object_8k_rowsunshred_variant_listunshred_variant_list_of_objectsunshred_variant_nested_fallbackunshred_variant_objectunshred_variant_partial_objectunshred_variant_partial_object_unsorted_metadataunshred_variant_primitivevariant_get_unshredded_object_path_262k_rowsvariant_get_list_index_unshreddedvariant_get_utf8_from_unshredded_stringvariant_get_binary_from_stringSlower inputs:
unshred_variant_objectis 4% slower andunshred_variant_listis 3% slower.variant_get_utf8_from_unshredded_stringandvariant_get_binary_from_stringare 9% slower in this run, although this PR does not changevariant_get; these two benchmarks have moved by 10–15% with unrelated changes on this machine.Are there any user-facing changes?
New public API in
parquet-variant:ObjectBuilder::insert_encodedandVariantView::bytes.On malformed variant bytes,
shred_variantand the leftover copy inunshred_variantreturn an error. Before, these paths could panic.🤖 Generated with Claude Code