Skip to content

feat(xml): add eager deserialization for buffered payloads - #846

Closed
stobrien89 wants to merge 1 commit into
smithy-lang:developfrom
stobrien89:xml-eager-deserialization
Closed

stobrien89 wants to merge 1 commit into
smithy-lang:developfrom
stobrien89:xml-eager-deserialization

Conversation

@stobrien89

Copy link
Copy Markdown
Contributor

Description

Adds eager XML deserialization for buffered payloads while preserving streaming deserialization for reader inputs.

Changes

  • Adds XMLDeserializationMode with:
    • AUTO: eagerly parses bytes and incrementally parses BytesReader inputs.
    • EAGER: always materializes the complete XML tree.
    • STREAMING: preserves the existing pull-parser implementation.
  • Adds an eager tree-backed deserializer supporting structures, attributes, lists, maps, flattened collections, wrappers, timestamps, and unknown members.
  • Adds xml_deserialization_mode to generated Rest XML, AWS Query, and EC2 Query client configurations.
  • Reuses the configured XML codec when deserializing modeled AWS Query errors.
  • Preserves custom protocol codec settings unless explicitly overridden.
  • Updates generated client snapshots, documentation, and changelog metadata.

Performance

Benchmarked on an x86 m7i instance using Python 3.12.14, with 5,000 warmup and 10,000 measured iterations.

XML-decoding cases improved by 28.1–31.4% at p50.

Case Streaming p50 Eager p50 Change
restXml_CopyObjectOutput_M 70.24 µs 48.57 µs 30.9% faster
awsQuery_GetMetricDataResponse_S 150.23 µs 106.04 µs 29.4% faster
awsQuery_GetMetricDataResponse_M 431.90 µs 296.30 µs 31.4% faster
awsQuery_GetMetricDataResponse_L 4,156.95 µs 2,988.69 µs 28.1% faster

Cases that do not decode an XML document through the payload codec showed benchmark noise:

Case Streaming p50 Eager p50 Change
restXml_CopyObjectOutput_Baseline 3.11 µs 3.27 µs 5.3% slower
restXml_GetObject_S 14.55 µs 14.86 µs 2.1% slower
restXml_GetObject_M 14.39 µs 14.86 µs 3.3% slower
restXml_GetObject_L 14.65 µs 14.91 µs 1.7% slower

Compatibility

  • Existing XMLCodec construction remains supported.
  • AUTO preserves incremental parsing for reader inputs.
  • STREAMING retains the previous deserialization path.
  • Existing exception types and XML behavior are preserved.
  • No schema or generated model changes are required.

Validation

  • 2,504 Python tests passed.
  • All generated protocol test suites passed.
  • Full Java build passed.
  • Ruff, Pyright, Spotless, and git diff --check passed.

@stobrien89
stobrien89 requested a review from a team as a code owner October 10, 2026 19:59
@stobrien89

Copy link
Copy Markdown
Contributor Author

Closing in favor of #849

@stobrien89 stobrien89 closed this Oct 12, 2026
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.

1 participant