aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.2k stars 853 forks source link

RPCv2 performance improvements. #5535

Closed sugmanue closed 2 weeks ago

sugmanue commented 2 months ago

Motivation and Context

Adds some performance improvements changes to improve the RPCv2 protocol, including:

Allow reading numbers without parsing

CBOR encodes numbers that are faster to read from its encoded form than converting them to strings and then parsing them back. For that we changed 1) the way we parse to return embedded objects when appropriate, and, 2) the way we unmarshall to support numbers as embedded objects, we also changed the way Instant is unmarshalled as in CBOR that's done as a number.

Faster lookups for unmarshallers

We keep a map in AbstractMarshallingRegistry to register different

. This map is used heavily during unmarshalling to find which unmarshall to use for each value.

to store, keyed on MarshallngType, to register unmarshallers for different types, however the types that we care about are static and known at compile time, this allow us to make an optimization, add an enum key to each of the known MarshallngType that we care about and index those using this enum to use EnumMap that has better performance than regular maps, and, fallback to use a regular map for the marshalling types that are not know.

Modifications

to find the unmarshaller for the given type, and, on Trait.class to find traits stored in the SdkField instances. To improve the performance of both we rely on the fact that both classes have a known set of static values that we care about,

Testing

Screenshots (if appropriate)

Types of changes

Checklist

License

sonarcloud[bot] commented 2 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
50.1% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint