Bypass CompositeBuilder for parameterless composite types#6458
Open
yykkibbb wants to merge 1 commit intonpgsql:mainfrom
Open
Bypass CompositeBuilder for parameterless composite types#6458yykkibbb wants to merge 1 commit intonpgsql:mainfrom
yykkibbb wants to merge 1 commit intonpgsql:mainfrom
Conversation
Skip CompositeBuilder when ConstructorParameters == 0 by reading and setting field values directly on the instance via new ReadAndSet/SetDbNull methods on CompositeFieldInfo.
64b3667 to
fde8d8d
Compare
Author
|
This implements the approach @NinoFloris suggested in #6452. All existing composite tests pass along with a new test for nullable fields through the fast path. @roji @vonzshik Open to any feedback on the implementation! — happy to adjust if there's a better approach or improvements to make. |
NinoFloris
reviewed
Mar 14, 2026
Member
There was a problem hiding this comment.
Thanks @yykkibbb, though this shows that it can work I'd rather see a more minimal diff.
Ideally you would mostly keep the current api surface but allow the builder to be an instance of T as well. This would mean both paths incur an exact type type check (if builder is CompositeBuilder<T>) but that should be well predicted and cheap.
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.
Fixes #6452
When
ConstructorParameters == 0,CompositeBuilderis unnecessary — it just creates the instance, boxes it, and callsfield.Set()for each field. This adds a fast path that skips the builder entirely, avoiding per-read allocations.Changes
ReadAndSet/SetDbNullmethods toCompositeFieldInfofor direct field settingCompositeConverter.Read()intoReadDirect(fast path) andReadWithBuilder(existing path)ValidateOidas a shared static method