Specialized row decoders per type and pinned byte arrays - #49
Draft
mzabani wants to merge 35 commits into
Draft
Conversation
This improves our "Record Stream" benchmarks by ~8.2%, even if total memory allocated goes up a bit.
It's only used to fetch field values, and values with length exactly 0 are extremely rare
We're beginning to converge to row decoders not being inlined by default, but their implementations/bodies being as inlined as possible, which feels reasonable. It remains to be seen if we can add a super-inlined version of row decoders for users to choose from if they wish, and what the effects are.
The boundary here is very nice: users that want to avoid too much code bloat can use the non-inlined decoders, and those that want to max out performance can use the inlined decoders.
With this, I am able to write specialised `FromPgField (Maybe a)` instances that can inline more aggressively. The gotcha is
Let's see if this is better than the OVERLAPPING instances
This is the prize I was looking for. Now the row decoders are built with the NULL handling parts a lot more inlined, which even means in a fully inlined row decoder we no longer box into a `Maybe a` to then case match on it and fail on `Nothing`, when the target record has a field typed as `a` (not a Maybe).
Types like `Scientific` are not being decoded optimally otherwise, and they can do better than in the current state
Becase we don't have a FieldInfo when decoding NULL anymore. Not sure what we can do.
And use them almost everywhere.
Barely any difference in performance
So we can change them
Very little gained, but why not?
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.
This needs to be rebased and explained.
This has technically breaking API changes (but most users shouldn't be affected and it's easy to adapt to the changes) and still needs a lot of thinking before being merged.
Before merging:
instance FromPgField MyEnum's definition, and see that users have no way of usingfailwithrawBytesFieldDecoder. Maybe something to keep in mind in any form of API changes.