Skip to content

Binary cache info#493

Merged
edolstra merged 2 commits into
mainfrom
binary-cache-info
Jun 10, 2026
Merged

Binary cache info#493
edolstra merged 2 commits into
mainfrom
binary-cache-info

Conversation

@edolstra

@edolstra edolstra commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Motivation

This deduplicates the Cache and CacheInfo types, and makes NarInfoDiskCache::createCache() take a CacheInfo instead of a bunch of separate arguments. This makes it easier to add new nix-cache-info fields in the future.

Upstream NixOS#16006.

Context

Summary by CodeRabbit

  • Refactor
    • Refactored cache creation API to use structured parameter passing with named fields for improved code clarity and maintainability.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ebe05558-27c3-4f1f-a142-e6e6a7d03389

📥 Commits

Reviewing files that changed from the base of the PR and between 7b09aba and d94497a.

📒 Files selected for processing (4)
  • src/libstore-tests/nar-info-disk-cache.cc
  • src/libstore/http-binary-cache-store.cc
  • src/libstore/include/nix/store/nar-info-disk-cache.hh
  • src/libstore/nar-info-disk-cache.cc

📝 Walkthrough

Walkthrough

The PR refactors NarInfoDiskCache to consolidate cache configuration parameters into a CacheInfo struct. The header updates the createCache signature and struct definition with default values, the implementation restructures the internal Cache layout and factory methods, all storage operations now access the nested cache.info.id, and all call sites (tests and HTTP store) pass the new struct format.

Changes

NarInfoDiskCache struct-based parameter passing

Layer / File(s) Summary
API contract: CacheInfo struct and createCache signature
src/libstore/include/nix/store/nar-info-disk-cache.hh
CacheInfo struct gains default-initialized fields (id = 0, wantMassQuery = false, priority = 0), and createCache signature changes to accept const CacheInfo & info instead of separate wantMassQuery and priority parameters. Documentation clarifies that info.id is ignored and the returned value is the cache entry id.
Internal Cache structure and factory methods
src/libstore/nar-info-disk-cache.cc
Cache struct refactored to store storeDir and an embedded CacheInfo object. createCache implementation updated to consume CacheInfo, return existing cache id via cache->info.id, and write back the inserted DB id into ret.info.id. queryCacheRaw and upToDateCacheExists likewise updated to construct and return CacheInfo-based structures.
Storage operation updates to use cache.info.id
src/libstore/nar-info-disk-cache.cc
All NAR and realisation lookup and upsert operations (lookupNarInfo, lookupRealisation, upsertNarInfo, upsertRealisation, upsertAbsentRealisation) updated to access cache id via cache.info.id instead of the former flat cache.id.
Test and HTTP cache store call sites
src/libstore-tests/nar-info-disk-cache.cc, src/libstore/http-binary-cache-store.cc
Test cases and HTTP binary cache store initialization call createCache with the new struct format, passing wantMassQuery and priority as named fields within a CacheInfo initializer instead of positional arguments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • cole-h

Poem

A rabbit's refactor, tidy and neat,
Takes scattered cache flags to make the design complete,
One struct to hold them all, clean as can be,
From test to storage, a cohesive spree. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The pull request title 'Binary cache info' is vague and does not clearly describe the main structural change—refactoring cache creation to use a CacheInfo struct for parameters. Consider a more specific title such as 'Refactor NarInfoDiskCache to use CacheInfo struct' or 'Deduplicate Cache and CacheInfo types in binary cache' to better convey the primary change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch binary-cache-info

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/libstore-tests/nar-info-disk-cache.cc

src/libstore-tests/nar-info-disk-cache.cc:1:10: fatal error: 'nix/store/nar-info-disk-cache.hh' file not found
1 | #include "nix/store/nar-info-disk-cache.hh"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
src/libstore-tests/nar-info-disk-cache.cc:12:1-127:1: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'nix::TEST' in file 'src/libstore-tests/nar-info-disk-cache.cc': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/l

... [truncated 2200 characters] ...

decl.CFrontend_decl_funct.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.function_decl in file "src/clang/cFrontend_decl.ml", line 90, characters 12-151
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.translate_one_declaration in file "src/clang/cFrontend_decl.ml", line 453, characters 10-56
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.translate_one_declaration.translate in file "src/clang/cFrontend_decl.ml" (inlined), line 448, characters 24-96
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Called from Base__List0.iter in file "src/li

src/libstore/http-binary-cache-store.cc

src/libstore/http-binary-cache-store.cc:1:10: fatal error: 'nix/store/http-binary-cache-store.hh' file not found
1 | #include "nix/store/http-binary-cache-store.hh"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/d94497aa0a97aac4e415afeb81784be60242cf73-ed501ff79c430470/tmp/clang_command_.tmp.1a8a10.txt
++Contents of '/tmp/coderabbit-infer/d94497aa0a97aac4e415afeb81784be60242cf73-ed501ff79c430470/tmp/clang_command_.tmp.1a8a10.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1"

... [truncated 1174 characters] ...

clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/ed501ff79c430470/file.o" "-x" "c++"
"src/libstore/http-binary-cache-store.cc" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

src/libstore/nar-info-disk-cache.cc

src/libstore/nar-info-disk-cache.cc:1:10: fatal error: 'nix/store/nar-info-disk-cache.hh' file not found
1 | #include "nix/store/nar-info-disk-cache.hh"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
src/libstore/nar-info-disk-cache.cc:89:5-169:5: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'nix::NarInfoDiskCacheImpl::NarInfoDiskCacheImpl' in file 'src/libstore/nar-info-disk-cache.cc': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map

... [truncated 2200 characters] ...

Frontend__CFrontend_decl.CFrontend_decl_funct.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl.add_method_if_create_procdesc in file "src/clang/cFrontend_decl.ml" (inlined), line 123, characters 16-158
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl in file "src/clang/cFrontend_decl.ml", line 126, characters 17-97
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_methods in file "src/clang/cFrontend_decl.ml" (inlined), line 270, characters 8-122
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Cal


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request June 10, 2026 17:07 Inactive
@edolstra edolstra added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit f195f8d Jun 10, 2026
30 checks passed
@edolstra edolstra deleted the binary-cache-info branch June 10, 2026 18:02
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