Program Plugin: Incremental Win32/UWP Reindex
UN
19d ago+172+172+012345678901234567890123456789-15-15-01234567890123456789
Split as requested: the faster shortcut reading (ShellLinkReader) moved to #4742. This PR now contains only the incremental reindex. The two are independent (no shared files) and combine.
Problem
Every program install or uninstall triggers a full Win32 reindex (Start Menu watcher → IndexWin32ProgramsAsync) that re-parses every shortcut and executable. An installer that adds shortcuts over a few seconds triggered it more than once, at normal priority on all cores. Each UWP package change re-parsed every package manifest (~3.6 s for 27 apps; enumerating the packages alone takes ~0.3 s).
Changes
Win32
- Parsed entries are memoized by path and exact file timestamp (
ParsedStamp). For.lnk, the target's timestamp (ParsedTargetStamp) is checked too, including a missing target's path (MissingTargetPath), so a shortcut is reparsed when its target changes, disappears or appears. - Each pass reads the previous pass's results and records only what it saw, so the memo holds only current files.
- The memo is seeded from the loaded
Win32.cacheat startup. Then an incremental pass runs in the background (~200 ms) to catch changes made while Flow was closed. The new properties are appended at the end of theMemoryPackableclass. Old caches still load (those entries are parsed again once). An older plugin build can't read the new cache: it logs a deserialize error and does a full reindex. - A full reindex (startup after 30 h, settings change, manual "Reindex") discards the memo at the start of its own pass. Only a full reindex updates
LastIndexTime. - Watcher debounce: wait for 3 s of quiet instead of a fixed 500 ms, so an install burst results in one reindex.
Win32.Allruns on a dedicatedBelowNormalthread. Auto-index programs are materialized beforeProgramsHasher, so parsing stays on that thread.
UWP
- Parsed packages are memoized by
Package.Id.FullName(includes the version) + install path. On a Store update only the updated package is parsed again.
Results (Release build of v2.1.4 with only this PR's changes, same machine, 846 programs)
| Scenario | Before | After |
|---|---|---|
| Reindex after a Start Menu change | ~114 s | 0.1 s (30–90 ms CPU) |
| Startup catch-up pass | — | ~200 ms |
| UWP reindex on a Store update | ~3.6 s each | 30–140 ms CPU (13 reindexes during a 7-app Store update, all versions picked up) |
| Full reindex | ~114 s | unchanged (~4.5 s together with #4742) |
Tested on Windows 11 23H2:
- created and deleted shortcuts (cold, warm, after a forced kill, while Flow was closed);
- a shortcut replaced in place with older timestamps;
- a target exe replaced in place;
- a target that appears later;
LastIndexTimeunchanged by incremental passes;- old-cache → new-plugin and new-cache → old-plugin compatibility;
- a real Microsoft Store update session.
Review feedback is addressed in the commits and in the comments above.