Skip to content

Avoid isValidPath(), use queryPathInfo() instead#157

Merged
edolstra merged 2 commits intodetsys-mainfrom
improve-path-info-caching
Jul 28, 2025
Merged

Avoid isValidPath(), use queryPathInfo() instead#157
edolstra merged 2 commits intodetsys-mainfrom
improve-path-info-caching

Conversation

@edolstra
Copy link
Collaborator

Motivation

Since recently we call isValidPath() a lot from the evaluator, specifically from LocalStoreAccessor::requireStoreObject(). Unfortunately, isValidPath() uses but does not populate the in-memory path info cache; only queryPathInfo() does that. So isValidPath() is fast if we happened to call queryPathInfo() on the same path previously. This is not the case when lazy-trees is enabled, so we got a lot of superfluous, high-latency calls to the daemon (which show up in verbose output as performing daemon worker op: 1).

Similarly, fetchToStore() called isValidPath() as well.

The fix is to use queryPathInfo(), which for one particular eval reduced the number of daemon calls from 15246 to 2324. This may cause Nix to fetch some unnecessary information from the daemon, but that probably doesn't matter much given the high latency.

Context

Since recently we call isValidPath() a lot from the evaluator,
specifically from
LocalStoreAccessor::requireStoreObject(). Unfortunately, isValidPath()
uses but does not populate the in-memory path info cache; only
queryPathInfo() does that. So isValidPath() is fast *if* we happened
to call queryPathInfo() on the same path previously. This is not the
case when lazy-trees is enabled, so we got a lot of superfluous,
high-latency calls to the daemon (which show up in verbose output as
`performing daemon worker op: 1`).

Similarly, `fetchToStore()` called `isValidPath()` as well.

The fix is to use `queryPathInfo()`, which for one particular eval
reduced the number of daemon calls from 15246 to 2324. This may cause
Nix to fetch some unnecessary information from the daemon, but that
probably doesn't matter much given the high latency.
@github-actions
Copy link

github-actions bot commented Jul 21, 2025

@github-actions github-actions bot temporarily deployed to pull request July 21, 2025 18:03 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 23, 2025 11:49 Inactive
@edolstra edolstra added this pull request to the merge queue Jul 28, 2025
Merged via the queue into detsys-main with commit c9467a6 Jul 28, 2025
33 checks passed
@edolstra edolstra deleted the improve-path-info-caching branch July 28, 2025 15:38
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.

2 participants