Repository navigation
perf(dotnet): push down native boundary and member selection predicates - #13317
Conversation
… overflow predicates
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0bcdb19378
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The PR appears safe to merge; no blocking issue remains. SummaryThe latest change moves
Reviews (3) · Last reviewed commit: "fix(dotnet): preserve readonly member dr..." · Reviewed by Greptile |
Main split field and method decoding into decodeFieldRow and decodeMethodRow with per-call contexts (morluto#13317) and rewrote the field constant budget test (morluto#13365). Carry the parameter defaults onto that shape: the inspection's shared Constant reader goes into parseFields and parseMethods, the field context calls it with the Field table, and the method context holds the Param default reader so both the full scan and the selected-interval path report parameter_defaults. The budget test now calls the shared reader with the Field table.
Summary
Pushes predicates down into
.NETmetadata table decoding so native-boundary analysis, selected-type inspection, and#USoverflow recovery avoid decoding unreferenced members or re-running full metadata scans:readBoundaryInventory(inventory.issuesdiagnostics acrossCustomAttribute,ManifestResource,AssemblyRef,Assembly,Module,cli.resources).ImplMap(table 28) first (scanImplMaps) to collect imports,ImplMapissues,referencedFieldRows, andreferencedMethodRows, decodes only referencedFieldnames (readReferencedFieldNames), and scans only the fixed-width 4-byteImplFlags+Flagsword atMethodDef +4(scanNativeMethods, mask0x2000_1007) so non-boundaryFieldandMethodDefrows are never decoded.#USbudget overflow preservation (ManagedMemberInspector.ts):baseInspection(user_strings: null) beforeparseUserStrings, and catchesManagedRepresentationFailureviawithoutUserStrings(baseInspection, cause)rather than re-runninginspectManagedMembersBytes(..., { userStrings: false }). The completed report is validated once.FieldList/MethodListinterval iteration (ManagedMemberRows.ts):[start, end)intervals directly and resolves member declaring types via binary search overrangeswhenselected !== nulland pointer tables (FieldPtr/MethodPtr) are absent and monotonic (falling back cleanly tomemberDeclaringTypeRowLookupotherwise).Problem and expected behavior
inspectManagedNativeBoundariesBytesmaterialized fullFieldandMethodDefmaps (89,775rows on capacity fixtures) even when only P/Invoke/unmanaged methods were requested,parseFields/parseMethodsallocated full ownershipUint32Arraymaps under selection, and#USbudget overflow re-ran the full metadata inspection from scratch.inventory.issues, native boundaries, field constants, member ownership, and#USomission diagnostics while skipping unreferenced rows cleanly.Change and scope
Follow the contribution scope.
Not applicable (internal
.NETmetadata reader optimizations within existing read-only contracts).Contract and boundary impact
ManagedNativeBoundaryInspector,ManagedMemberInspectorandManagedMemberRows(ECMA-335 table readers).FieldPtr/MethodPtrindirect layouts continue to use the established fallback, and Constant declaration order is preserved).inventory.issues,readManagedMetadataInventorydiagnostics, andwithoutUserStringspartial omission state).docs/public/product-catalog.json), package, or installation impact: none.Expected effects:
Evidence and regression coverage
native boundary predicate pushdown.user string capacity overflow preserves decoded members.selected FieldList and MethodList interval iteration.origin/main264c398c0dvs0bcdb19378, Apple M5 arm64, Nodev24.22.1):inspectManagedNativeBoundariesBytes(buildManagedMemberSelectionCapacityFixture,9,409TypeDefs /40,037Fields /49,738MethodDefs /58,698CustomAttributes): cold181.82 ms -> 92.84 ms, warm median132.64 ms -> 69.01 ms; non-boundary rows decoded89,775 -> 0; tightmaxRepresentationBytes: 40_000_000moves"unavailable" -> "complete".parseFields+parseMethods(selected = Set(["0x02000001"])): cold15.02 ms -> 5.10 ms, warm median4.38 ms -> 0.57 ms(Uint32Arrayownership allocations4 -> 0).inspectManagedMembersBytes#USoverflow (500methods): cold46.89 ms -> 29.50 ms, warm median36.05 ms -> 21.46 ms(readManagedMetadataInventorypasses2 -> 1).ManagedPe.fixture.ts,managedMemberCapacity.ts,scripts/fixtures/managed/pe.mjs); external real-world.dllbinaries were not benchmarked locally.For evidence-bearing changes:
Validation performed
npm run format:check(8,602files) — passednpm run check:fast(typecheck,lint,verify:architecture-guardsacross2,944source files) — passednpm run test:local(30unit/conformance/composition suites acrosssrc/dotnet/*.test.ts,src/domain/managed/*.test.ts,managedNativeVerification.test.ts,managedApplicationGraph.test.ts) —30/30files,733/733passednpm run build:cached&npm run test:focused(8boundary/MCP/acceptance suites:managedDirectAnalysis,managedStaticProvider,managedFieldConstantsComparison,managedMcp,managedFieldConstantsMcp,managedMemberRecovery,managedSelectedScope,managedMemberPointers) —8/8files,34/34passednpm run knip:production— exited0(advisory report only)Compatibility, safety, and release
v24.22.1unit, conformance, MCP boundary, and acceptance suites on darwin with synthetic ECMA-335 PE fixtures.FieldPtr/MethodPtrindirection, and monotonic-order fallbacks are checked prior to fast-path indexing;budgetreservations remain accounted cleanly.Author readiness
Human owner:
Before merge
type(scope): outcome.