Repository navigation
Conversation
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Schemas are now generated as package-level variables that the compiler initializes statically, instead of
NewSchema/AddMembercalls in aninit(). Schema packages no longer run code or allocate at startup, and the linker can drop schemas that nothing references.This replaces the table-based layout from the
pagedatabranch (records indexed by row in a per-packageSchemaSet). That layout fixed the heap but made every accessor chain through the set, record slices and bounds checks, and it was slower than main. Here every schema reaches its data with the same number of loads as main, except trait lookups (one extra load) and extension lookups (one extra load).Layout
Generated code looks like this:
NewStaticSchemais small enough to inline, which is what lets the compiler lay these out as data. Recursive shapes would make the initializers refer to each other in a cycle, which Go rejects, so the member that closes each cycle is left withoutMembersand completed in a smallinit()(one store per member, no allocation). That's 182 members across the whole SDK, in 57 packages.Member(name)scansListfor shapes with up to 8 members and uses the perfect hash otherwise.ListMember,MapKeyandMapValuereadList[0]/List[1].NewSchemaandAddMemberbuild the same structure on the heap and still work, including with a static schema as theAddMembertarget.The JSON and CBOR struct readers now call
Member(serde.UnsafeString(key))instead ofMembers()[string(key)].API
Added, for generated code only:
NewStaticSchema,StaticSchema,SchemaMembers,MemberHash,ShapeName,SchemaExtensions,TraitSet.Schema.DumpandSchemaDumpare also added; only the SDK's static-vs-dynamic verification test uses them, and they could move somewhere less visible. No existing exported signature changed.Behavior changes:
ListMember,MapKeyandMapValuereturn nil unless the schema is a list/set or map. Before,ListMemberreturned a member namedmemberon any shape.AddMemberkeeps a map'skeybefore itsvalue.Members()is nil for a static shape without members, instead of an empty map.AddMemberon a static schema panics.Results
Measured on m7i.xlarge and m7g.xlarge with Go 1.27.3, against main and against the
pagedatalayout. All variants were interleaved within each rep on the same boxes, over two rounds (10 and 6 reps). The aws-sdk-go-v2 side is thepagedata-ptrcbranch.Serde benchmarks, mean over 71 cases versus main:
The gain comes from member lookups. A linear scan or perfect hash takes about half the time of a Go map lookup (4-member struct: 10.3 ns -> 6.0 ns on x86, 10.0 -> 5.5 on arm). On arm,
ListMemberalso avoids an atomic load. The one regression is REST serialize, at +1-2.6%. The httpbinding serializer makes about 6SchemaTraitcalls per member per request, and deduplicated trait sets sit farther from the schema than main's per-member copies, which costs L1 misses. Caching HTTP-binding membership in the httpbinding extension would fix that for any layout.Stripped binary size, MiB (x86_64):
Heap and startup (x86_64):
Costs:
schemas.gois about 2x main's size across the SDK, because every schema is a keyed composite literal.Testing
go test ./..., codegen./gradlew build.go testandgo vet --allexceptcodegenand oneconfigtest, which fails on the base commit too.