Skip to content

perf: optimize compatible mode read performance#3743

Open
chaokunyang wants to merge 35 commits into
apache:mainfrom
chaokunyang:optimize_compatible_mode_perf
Open

perf: optimize compatible mode read performance#3743
chaokunyang wants to merge 35 commits into
apache:mainfrom
chaokunyang:optimize_compatible_mode_perf

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented Jun 6, 2026

Why?

Compatible-mode xlang reads spend too much time in generic matched-field handling: exact schema matches can still carry compatible metadata, scalar widening can redispatch through generic converters, and regenerated serializers can keep extra matched-id dispatch in their hot paths. The benchmark matrix also lacked a focused schema-mismatch mode for measuring compatible-read behavior across runtimes.

What does this PR do?

  • Optimizes compatible-read layout/codegen across Java, C++, C#, Dart, Go, JavaScript, Kotlin, Python, Rust, Scala, and Swift by classifying matched fields as exact direct reads, compatible scalar conversions, or remote-only skips before generated dispatch.
  • Adds typed/lossless compatible scalar conversion paths and descriptor-aware converter callsites so hot reads use concrete remote wire reads plus the required conversion instead of generic remote/local type redispatch.
  • Updates generated/static serializer paths, reader caches, collection handling, and mismatch validation so compatible reads keep direct same-schema paths while rejecting incompatible matched fields.
  • Extends tests for compatible scalar conversion, generated/static serializers, struct compatibility, mismatch handling, and xlang coverage across affected runtimes.
  • Adds/updates benchmark workloads, run scripts, and README guidance for Fory-only schema-mismatch benchmark mode via FORY_BENCH_SCHEMA_MISMATCH=1, including v1-to-v2 int32-to-int64 compatible-read cases.
  • Documents the generated compatible-read ownership model in the xlang implementation guide and local runtime guidance.

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

No public API or binary protocol compatibility change is intended. The visible change is benchmark-only documentation and runner support for schema-mismatch compatible-read measurements.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Adds schema-mismatch benchmark mode to the language benchmark runners. Run with FORY_BENCH_SCHEMA_MISMATCH=1 and --serializer fory to measure compatible-read deserialization where v1 benchmark payloads are read by v2 schemas using the same Fory type IDs and one widened int32-to-int64 field.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants