feat(rust): support configure rust field meta to reduce cost#3089
Merged
chaokunyang merged 6 commits intoapache:mainfrom Dec 25, 2025
Merged
feat(rust): support configure rust field meta to reduce cost#3089chaokunyang merged 6 commits intoapache:mainfrom
chaokunyang merged 6 commits intoapache:mainfrom
Conversation
pandalee99
approved these changes
Dec 25, 2025
- Run cargo fmt to fix formatting issues - Wrap generic type parameters in doc comments with backticks to avoid being interpreted as HTML tags
- Fix misleading comment: compact field ID encoding IS implemented - Add assertion verifying field ID encoding produces smaller payloads - Field IDs use TAG_ID encoding (0b11 marker) per xlang spec
Wrap generic type parameters in FieldTypeClass enum doc comments with backticks to avoid rustdoc HTML tag warnings.
Resolved conflicts combining tuple struct support with field metadata: - misc.rs: Use enumerate + get_field_name for tuple structs with field ID metadata - read.rs: Keep tuple struct index parameter with sorted index matching comment - util.rs: Use get_field_name(field, idx) in fingerprint computation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
This PR implements field-level optimization attributes for Rust, enabling users to control serialization behavior at the field level. This reduces serialization overhead by:
What does this PR do?
New Field Attributes
Adds support for
#[fory(...)]field attributes with the following options:id = NnullabletrueforOption<T>,RcWeak<T>,ArcWeak<T>;falseotherwisereftrueforRc<T>,Arc<T>,RcWeak<T>,ArcWeak<T>;falseotherwiseskipfalseUsage Examples
Compact Field ID Encoding
Per xlang_serialization_spec.md, field IDs use TAG_ID encoding:
This provides ~28% smaller payload compared to field name encoding for structs with explicit field IDs.
Implementation Details
field_meta.rs: New module for parsing#[fory(...)]attributestype_meta.rs: UpdatedFieldInfowithnew_with_id()constructor and compact encodingmisc.rs: Generates field metadata with nullable/ref_tracking/field_idutil.rs: Updated fingerprint computation to include field metadataRelated issues
Closes #3004
#1017
Does this PR introduce any user-facing change?
#[fory(...)]field attributesBenchmark
Field ID encoding produces ~28% smaller payloads: