[PR #1943] [MERGED] fix(managed): index attribute constructor owners once per layout #4927

Closed
opened 2026-10-31 00:56:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1943
Author: @kaoru0822-kitauji
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @morluto

Base: main ← Head: fix/issue-1940


📝 Commits (1)

  • 060d3bb fix(managed): index attribute constructor owners once per layout

📊 Changes

2 files changed (+105 additions, -24 deletions)

View changed files

📝 src/dotnet/ManagedArtifactInspector.test.ts (+29 -0)
📝 src/dotnet/ManagedMetadataInventoryRows.ts (+76 -24)

📄 Description

Fixes #1940

Behavior

inspect_managed_artifact resolved each local attribute constructor's declaring type by scanning the TypeDef table from row 1, so the work was O(attributes × TypeDefs). After #1897, repeated row cursors no longer charge the decode budget, so nothing bounded that work (raised as a P1 by Codex on #1897).

This PR builds a first-match owner index (methodOwnerRows) once per metadata layout and looks each constructor up in it. Already-owned method-list positions are skipped, so overlapping or unordered (malformed) method lists keep the previous first-match owner in near-linear time. Names are still read through readMetadataString per attribute, so the per-attribute representation charge is unchanged. The index arrays are reserved in the decode budget, and a build failure is cached like memberListRowLookup's.

16,000 TypeDefs × 16,000 attributes (584 KB) time
main d802304c5 38.1 s
this PR 27 ms

Open PR #1706 includes a similar index as part of a feature. That PR conflicts with main, predates pointer-table ownership (#1886), and still scans per attribute when method lists are unordered.

Validation

  • New module test in src/dotnet/ManagedArtifactInspector.test.ts. It fails on main (36.4 s against the 2 s bound) and passes here; all 170 src/dotnet tests pass.
  • npm run lint, npm run typecheck, npm run format:check: pass.
  • npm test: 8,261 passed, 12 failed. The same 12 failures occur on a clean origin/main worktree on this Mac. They are environmental: ibtool NIB tests (Command Line Tools only), the hdiutil verify refusal, and JS runtime discovery path tests in /private/var temp directories. None of them touch managed code.
  • Not verified against real compiled .NET assemblies; there is none on this machine.

🤖 Generated with Claude Code


🔄 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/1943 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/issue-1940` --- ### 📝 Commits (1) - [`060d3bb`](https://github.com/morluto/rea/commit/060d3bbbe6cc4089f14eb24c47d0c990dcd321ab) fix(managed): index attribute constructor owners once per layout ### 📊 Changes **2 files changed** (+105 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedArtifactInspector.test.ts` (+29 -0) 📝 `src/dotnet/ManagedMetadataInventoryRows.ts` (+76 -24) </details> ### 📄 Description Fixes #1940 ## Behavior `inspect_managed_artifact` resolved each local attribute constructor's declaring type by scanning the TypeDef table from row 1, so the work was O(attributes × TypeDefs). After #1897, repeated row cursors no longer charge the decode budget, so nothing bounded that work (raised as a P1 by Codex on #1897). This PR builds a first-match owner index (`methodOwnerRows`) once per metadata layout and looks each constructor up in it. Already-owned method-list positions are skipped, so overlapping or unordered (malformed) method lists keep the previous first-match owner in near-linear time. Names are still read through `readMetadataString` per attribute, so the per-attribute representation charge is unchanged. The index arrays are reserved in the decode budget, and a build failure is cached like `memberListRowLookup`'s. | 16,000 TypeDefs × 16,000 attributes (584 KB) | time | | --- | ---: | | main `d802304c5` | 38.1 s | | this PR | 27 ms | Open PR #1706 includes a similar index as part of a feature. That PR conflicts with main, predates pointer-table ownership (#1886), and still scans per attribute when method lists are unordered. ## Validation - New module test in `src/dotnet/ManagedArtifactInspector.test.ts`. It fails on main (36.4 s against the 2 s bound) and passes here; all 170 `src/dotnet` tests pass. - `npm run lint`, `npm run typecheck`, `npm run format:check`: pass. - `npm test`: 8,261 passed, 12 failed. The same 12 failures occur on a clean origin/main worktree on this Mac. They are environmental: ibtool NIB tests (Command Line Tools only), the hdiutil verify refusal, and JS runtime discovery path tests in `/private/var` temp directories. None of them touch managed code. - Not verified against real compiled .NET assemblies; there is none on this machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:56:58 +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#4927
No description provided.