Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/styles/config/vocabularies/TraceMachina/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ deserialization
Dockerised
Merkle
subtree
subtrees
hardlink
multiplicatively
SELinux
Expand Down
36 changes: 36 additions & 0 deletions nativelink-config/src/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,42 @@ pub struct LocalWorkerConfig {
#[serde(default)]
pub experimental_active_input_leases: bool,

/// Reuse immutable input directories through read-only bind mounts on Linux.
/// The worker prepares each selected subtree once per REAPI `Directory`
/// digest in the directory cache, then mounts it into each action instead of
/// recreating its filesystem entries.
///
/// Paths are relative to the action input root, for example `["out/x/sdk"]`.
/// They must be nonempty, canonical, and non-overlapping. Absolute paths,
/// empty path components, and `.`/`..` components are rejected.
/// Requires `directory_cache`, `use_namespaces: true`, and
/// `use_mount_namespace: true`.
///
/// Actions declaring overlapping outputs, working inside a selected subtree,
/// or using a persistent worker fall back to ordinary materialization.
/// Output paths reached through symlink aliases cannot be checked for
/// overlap. Use this only with trusted workloads that do not modify the
/// selected trees; read-only input mounts are not a security boundary.
///
/// Select trees whose contents (and Directory digest) are reused across
/// many actions. Trees that change per action add cache construction work
/// without reuse. When mounts apply, other inputs use ordinary downloads,
/// bypassing both root and subtree directory caching for that action.
/// Failed mount preparation retries once without mounts; a failed mount
/// syscall still aborts the action before its command runs.
///
/// An action can remount its inputs writable in its own user namespace
/// and corrupt the shared cache. Later actions can then produce incorrect
/// results from those inputs. Enable only for trusted commands.
///
/// Cache entries remain pinned until action cleanup and may temporarily
/// exceed the cache's eviction budget. Pinned bytes have no separate limit,
/// so concurrent distinct trees can exhaust the disk. Leave headroom.
///
/// Default: [] (disabled)
#[serde(default)]
pub experimental_readonly_input_mounts: Vec<String>,

/// Whether to use namespaces to isolate the execution. This is only available
/// on Linux. It is highly recommended as it avoids a number of issues with
/// zombie processes and also provides additional hermeticity. If explicitly set
Expand Down
2 changes: 1 addition & 1 deletion nativelink-config/src/schedulers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ pub struct SimpleSpec {
/// operation from the store, on every scheduler replica: with a shared
/// Redis that is a full index read per interval per replica, which is
/// why it is off unless asked for. Turn it on for a look, not for good.
/// Defaults to -1 (disabled). Any positive value enables it.
/// Defaults to `-1` (disabled). Any positive value enables it.
#[serde(
default = "default_worker_match_logging_interval_s",
deserialize_with = "convert_duration_with_shellexpand_and_negative"
Expand Down
37 changes: 37 additions & 0 deletions nativelink-util/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,43 @@ pub fn execution_output_bytes(action_result: &ActionResult) -> u64 {
+ action_result.stderr_digest.size_bytes()
}

/// Input mount counters, emitted by workers rather than schedulers.
pub static INPUT_MOUNT_METRICS: LazyLock<InputMountMetrics> = LazyLock::new(|| {
let meter = global::meter_with_scope(InstrumentationScope::builder("nativelink").build());
InputMountMetrics {
cache_hits: meter
.u64_counter("worker.input_mount.cache_hits")
.with_description("Cached directories reused for input mount preparation")
.build(),
cache_misses: meter
.u64_counter("worker.input_mount.cache_misses")
.with_description("Input mount directories requiring cache construction")
.build(),
fallbacks: meter
.u64_counter("worker.input_mount.fallbacks")
.with_description(
"Actions using ordinary input preparation despite configured input mounts",
)
.build(),
prepare_failures: meter
.u64_counter("worker.input_mount.prepare_failures")
.with_description("Failed input mount preparations retried without mounts")
.build(),
}
});

#[derive(Debug)]
pub struct InputMountMetrics {
/// Cached directories reused for input mount preparation.
pub cache_hits: metrics::Counter<u64>,
/// Input mount directories requiring cache construction.
pub cache_misses: metrics::Counter<u64>,
/// Actions using ordinary input preparation despite configured input mounts.
pub fallbacks: metrics::Counter<u64>,
/// Failed input mount preparations retried without mounts.
pub prepare_failures: metrics::Counter<u64>,
}

/// Global worker fleet metrics instruments.
pub static WORKER_METRICS: LazyLock<WorkerMetrics> = LazyLock::new(|| {
let meter = global::meter_with_scope(InstrumentationScope::builder("nativelink").build());
Expand Down
1 change: 1 addition & 0 deletions nativelink-worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rust_library(
"src/buck2_file_capture.rs",
"src/capacity.rs",
"src/directory_cache.rs",
"src/input_mounts.rs",
"src/lib.rs",
"src/local_worker.rs",
"src/persistent_worker/live_worker.rs",
Expand Down
Loading
Loading