[PR #918] [MERGED] perf(dotnet): index declaring-type ranges once per metadata table #2349

Closed
opened 2026-10-16 21:17:39 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/918
Author: @morluto
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: codex/managed-member-lookup


📝 Commits (1)

  • acfec42 perf(dotnet): index ordered declaring-type ranges once per table

📊 Changes

3 files changed (+137 additions, -3 deletions)

View changed files

➕ src/dotnet/ManagedMemberInspectorCore.test.ts (+96 -0)
📝 src/dotnet/ManagedMemberInspectorCore.ts (+36 -0)
📝 src/dotnet/ManagedMemberRows.ts (+5 -3)

📄 Description

Summary

Managed member inspection rescans the complete TypeDef list for every field and method. Build a declaring-type lookup once per table and search ordered, disjoint ranges. This optimization was found during the codebase audit; no separate issue is linked.

Problem and expected behavior

With T types and M members, ownership lookup repeats up to T comparisons for each member. Large metadata tables should retain every member and its observed declaring type without repeatedly scanning the type list. Malformed ranges must retain the existing first-match interpretation.

Change and scope

parseFields and parseMethods each create a table-specific range lookup once. Ordered, disjoint half-open ranges use binary search. Overlapping, reversed, or nonmonotonic ranges retain the original scan. Empty types, gaps, unknown owners, token identity, signatures, and output ordering stay unchanged. No cap or persistent cache is added.

Contract and boundary impact

  • Semantic owner and earliest changed stage: managed metadata adapter, after TypeDef parsing.
  • CLI and MCP/tool-catalog contract: no schema or catalog change.
  • Provider, bridge, target-format, or platform compatibility: existing inert PE/CLI inspection.
  • Evidence, artifact, provenance, or reconstruction contract: observed ownership and missing-owner nulls preserved.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

Executed on macOS arm64, Node 24.18.0, three samples per input. Full inspectManagedMembersBytes measurement includes PE/metadata parsing, ownership, signatures/body projection, and output-schema validation. Fixture construction, hashing, and ownership assertions are outside the timer.

Source-owned PE32/CLI fixture Base median Candidate median
1,000 types / 10,000 methods / 1,000 fields 41.1 ms 30.6 ms
3,000 types / 30,000 methods / 3,000 fields 108.4 ms 76.5 ms
5,000 types / 50,000 methods / 5,000 fields 210.5 ms 121.5 ms

Complete result SHA-256 digests match on every workload, and every method ownership token is checked. These fixtures contain shared names and abstract methods without CIL bodies; these numbers are specific to metadata inspection, not a universal assembly-analysis speedup. The 801,280-byte largest fixture has input SHA-256 1bb77ffc2e72691d5e5d386e3de79b0c9e4c2e7de4aa42b4e8520a6a5f22ef59 and identical result digest f7d678668987d5cb38381afef3e4215eb1d0325df88504962a6c7ddea196c31d.

The isolated lookup benchmark includes construction and query checks: 10,000 types / 100,000 method rows improved from 308.8 ms to 7.4 ms median. Normal ordered-range lookup changes from O(TM) to O(T + M log T); malformed metadata retains the previous interpretation and cost.

  • Tests cover separate field/method intervals, boundaries, gaps, repeated starts and empty types, overlapping/reversed/nonmonotonic ownership, and generated first-match equivalence.

  • Existing member/provider/composition/MCP regressions retain behavior.

  • Compiled CLI inspection of a source-owned 1,000-type / 10,000-method PE fixture verifies the public path.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity and source provenance remain preserved.

  • Unknown and malformed outcomes remain visible.

Validation performed

  • npm run build:cached — passed.
  • npm run check:fast — passed.
  • npm run test:focused -- <16 exact managed test paths> — 61 tests passed across dotnet adapters, managed provider boundaries, composition, and MCP.
  • Full compiled parser and isolated lookup baseline/candidate profiles — result checks passed.
  • node scripts/rea.mjs inspect-managed-members <source-owned-fixture.dll> --json — passed.
  • Independent Standards and Spec reviews — clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: no changed engine claim. Real .NET SDK conformance was not run; the SDK is unavailable on this host.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new execution authority or evidence filtering.

Review checklist

  • One focused outcome and Conventional Commit title.
  • Reason for no separate issue stated above.
  • Ownership and malformed-range behaviors covered.
  • No owning contract or generated metadata changes required.
  • Public CLI path checked.
  • Final diff checked for unrelated changes and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/918 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/managed-member-lookup` --- ### 📝 Commits (1) - [`acfec42`](https://github.com/morluto/rea/commit/acfec427e350057a97e8581b0418a1bbdacd79d0) perf(dotnet): index ordered declaring-type ranges once per table ### 📊 Changes **3 files changed** (+137 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `src/dotnet/ManagedMemberInspectorCore.test.ts` (+96 -0) 📝 `src/dotnet/ManagedMemberInspectorCore.ts` (+36 -0) 📝 `src/dotnet/ManagedMemberRows.ts` (+5 -3) </details> ### 📄 Description ## Summary Managed member inspection rescans the complete TypeDef list for every field and method. Build a declaring-type lookup once per table and search ordered, disjoint ranges. This optimization was found during the codebase audit; no separate issue is linked. ## Problem and expected behavior With T types and M members, ownership lookup repeats up to T comparisons for each member. Large metadata tables should retain every member and its observed declaring type without repeatedly scanning the type list. Malformed ranges must retain the existing first-match interpretation. ## Change and scope `parseFields` and `parseMethods` each create a table-specific range lookup once. Ordered, disjoint half-open ranges use binary search. Overlapping, reversed, or nonmonotonic ranges retain the original scan. Empty types, gaps, unknown owners, token identity, signatures, and output ordering stay unchanged. No cap or persistent cache is added. ## Contract and boundary impact - Semantic owner and earliest changed stage: managed metadata adapter, after TypeDef parsing. - CLI and MCP/tool-catalog contract: no schema or catalog change. - Provider, bridge, target-format, or platform compatibility: existing inert PE/CLI inspection. - Evidence, artifact, provenance, or reconstruction contract: observed ownership and missing-owner nulls preserved. - Process execution, authorization, cleanup, or containment impact: none. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage Executed on macOS arm64, Node 24.18.0, three samples per input. Full `inspectManagedMembersBytes` measurement includes PE/metadata parsing, ownership, signatures/body projection, and output-schema validation. Fixture construction, hashing, and ownership assertions are outside the timer. | Source-owned PE32/CLI fixture | Base median | Candidate median | | --- | ---: | ---: | | 1,000 types / 10,000 methods / 1,000 fields | 41.1 ms | 30.6 ms | | 3,000 types / 30,000 methods / 3,000 fields | 108.4 ms | 76.5 ms | | 5,000 types / 50,000 methods / 5,000 fields | 210.5 ms | 121.5 ms | Complete result SHA-256 digests match on every workload, and every method ownership token is checked. These fixtures contain shared names and abstract methods without CIL bodies; these numbers are specific to metadata inspection, not a universal assembly-analysis speedup. The 801,280-byte largest fixture has input SHA-256 `1bb77ffc2e72691d5e5d386e3de79b0c9e4c2e7de4aa42b4e8520a6a5f22ef59` and identical result digest `f7d678668987d5cb38381afef3e4215eb1d0325df88504962a6c7ddea196c31d`. The isolated lookup benchmark includes construction and query checks: 10,000 types / 100,000 method rows improved from 308.8 ms to 7.4 ms median. Normal ordered-range lookup changes from O(TM) to O(T + M log T); malformed metadata retains the previous interpretation and cost. - Tests cover separate field/method intervals, boundaries, gaps, repeated starts and empty types, overlapping/reversed/nonmonotonic ownership, and generated first-match equivalence. - Existing member/provider/composition/MCP regressions retain behavior. - Compiled CLI inspection of a source-owned 1,000-type / 10,000-method PE fixture verifies the public path. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity and source provenance remain preserved. - [x] Unknown and malformed outcomes remain visible. ## Validation performed - `npm run build:cached` — passed. - `npm run check:fast` — passed. - `npm run test:focused -- <16 exact managed test paths>` — 61 tests passed across dotnet adapters, managed provider boundaries, composition, and MCP. - Full compiled parser and isolated lookup baseline/candidate profiles — result checks passed. - `node scripts/rea.mjs inspect-managed-members <source-owned-fixture.dll> --json` — passed. - Independent Standards and Spec reviews — clean. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: no changed engine claim. Real .NET SDK conformance was not run; the SDK is unavailable on this host. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new execution authority or evidence filtering. ## Review checklist - [x] One focused outcome and Conventional Commit title. - [x] Reason for no separate issue stated above. - [x] Ownership and malformed-range behaviors covered. - [x] No owning contract or generated metadata changes required. - [x] Public CLI path checked. - [x] Final diff checked for unrelated changes and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:17:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2349
No description provided.