Cache ObjectPType member dispatch - #187
Merged
Merged
Conversation
chklauser
marked this pull request as ready for review
July 25, 2026 00:39
chklauser
force-pushed
the
agent/cache-object-member-dispatch
branch
from
July 25, 2026 00:42
b9c49e4 to
f7ed685
Compare
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.
Summary
ObjectPTypemember call sites to interpreted functionsPTypeidentity and recent-conversion-lock semanticsWhy
ObjectPTypepreviously repeated reflection discovery and Prexonite overload resolution for every member call. The call sites cache the result behind guards derived from the fullPValueshape, rather than delegating binding to C#, so object overrides, type tags, and explicit conversions continue to follow Prexonite rules.The four-rule cutoff bounds polymorphic-chain cost and retained memory. On the fifth distinct binding, a site keeps the four most recently bound shapes and becomes sticky-megamorphic; retained shapes still use cached bindings, while other shapes resolve directly without growing the DLR rule chain.
Benchmarks
BenchmarkDotNet 0.15.8, .NET 10, three launches, 15+ iterations, 2% maximum relative error, concurrent workstation GC:
The fresh-receiver case is the expected unfavorable case: it cannot reuse a binding and additionally checks the bounded retained set. Saturation reduces its earlier pre-cutoff regression from roughly 1.45x to 1.19x while preventing an unbounded guard chain.
Validation
dotnet test -m:1: 1,446 passed, 3 skipped, 0 faileddotnet build -c Release Prexonite.Benchmarks/Prexonite.Benchmarks.csproj -m:1bash "$(jj root)/.codex/hooks/format-csharp.sh"MemoryDiagnoser