Skip to content

Commit 3f3513f

Browse files
edolstraclaude
andcommitted
binary cache: add use-bloom-filter setting (default true)
Lets a client opt out of consulting a cache's advertised Bloom filter. isDefinitelyMissing bails out early when it's false. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c107b50 commit 3f3513f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/libstore/binary-cache-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bool BinaryCacheStore::fetchBloomFilter(const std::string & uri)
140140

141141
bool BinaryCacheStore::isDefinitelyMissing(const StorePath & storePath) noexcept
142142
{
143-
if (!diskCache || !bloomFilterUrl)
143+
if (!diskCache || !bloomFilterUrl || !config.useBloomFilter)
144144
return false;
145145

146146
const auto uri = config.getReference().render(/*withParams=*/false);

src/libstore/include/nix/store/binary-cache-store.hh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ struct BinaryCacheStoreConfig : virtual StoreConfig
6868
The meaning and accepted values depend on the compression method selected.
6969
`-1` specifies that the default compression level should be used.
7070
)"};
71+
72+
Setting<bool> useBloomFilter{
73+
this,
74+
true,
75+
"use-bloom-filter",
76+
R"(
77+
Whether to use the Bloom filter advertised by this binary cache (if
78+
any) to avoid querying `.narinfo` files for store paths that are
79+
definitely not in the cache. Set to `false` to disable this
80+
optimization.
81+
)"};
7182
};
7283

7384
/**

0 commit comments

Comments
 (0)