Skip to content

Wire caching rfc #4210

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Wire caching rfc #4210

wants to merge 1 commit into from

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Jul 15, 2025

Rendered

Motivation and Context

Add an RFC to support wire-caching of response types. This will enable high performance services written in smithy-rs to more efficiently cache data.

Servers can store cached response data in a datastore, then conditionally return it directly to the client. This also includes additions to make it possible to directly retrieve the serialized representation of these types.

This will only be supported at launch for RPCv2 CBOR.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rcoh rcoh requested review from a team as code owners July 15, 2025 17:34
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@drganjoo
Copy link
Contributor

Currently, we don't expose serialization methods to service teams, so implementing wire-format caching would require adding some API for services to obtain the serialized bytes.

Potential Enhancement:

When we do expose this capability, we could consider including validation metadata in the cache storage format:

{
  metadata: {
    model_version: "...",
    protocol_version: "...", 
    field_index: Map<SmithyShapeId, FieldMetadata>
  },
  wire_data: <raw_bytes>
}

How this could work:

  • Code generator emits field position tracking alongside serialization
  • Services store the complete format (metadata + wire bytes) in their cache
  • When returning cached data, we strip the metadata and send only the raw bytes to clients
  • Field index enables selective validation of cached responses without full deserialization

Areas that need more exploration:

  • Collection handling (arrays/maps with validation requirements)
  • Performance impact during serialization
  • Storage overhead scaling

This might be worth digging into as part of the serializer exposure work, but we'd want to benchmark the performance implications first.

@rcoh
Copy link
Collaborator Author

rcoh commented Jul 21, 2025

including metadata is a potential avenue to explore. I know that some of the downstream customers are extremely space sensitive so it would need to be opt in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants