Skip to content

WIP: Array types and interned schema#254

Open
jamesmunns wants to merge 7 commits intomainfrom
james/array-type
Open

WIP: Array types and interned schema#254
jamesmunns wants to merge 7 commits intomainfrom
james/array-type

Conversation

@jamesmunns
Copy link
Owner

Still in progress, I have some string interning working, and starting to figure out the type interning.

This attempts to make a third representation for schemas, intended to make a much smaller wire form. This pulls all strings and subtypes into a deduplicated list, then describes types using references to the attached str/ty data.

I also hope to see if I can emit this to a serialized &'static [u8] at compile time so you don't need to actually serialize the schema at runtime.

CC @max-heller if you have any thoughts on the approach. I also introduced an explicit "array" type to the data model, to get away from using tuple for that.

IMO: this is a breaking "Schema" type change, but is NOT a breaking postcard wire change: fixed size arrays are encoded the same way, they are just described differently.

This avoids repetitive schema definitions of arrays
@jamesmunns jamesmunns requested a review from max-heller July 10, 2025 21:53
@netlify
Copy link

netlify bot commented Jul 10, 2025

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit 8ef9e57
🔍 Latest deploy log https://app.netlify.com/projects/cute-starship-2d9c9b/deploys/6870e69fb8acd70008afdf0c

@jamesmunns
Copy link
Owner Author

So, it works, but it makes small + reasonable schemas a bit bigger (10% or so) on the wire (and a lot more complicated), it's a draw/slight win for "medium" schemas, and really only shines against silly nested/repetitive types.

Hmmm. Bummer.

@max-heller
Copy link
Collaborator

Can we split the array schema change out of this? That seems like a relatively straightforward addition, though I'm wondering if we want to make [T; N] and (T, T, ..., T) (N times) interchangeable or not.

Re. interning, I haven't had time to look into this implementation yet. I thought a lot about interning trees like this a while ago, maybe I can dig up some tricks

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