Repository navigation
Look up input object fields and enum values by UTF-8 name during variable coercion - #10534
Merged
Merged
Conversation
tobias-tengler
force-pushed
the
tte/core-utf8-input-field-lookup
branch
from
October 13, 2026 12:43
2fa8b40 to
39fcf1e
Compare
…able coercion Variable coercion decoded every JSON property name and enum string into a UTF-16 string for the field and value lookups, and the literal pass created a new NameNode per coerced field. FieldCollection<T> and EnumValueCollection now look names up as UTF-8 bytes: collections with up to eight entries are scanned with Ascii.Equals, larger ones widen the name into a stack buffer and use the frozen dictionary's ReadOnlySpan<char> alternate lookup. The enum lookup honors the configurable name comparer and only decodes the string for custom comparers. The input parser and the coercion helper use these lookups, the literal pass reuses the schema's enum name and a NameNode cached on InputField, and processed fields are tracked by index instead of a pooled string set.
tobias-tengler
force-pushed
the
tte/core-utf8-input-field-lookup
branch
from
October 13, 2026 12:49
39fcf1e to
d7f22f0
Compare
Contributor
Patch coverage100.0% of changed lines covered (95/95)
Project coverage: 58.7% (315762/538284 lines) |
The JSON property and element overloads move into the input parser and the enum type, the enum collection's byte lookup mirrors the field collection, and the literal pass allocates the enum value node per coerced value from the schema's name.
tobias-tengler
marked this pull request as ready for review
October 13, 2026 13:11
This was referenced Oct 25, 2026
Merged
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.
Variable coercion decoded every JSON property name and enum string into a UTF-16 string for the field and value lookups, and the literal pass created a new
NameNodeper coerced field.FieldCollection<T>andEnumValueCollectionnow look names up as UTF-8 bytes: collections with up to eight entries are scanned withAscii.Equals, larger ones widen the name into a stack buffer and use the frozen dictionary'sReadOnlySpan<char>alternate lookup. The enum lookup honors the configurable name comparer and only decodes the string for custom comparers. The input parser and the coercion helper use these lookups, the literal pass reuses the schema's enum name and aNameNodecached on InputField, and processed fields are tracked by index instead of a pooled string set.Benchmarks
Measured with a local
VariableCoercionBenchmark(not part of this PR), net11 in-process.Small input (2 objects, 5 fields)
mainLarge input with a list of 20 input objects (22 objects, 66 fields)
mainSingle enum value
mainList of 20 enum values (12-value enum)
mainVariable coercion allocates 31% less for the small input and 33% less for the large input, and is 24% and 26% faster. A single enum value allocates 13% less at the same speed. A list of 20 values of a 12-value enum allocates 30% less but is 9% slower, because the hashed lookup fetches the alternate lookup per call; caching it, together with a cached enum literal, follows in a separate PR.