Skip to content

Conda: find() wipes the env cache on every call, defeating cross-refresh reuse #476

@eleanorjboyd

Description

@eleanorjboyd

Problem

Conda::find calls self.clear() at the top of every invocation, wiping environments, managers, and mamba_managers. Every full refresh then rebuilds everything from scratch — including re-reading each env's conda-meta/history, re-running per-env package detection, and re-resolving the conda install for each env.

The Arc<LocatorCache<PathBuf, PythonEnvironment>> on the struct suggests the cache is meant to live across calls, but in practice it never does because of the clear-on-find. For installs with many envs this is the dominant cost on every refresh.

Proposal

Apply the mtime-keyed cache pattern from #469 (Hatch TOML parse cache). Cache CondaEnvironment entries keyed on the prefix plus the relevant conda-meta/* mtimes (history file, and/or conda-meta directory mtime). On find(), stat the keying paths first; if mtimes are unchanged, reuse the cached entry. Cold path is unchanged; warm path becomes stat-only.

This is independent of and bigger than #475 (in-flight memoization within a single find() — filed separately). The two are complementary: the memoization fix dedupes reads inside one call; this one skips work across calls.

Related: #469 (same pattern for Hatch).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions