diff options
author | Florian Klink <flokli@flokli.de> | 2024-11-09T15·45+0000 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-11-12T00·26+0000 |
commit | 85de9b8dabfcbe169e3c5f6d33c1f2b60d56176d (patch) | |
tree | 74af32ad51e30e6aebc43c90381505cb1e8db6ca /tvix/nar-bridge/src/lib.rs | |
parent | 8400e523ceaa143c107f51e321263268d1048d7c (diff) |
feat(tvix/nar-bridge): avoid unnecessary NAR uploads r/8904
When uploading a Store Path to a Nix HTTP Binary Cache, Nix first does a HEAD request for $outhash.narinfo, and if that's not found, for `{narhash}.nar[.compression_suffix]`. If the NAR is already present, only the NARInfo is uploaded. Even though we don't have a service allowing to globally look up from NARHash to root node, `root_nodes` in `AppState` at least contains recently uploaded NARHashes. If we find it in there, we can prevent Nix unnecessarily uploading NARs if the same contents have already been recently uploaded. We also promote this key, chances are high Nix will subsequently upload a NARInfo referring to this NARHash. Change-Id: I34e3fd9b334b695abe945e64cd291e30f303c2a2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12752 Tested-by: BuildkiteCI Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com> Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nar-bridge/src/lib.rs')
-rw-r--r-- | tvix/nar-bridge/src/lib.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/tvix/nar-bridge/src/lib.rs b/tvix/nar-bridge/src/lib.rs index c4a6c8d5f2dc..9246a334c7f6 100644 --- a/tvix/nar-bridge/src/lib.rs +++ b/tvix/nar-bridge/src/lib.rs @@ -53,10 +53,8 @@ impl AppState { pub fn gen_router(priority: u64) -> Router<AppState> { Router::new() .route("/", get(root)) - // FUTUREWORK: respond for NARs that we still have in root_nodes (at least HEAD) - // This avoids some unnecessary NAR uploading from multiple concurrent clients, and is cheap. .route("/nar/:nar_str", get(four_o_four)) - .route("/nar/:nar_str", head(four_o_four)) + .route("/nar/:nar_str", head(nar::head_root_nodes)) .route("/nar/:nar_str", put(nar::put)) .route("/nar/tvix-castore/:root_node_enc", get(nar::get_head)) .route("/nar/tvix-castore/:root_node_enc", head(nar::get_head)) |