[EXPERIMENTAL] Improved Go tuple library #12338
Draft
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.
This PR adds an experimental tuple decoder that is optimized for lower allocations and higher performance, support for fixed-length byte strings, along with fixing some panics.
This should be kept experimental until a way to handle the potentially breaking changes is found (possibly combining it with other breaking binding changes in a Go bindings "v2")
Over the original decoder, the new decoder attempts to zero-copy strings, and uses a new
Boxed
type which requires zero allocations compared to theany
type which requires its contents are on the heap.A neat hack relating to on-stack slice allocation is also used to remove allocations from
append
that arise from tuples while not having to estimate the length of the tuple for capacity.The tests are also improved to ensure unpacking works correctly, and benchmarks are added.
This PR was closed and reopened due to separating this update to a separate branch
Benchmarking
To run benchmarks:
go test -run=NONE -bench=^BenchmarkTupleUnpack
To-do list
google/uuid
(we may be able to just aliastuple.UUID
to it)Unpack
to not depend on the input buffer. This could be "fixed" by copying the input buffer or by making a breaking v2 release (alongside possibly other binding improvements).big.Int
. The new decoder does not support this right now.Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.