Skip to content

Conversation

xokdvium
Copy link
Contributor

@xokdvium xokdvium commented Sep 21, 2025

Motivation

Tested by building with b_sanitize=thread and running:

nix flake prefetch-inputs --store "dummy://?read-only=false"

It might make sense to move this utility class out of dummy-store.cc,
but it seems fine for now.

Context

Fixes #14036
Follow-up to #14023


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@xokdvium xokdvium requested a review from roberth September 21, 2025 22:17
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Sep 21, 2025

namespace nix {

inline std::size_t hash_value(const StorePath & path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think defining hash_value is unnecessary if you add

using is_avalanching = std::true_type;

to struct hash<nix::StorePath>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is unrelated:

When using a hash function directly suitable for open addressing, post-mixing can be opted out by via a dedicated hash_is_avalanchingtrait. boost::hash specializations for string types are marked as avalanching.

https://www.boost.org/doc/libs/1_85_0/libs/unordered/doc/html/unordered.html

Also this isn't really the case here.

A hash function is said to have the avalanching property if small changes in the input translate to large changes in the returned hash code

Because we just take the first 8 bytes of the hash part as the hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it doesn't help with the build anyway:

boost/container_hash/hash.hpp:537:20: error: no matching function for call to 'hash_value'
  537 |             return hash_value( val );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested by building with b_sanitize=thread and running:

nix flake prefetch-inputs --store "dummy://?read-only=false"

It might make sense to move this utility class out of dummy-store.cc,
but it seems fine for now.
This is no longer necessary.

This reverts commit 4df60e6.
@Ericson2314 Ericson2314 merged commit 5292b0e into master Sep 22, 2025
29 checks passed
@Ericson2314 Ericson2314 deleted the thread-safe-dummy branch September 22, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writable dummy store thread-safe

3 participants