Repository navigation
Reduce codegen size - #1430
Reduce codegen size#1430
Conversation
Codegen size reportCode generated for 437 AWS service models (aws-api-models 1.0.337) with modes
Totals cover the 435 services that compile on both base and PR. Known failures excluded: Largest changes by service435 of 435 services changed jar size.
`ec2`: by category
`ec2`: largest changes by class33 top-level classes added, 9 removed. Sizes are deflated jar bytes.
Base: |
ddd6c1a to
c34a6e5
Compare
| @Override | ||
| public Void listShape(ListShape listShape) { | ||
| var kind = CodegenUtils.collectionWriterKind(model, listShape.getMember()); | ||
| if (kind != null) { |
There was a problem hiding this comment.
this kinda contradicts with an ability to override the type via symbol provider for a given shape - e.g. if in a symbol provider you say "this shape has to be a list of LocalDate objects" whilst on the model level it is still a string, the code will be generated correctly, but now because the list generation is based on the smithy model alone (without accounting for the codegen symbol provider) this gets out of sync. Is this expected?
There was a problem hiding this comment.
Hmm it feels like it should fine as soon as the codegen integration also overrides the codegen for lists and maps now (previously when overriding the codegen for a specific "string" shape e.g. with a trait it was automatically applied to both lists and maps of such shape, but now it has to be done additionally). So I guess it should be fine 🙏
a3409d2 to
bc2e96b
Compare
|
@mtdowling I added back Unknown enum as a record. It adds about 170 KB but preserves backward compatibility for unknown record deconstruction. |
bc2e96b to
296c12e
Compare
b342571 to
63590db
Compare
Wrap failures raised during deserialization (e.g. a union builder rejecting a payload with no members or more than one member set) into SerializationException at the top-level entry points: Codec and JsonCodec deserializeShape, and the HTTP binding request/response deserializers. This makes malformed input surface consistently across codecs instead of leaking NullPointerException/IllegalArgumentException from generated builders.
Replace generated structure and collection deserializer callback classes with static method references. Keep serializer singleton classes to preserve cold serialization performance, and shard SharedSerde content alongside schema partitions. EC2 benchmark (811 operations), relative to the prior per-operation output: - JAR: 25,020,471 -> 21,431,175 bytes (-14.35%) - Classes: 15,335 -> 12,034 (-21.53%) - First serialization: 8.6 -> 7.9 ms - First deserialization: 15.5 -> 4.9 ms - Steady serialization: 106.2 -> 106.2 ns/op - Steady deserialization: 2,077.4 -> 2,031.4 ns/op Timing values are medians from three fresh JVM runs. Tests: ./gradlew :codegen:codegen-core:check :codegen:codegen-plugin:check
63590db to
c07f500
Compare
c07f500 to
58d182a
Compare
What behavior changes?
Generated models share operation and enum logic, use typed collection writers, and replace deserializer helper classes with static methods.
SharedSerdefollows schema partitions.ApiServiceadds operation lookup byShapeId. Unknown enum variants become classes instead of records.Why is this change needed?
Large models repeat helper code across thousands of shapes. For EC2, the JAR shrinks from 23.35 MB to 15.97 MB (31.60%), with 4,598 fewer classes.
How was this validated?
Added tests cover collection writers across codecs, enum equality, generated deserializers, and operation lookup. The EC2 size workflow and Java 25 tests on macOS passed. Ubuntu tests remain in progress.
What should reviewers focus on?
Review
OperationGenerator,EnumGenerator,SharedSerdeGenerator, and the collection writers in each codec. Review how these changes handle sparse collections, unknown enum values, and operation schemas.Additional Links
EC2 size report.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Stack created with GitHub Stacks CLI • Give Feedback 💬