[GH-ISSUE #1953] inspect_managed_members falls back to a per-member TypeDef scan for unordered member lists (quadratic) #649

Closed
opened 2026-10-15 18:26:57 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @kaoru0822-kitauji on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1953

Observed behavior

inspect_managed_members resolves each field and method's declaring type through createDeclaringTypeLookup (src/dotnet/ManagedMemberInspectorCore.ts). When the TypeDef field or method lists are ordered, it binary-searches. If any range is reversed or out of order, as crafted or malformed metadata can make it, it falls back to declaringType, which scans every TypeDef range for each member. That is O(members × types).

Measured directly on createDeclaringTypeLookup, with one reversed range first and the owning type last:

types = methods lookup time
10,000 96 ms
20,000 348 ms
40,000 1.4 s
100,000 8.1 s

This is the members-side counterpart of #1940. #1943 fixed the attribute path with its own first-match index, so TypeDef member-list ownership is now interpreted twice, in the inventory and in the members inspector.

Expected behavior

One shared first-match ownership index serves both inspectors in near-linear time for ordered and unordered lists, keeping the current first-match owner for malformed, overlapping ranges.

Originally created by @kaoru0822-kitauji on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1953 ### Observed behavior `inspect_managed_members` resolves each field and method's declaring type through `createDeclaringTypeLookup` (`src/dotnet/ManagedMemberInspectorCore.ts`). When the TypeDef field or method lists are ordered, it binary-searches. If any range is reversed or out of order, as crafted or malformed metadata can make it, it falls back to `declaringType`, which scans every TypeDef range for each member. That is O(members × types). Measured directly on `createDeclaringTypeLookup`, with one reversed range first and the owning type last: | types = methods | lookup time | | ---: | ---: | | 10,000 | 96 ms | | 20,000 | 348 ms | | 40,000 | 1.4 s | | 100,000 | 8.1 s | This is the members-side counterpart of #1940. #1943 fixed the attribute path with its own first-match index, so TypeDef member-list ownership is now interpreted twice, in the inventory and in the members inspector. ### Expected behavior One shared first-match ownership index serves both inspectors in near-linear time for ordered and unordered lists, keeping the current first-match owner for malformed, overlapping ranges.
bsakaguchi 2026-10-15 18:26:57 +00:00
  • closed this issue
  • added the
    bug
    label
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#649
No description provided.