clean
This document provides an overview of the commands and options available under buck2 clean.
buck2 clean
Delete generated files and caches.
The command also kills the buck2 daemon.
Under daemon sharing (buck2.share_daemon), it evicts the selected tenant from the shared daemon instead.
Usage: buck2 clean [OPTIONS]
Common Options:
Common options are documented on the Common Options page.
Options:
-
--dry-runPerforms a dry-run and prints the paths that would be removed. -
--backgroundRun the clean operation in the background -
-m, --modifier <VALUE>This option is not used -
--stale <DURATION>Delete artifacts from buck-out using the configured clean-stale policy or a duration if specified, without killing the daemon -
--tracked-onlyOnly considers tracked artifacts for cleanup.buck-outcan contain untracked artifacts for different reasons: - Outputs from aborted actions - State getting deleted (e.g., new buckversion that changes the on-disk state format) - Writing tobuck-outwithout being expected by Buck -
--adaptive-low-disk-threshold <PERCENT>Enable adaptive low-disk promotion: after the regular stale scan, promote retained, non-active artifacts (oldest-access first) to stale until projected free disk % rises above this threshold (0.0 - 100.0) -
--adaptive-min-ttl <DURATION>Minimum TTL floor for adaptive low-disk promotion: retained artifacts accessed within this duration of now are never promoted, even under disk pressure. Ignored unless--adaptive-low-disk-thresholdis set- Default value:
12h
- Default value:
-
--adaptive-unmaterialize-activeAllow adaptive cleaning to unmaterialize active remote-backed intermediate artifacts as a final escalation step -
--disable-starlark-typesDisable runtime type checking in Starlark interpreter.This option is not stable, and can be used only locally to diagnose evaluation performance problems.
-
--stackRecord or show target call stacks.Starlark call stacks will be included in duplicate targets error.
If a command outputs targets (like
targetscommand), starlark call stacks will be printed after the targets. -
--profile-patterns <PROFILE_PATTERNS>Enables profiling for all evaluations whose evaluation identifier matches one of the provided patterns.Some examples identifiers: analysis/cell//buck2/app/buck2_action_impl:buck2_action_impl (cfg:linux-x86_64#27ac5723e0c99706) load/cell//build_defs/json.bzl load/prelude//playground/test.bxl load_buildfile/fbcode//third-party-buck/platform010/build/ncurses load_packagefile/fbcode//cli/rust/cli_delegate anon_analysis/anon//:_anon_link_rule (anon: 766183dc9b6f680a) (fbcode//buck2/platform/execution:linux-x86_64#08961b14cfb182aa) bxl/prelude//playground/test.bxl:playground
You can pass
--profile-patterns=.*to enable no-op profiling for everything (additionally pass--profile-patterns-mode=noneto use no-op profiling to just get a list of all the identifiers).The profile results will be written to individual .profile files in
<ROOT_OUTPUT>/<data+time>-<uuid>/where ROOT_OUTPUT comes from the --profile-patterns-output flag. In that directory there will also be a file listing all the identifiers that were profiled.Switching between no profiling and
--profile-patternsinvalidates every cached Starlark evaluation (loads, analyses, BXL); later commands redo the ones they need. Changing the patterns between two commands that pass it invalidates only the evaluations whose profiling changes. In some cases this will cause other work to also need to be redone (for example, invalidating the result of loading PACKAGE files causes all consumers to be recomputed). But if you keep profiling options consistent between commands, only the work that is otherwise invalidated will be redone (and only for those would profiling results be created).You must also pass --profile-patterns-mode and --profile-patterns-output.
-
--profile-patterns-output <PATH> -
--profile-patterns-mode <PROFILE_PATTERNS_MODE>Profile mode.Memory profiling modes have suffixes either
-allocatedor-retained.-retainedmeans memory kept in frozen starlark heaps after analysis completes.-retaineddoes not work when profiling loading, because no memory is retained after loading and frozen heap is not even created. This is probably what you want when profiling analysis.-allocatedmeans allocated memory, including memory which is later garbage collected.- Possible values:
time-flameheap-allocatedheap-retainedheap-flame-allocatedheap-flame-retainedheap-summary-allocatedheap-summary-retainedstatementbytecodebytecode-pairstypecheckcoveragenone
- Possible values: