Skip to content

perf(paths): stored_spelling lists every component on every install; skip on non-folding volumes #5432

Todo

Description

Summary

apm_cli.utils.paths.stored_spelling lists the directory at every path component, including components already spelled exactly (the part not in names check needs the listing). Since the fix for #5424 (PR #5426), deps/local_identity.stored_directory calls it on every install, on every OS, for each root and each transitive local dependency edge.

Cost

For N local packages under one directory (e.g. packages/), each lookup lists that directory and scans its N names, so one install does O(N^2) name comparisons plus one listdir per component per local edge. On case-sensitive volumes (most Linux filesystems) the work never changes the result: the exact entry always wins.

Proposed fix

Probe once per project root whether the volume folds case or Unicode normalization (for example, check whether a case-swapped spelling of the root resolves to the same directory with os.path.samefile). On a non-folding volume, return the anchored path without listing. On a folding volume, keep the current behaviour, and cache each directory listing per install.

Acceptance

  • Linux (non-folding): zero extra listdir calls per local edge, covered by a syscall-count or perf budget cell.
  • macOS and Windows: the [ci] Daily release smoke is failing #5424 cells keep passing.
  • No change to lock identity on any volume.

Out of scope for v0.39.0 (scope frozen). Relates to #5424 and #5426.

Activity

  1. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    Thanks for the detailed cost analysis. This is triaged as a performance follow-up to #5424 and #5426, and it stays on the 0.40.0 milestone. Scope will be confirmed before work starts.


    Generated by autopilot-issue-triage-worker. This comment is AI-generated and may contain errors.

  2. added
    type/performance
    status/triaged
    on Nov 25, 2026
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

    status/triagedtype/performance

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions