Skip to content

perf(editor): reuse display metadata when rebuilding type popups - #110

Merged
mackysoft merged 1 commit into
mainfrom
perf/popup-rebuild-metadata
Oct 15, 2026
Merged

mackysoft merged 1 commit into
mainfrom
perf/popup-rebuild-metadata

Conversation

@mackysoft

@mackysoft mackysoft commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reopening a type selector now reuses its sorted display metadata instead of repeating attribute lookups, path splitting, sorting, and label preparation. Each rebuild still creates fresh dropdown items.

The metadata belongs to one popup's candidate snapshot and is prepared lazily. SetTypes and a change of the current culture invalidate it.

Scope

  • Change AdvancedTypePopup only in production code. Keep type discovery, eligibility filters, generic handling, Runtime, and public API signatures unchanged.
  • Preserve public AddTo sorting on every call, stable ordering, menu paths and namespace flattening, input snapshots, mutable item isolation, and type/null selection notifications.
  • Add 11 behavior tests covering those contracts. Diagnostic sources, benchmarks, and temporary Editor windows are excluded from the PR.

Verification

  • Local Unity CLI EditMode: 47/47 regression tests on 2021.3.45f2 and 50/50 on 2023.2.22f1, plus a passing temporary performance diagnostic on each version.
  • Independent code and test-oracle review completed with no outstanding findings.
  • Unity 2023.2 Inspector: open the selector, search for Grape, select it, reopen and select Peach, then reopen and select null. Serialized values and candidate contents/order were confirmed; the preview scene was disposed afterward.
  • Linux Unity CLI EditMode: 47/47 on 2021.3.45f2 and 50/50 on 2023.2.22f1; final Verification passed for commit 871fa0d (PR run).

Repeated BuildRoot measurements on macOS / Apple M1 Max, comparing main (6d034d5) with this change:

Unity Candidate set Median milliseconds, main → change Median GC.Alloc events, main → change
2021.3.45f2 Food, 3 types 0.0241 → 0.0017 143 → 16
2021.3.45f2 object, 1,052 types 12.6660 → 1.8448 35,448 → 4,845
2023.2.22f1 Food, 3 types 0.0225 → 0.0018 148 → 21
2023.2.22f1 object, 1,544 types 17.5151 → 2.1140 53,527 → 8,674

Each subject used the same candidate arrays, with 51 samples per case after JIT warmup and alternating measurement order. Allocation capture ran separately and reports calibrated allocation event counts, not bytes. Names, hierarchy, IDs, and represented types matched main for Food, ITestBase, and object. The baseline popup/utility sources are byte-identical between a746389 and 6d034d5.

Fresh construction plus the first build, including metadata preparation, remained comparable: object medians were 12.1659 → 12.2912 ms on 2021.3 and 17.6828 → 17.6369 ms on 2023.2. These are local diagnostic observations, not timing thresholds in the test suite. The popup retains display metadata for reuse until its snapshot or culture changes.

References

  • #109: investigation separating popup rebuild costs from generic-type discovery.

Why
Reopening a type selector repeats sorting, attribute lookup, path splitting,
and label preparation even when its candidate snapshot has not changed.

What Changed
Prepare private display metadata once per popup snapshot and current culture,
then build fresh dropdown items from it. Invalidate metadata on SetTypes or a
culture change. Keep public AddTo sorting independently on every call.
Add behavior tests for ordering, menu paths, snapshots, replacement, culture,
mutable item isolation, public path isolation, and selection notifications.

Impact
Repeated popup rebuilds avoid redundant metadata work while preserving type
filtering and public APIs. No generic support or shared mutable cache is added.
@mackysoft
mackysoft merged commit 9587592 into main Oct 15, 2026
8 checks passed
@mackysoft
mackysoft deleted the perf/popup-rebuild-metadata branch October 15, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant