Repository navigation
feat(xml): add eager deserialization for buffered payloads - #849
stobrien89 wants to merge 2 commits into
Conversation
| /** | ||
| * The core smithy-xml python package. | ||
| */ | ||
| public static final PythonDependency SMITHY_XML = new PythonDependency( |
There was a problem hiding this comment.
Service clients that rely on a query-based protocol already get a dependency on smithy_aws_core[xml]. That package has an xml dependency group which defines what smithy_xml version it is compatible with.
smithy-python/packages/smithy-aws-core/pyproject.toml
Lines 62 to 64 in 676fb80
Since you have a feature changelog entry being added, our release infra will bump smithy_xml to v0.3.0. Since its a minor bump, that gets propagated all the way through our dependency chain. So:
smithy_xmlv0.2.0 --> v0.3.0smithy_aws_corev0.12.0 --> v0.13.0xmldependency group updates:smithy_xmlv0.2.0 --> v0.3.0
aws-sdk-<query-service>v0.x.0 --> v0.x+1.0smithy_aws_core[xml]v0.12.0 --> v0.13.0
In summary, we don't need this and version management is changelog driven and handled at release time
676fb80 to
6dc92f8
Compare
| from smithy_core.shapes import ShapeID | ||
| from smithy_core.types import TimestampFormat | ||
|
|
||
| from ._private.deserializers import XMLShapeDeserializer as _XMLShapeDeserializer |
There was a problem hiding this comment.
Nothing is using XMLShapeDeserializer or readers.py anymore right? Can we delete the streaming deserializer and move XMLValueDeserializer into deserializers.py? We might even just want to rename back to XMLShapeDeserializer for consistency.
| reader = _XMLEventReader( | ||
| iterparse(source, events=("start", "end")) # noqa: S314 | ||
| root = ( | ||
| fromstring(source) # noqa: S314 |
There was a problem hiding this comment.
Now that parsing is eager, we're calling fromstring() on the same body two or three times per response. Could we parse once and pass the root element through? Didn't deep dive, but if that just affects the error case, not a big deal. But we definitely want the happy path not to do this multiple times if preventable
Description
Adds eager XML deserialization for buffered payloads while preserving streaming deserialization for reader inputs.
Changes
XMLDeserializationModewith:AUTO: eagerly parsesbytesand incrementally parsesBytesReaderinputs.EAGER: always materializes the complete XML tree.STREAMING: preserves the existing pull-parser implementation.xml_deserialization_modeto generated Rest XML, AWS Query, and EC2 Query client configurations.Performance
Benchmarked on an x86
m7iinstance 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.
restXml_CopyObjectOutput_MawsQuery_GetMetricDataResponse_SawsQuery_GetMetricDataResponse_MawsQuery_GetMetricDataResponse_LCases that do not decode an XML document through the payload codec showed benchmark noise:
restXml_CopyObjectOutput_BaselinerestXml_GetObject_SrestXml_GetObject_MrestXml_GetObject_LCompatibility
XMLCodecconstruction remains supported.AUTOpreserves incremental parsing for reader inputs.STREAMINGretains the previous deserialization path.Validation
git diff --checkpassed.