Skip to content

Avoid quadratic registry reads and duplicate disk scans when opening Skills #1124

Closed

Description

@currentbits

Priority: P1. Performance defect verified at 6c7a6fb on 2026-09-08.

Evidence

Opening Skills calls reloadAll: listSkills and listSkillCatalog both scan all user skill directories. listCatalog calls listSkills again. Each managed provider copy calls resolveManagedProvenance -> lookupInstall -> readRegistry, which reads, parses and sanitizes the entire registry. With N managed skills and P provider copies, registry processing grows approximately with P*N², then runs twice. The IPC handler being async does not move its synchronous filesystem work off Electron's main thread.

Disposable fixture, real production functions, three provider copies per skill:

Skills Registry reads per paired load SKILL.md reads Synchronous elapsed
100 600 600 72 ms
300 1,800 1,800 350 ms
600 3,600 3,600 1,160 ms

A separate read-only scan of the local skills directories returned 62 rows and took 39 ms for the paired load without registry provenance lookup. This is a smaller baseline, not evidence of a current 1.16-second user stall. Timings are one-machine diagnostics; operation counts are deterministic.

Smallest useful fix

  • Read and validate the app-owned registry once per inventory scan and reuse that snapshot for all marker lookups. Keep marker/name/catalog provenance validation intact.
  • Derive installed catalog status from the same inventory used by Skills, or coalesce the paired reads. Avoid rescanning every provider for static catalog metadata.
  • Reuse parsed metadata for aliases of the same physical SKILL.md within a scan, preserving symlink and dangling-link behavior.
  • If remaining cold I/O exceeds the interaction budget, move inventory scanning off the main event loop. Benchmark first; a permanent watcher framework is not required.
  • Refresh correctly after add/remove/sync/import and project changes. Avoid an indefinitely stale global cache.

Acceptance

Instrument the same 600-skill fixture: registry reads are O(1) per inventory, not per provider copy; a paired Skills/catalog load does not duplicate a full inventory. Target at least 80% less elapsed time versus the paired baseline on the same machine, with no main-thread task over 50 ms during tab opening. Report actual before/after p50/p95 and event-loop delay instead of claiming a universal speedup. Verify provenance, sync drift, imported plugins, external edits after refresh, symlinks and project read-only rows still work.

Runnable current-behavior evidence in the audit checkout: node docs/issue-drafts/2026-09-08-performance-skills-memory-evidence.cjs (exit 0). It creates/removes synthetic directories and asserts registry/skill read counts; it does not modify live skills.

Sources: inventory, provenance, registry, catalog, tab load.

Separate from #695 provider path correctness and #728 CSS flattening. No app implementation in this audit.

Activity

  1. added
    plan:todo
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Sep 8, 2026
  2. currentbits commented on Sep 8, 2026

    @currentbits
    OwnerAuthor

    Fixed on this branch. Inventory scan reads the registry once; catalog listing no longer rescans every SKILL.md; provider aliases reuse one parse; IPC list yields every ~20ms. Measured on the 600-skill / 3-copy fixture: paired p50 120ms / p95 123ms (was 1160ms), event-loop delay p95 21ms. See #1141.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions