-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use serde helper function & serde shortcuts #735
Conversation
18a8d3b
to
3aef19d
Compare
sample: effect on aws-sdk-js-v3's client-sagemaker
Overall -24%, or -44% in the protocols file, for this particular JSON protocol client. Other examples:
The magnitude of the effect is based on how much of the protocol serde is composed of simple objects that don't need parsing. Doubles, floats (NaN & Infinity strings), timestamps and other types with parsing steps cause the optimization to bail. JSv3 overall dist-cjs byte count effect provided in linked PR. |
* Incompatible types refers to types that need special serde mapping | ||
* functions, like timestamps. | ||
*/ | ||
private boolean hasIncompatibleTypes(Shape shape, Set<ShapeType> types, int depth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a selector equivalent for this?
Set<Shape> matches = selector.select(model); | ||
boolean found = !matches.isEmpty(); | ||
|
||
if (found) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be return found
from here
* For determining whether a serde function for a shape may be omitted. | ||
*/ | ||
public final class SerdeElision { | ||
private static final Map<Model, SerdeElision> INSTANCES = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leak memory, usually better to use an LRU cache with a capped size or something else that the GC can collect.
return Promise.resolve(...)
in async fn.take(...)
from feat(codegen): add serde helper function aws/aws-sdk-js-v3#4616 to reduce repeated field names in object mapping.(_) => expectString(_)
toexpectString
SerdeElision
helper. This decides whether a serde function can be omitted.becomes
where
_json
is a helper function that applies recursive default json serde behavior (omit nullish, filter sparse lists). This allows the omission ofde_MyShape
and any downstream serde functions. This optimization only occurs if the entire shape and its downstream shapes require no special parsing.