Skip to content

feat: add binary encoding for unboxed types#13

Merged
tmcdonell merged 7 commits into
mainfrom
feat/binary-encodable
Jan 14, 2026
Merged

feat: add binary encoding for unboxed types#13
tmcdonell merged 7 commits into
mainfrom
feat/binary-encodable

Conversation

@tmcdonell

Copy link
Copy Markdown
Contributor

Summary

This adds an encoding to Data for types that can be represented without pointers. This can be done efficiently by copying the entire underlying buffer in one go.

@tmcdonell tmcdonell requested a review from JaapWijnen December 19, 2025 11:56
@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch 2 times, most recently from bc89f1e to 1883164 Compare December 20, 2025 09:38
@tmcdonell tmcdonell changed the title feat: add binary wire encoding for unboxed types feat: add binary encoding for unboxed types Dec 21, 2025
@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch from 1883164 to ec00aca Compare January 6, 2026 14:02
This is implicitly true becaues SIMDScalar is limited to scalar types,
but this is more precise and resistent to future changes.
@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch from ec00aca to a2661c5 Compare January 6, 2026 14:13
@tmcdonell

Copy link
Copy Markdown
Contributor Author

Rewritten to include a type encoding in the (now variable sized) header. Might be good to include a hash of the (type) header as well for extra redundancy and/or constant-time header validation, although the current should be non-allocating and realistically fast enough. We can get single-bit flips in the type encoding to another valid type (it is a very small space), but for that to pass validation requires the receiver to also be expecting the corrupted tag, so the silent failure mode is unlikely.

@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch 5 times, most recently from 85c9b51 to 37aef21 Compare January 7, 2026 07:43
Comment thread Sources/MultiArray/Generic.swift Outdated
Comment thread Sources/MultiArray/Generic.swift Outdated
Comment thread Sources/MultiArray/ArrayData.swift
Comment thread Sources/MultiArray/Extensions/Data.swift Outdated
@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch from 2a3111c to bd6b932 Compare January 13, 2026 15:18
This moves the platform dependent sized Int and UInt to the surface
layer
This explicitly excludes Box, so we are statically restricted to types
we can fully encode in our struct-of-array representation.
@tmcdonell tmcdonell force-pushed the feat/binary-encodable branch from bd6b932 to 31455da Compare January 13, 2026 15:25
@tmcdonell tmcdonell merged commit 9c8c900 into main Jan 14, 2026
3 checks passed
@tmcdonell tmcdonell deleted the feat/binary-encodable branch January 14, 2026 11:18
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.

3 participants