Skip to main content

Settings

Struct Settings 

Source
pub struct Settings {
    pub env_deny: Vec<String>,
    pub env_allow: Vec<String>,
    pub gate_pct: f64,
    pub accept_trailers: bool,
    pub gate_min_delta: u64,
    pub allow_empty: bool,
    pub credit: bool,
    pub runner_class: String,
}
Expand description

Every setting tak supports, resolved.

PartialEq but not Eq: a float setting has no total equality.

Fields§

§env_deny: Vec<String>

Environment variables removed from every command tak measures.

Two reasons this defaults to a non-empty list rather than to nothing.

Determinism. A CLI that finds a forge token in its environment often does more with it than without — authenticating, fetching, checking rate limits. A measurement that moves depending on whether CI happened to export a token is not a measurement of the code under test. It lands in the series as an unexplained step change on the day someone edits an unrelated workflow.

This is not a credential sandbox. The listed variables are absent from the child’s direct environment, but a hostile binary can still inspect accessible same-user processes and files. In particular, tak backfill downloads and executes release binaries; run it on an isolated credential-free machine when those assets are not fully trusted.

Setting this replaces the default list rather than adding to it. To keep the defaults and remove more, list them alongside. To keep the defaults and remove fewer, use env_allow — it is subtracted from this list, so the two compose without either having to restate the other.

Names are matched exactly. There is no globbing: a benchmark whose behaviour depends on which variables happen to match a pattern is the problem this setting exists to avoid.

tak’s own network calls are unaffected. backfill authenticates with curl directly rather than through the measurement path.

§env_allow: Vec<String>

Environment variables kept even though env_deny lists them.

Subtracted from env_deny, so a project can opt one variable back in without restating the whole default list. A CLI whose measured path genuinely requires a token — a client that cannot start unauthenticated, say — needs this.

Doing so makes the measurement depend on something outside the repository. That is a real cost, not a formality: the numbers become conditional on the environment the run happened to have, and a token expiring will read as a performance change.

Listing a variable here that env_deny does not mention has no effect. This setting removes entries from the deny list; it does not add anything to the environment.

§gate_pct: f64

How much an instruction count may rise before tak compare or tak detect fails.

A percentage of the base measurement. Only instruction counts are gated. Wall clock is reported and never gated: on the same hardware it moves 4-20% run to run, so a threshold tight enough to catch a real regression would fire constantly, and one loose enough to stay quiet would catch nothing.

The default of 1% is about fifty times the ~0.02% instruction counting reproduces to, leaving room for the small differences a compiler or dependency bump can produce without turning the gate into noise.

Raise it to report without effectively failing. Setting it to zero fails on any increase at all, which sounds appealing and is not: one extra instruction on a startup path is not worth blocking a pull request over.

This is the gate for every series without its own. A benchmark or subject can set one with gate = { pct = N } in tak.toml, and that wins over this setting from any source, --gate-pct included: the flag moves the default, not the benchmarks a project has singled out.

§accept_trailers: bool

Whether tak compare and tak detect honour Tak-Accept: trailers on the commits they compare.

Off by default, because of who writes those trailers. A trailer is part of a commit message, and the commits tak compare reads are the change being gated — on a pull request, the author’s own. Honouring them by default would let any change waive its own gate by adding one line, which makes the gate advisory for exactly the changes it exists to stop. The acceptance would be visible in the report, but visible is not the same as approved.

With this off, trailers are ignored entirely; if the compared range carries any, the report says so in one line, so an author is not left wondering why theirs did nothing. tak compare --accept BENCH works either way, and is the recommended route in CI: pass it from a workflow step driven by something only maintainers can do, such as applying a pull-request label.

Turn it on where every commit in the compared range has already been reviewed by the time the result matters, or where everyone who can push is trusted to waive the gate — a solo project, or comparisons along an already-reviewed main branch.

tak compare reads this key, like the rest of its gate, from the base revision’s tak.toml rather than the checkout being measured, so a pull request cannot turn trailers on for itself; turning them on takes effect once that change is merged. tak detect reads the working tree’s, which on a main-branch run is merged history. The environment takes precedence over either file.

§gate_min_delta: u64

How many instructions a count may rise by before tak compare or tak detect fails, whatever the percentage.

A regression has to exceed both this and gate_pct. A percentage alone serves small benchmarks badly: on a 450k-instruction startup check, 1% is 4,500 instructions, which one new dependency’s relocations in the dynamic loader can account for before main runs. A floor lets such a benchmark keep a tight percentage without failing on a handful of instructions.

The default of 0 means no floor: any rise beyond gate_pct fails. A benchmark or subject can set its own with gate = { min_delta = N } in tak.toml.

§allow_empty: bool

Whether a comparison that compared nothing passes, with a warning, instead of failing.

Applies to tak compare, tak detect and tak run --baseline --gate: the case where no series was measured on both sides, so the gate had nothing to check. Off by default, because a gate that passed without running reads exactly like one that ran clean, and the causes nobody notices — a base never recorded, notes never fetched, a recording that stopped producing instruction counts — are the ones a green check hides.

Turn it on where comparing nothing is routine rather than a symptom: a runner class that encodes an image or toolchain version, so every update starts a new series and the first comparison after it has no base; or a project still adopting, whose pull requests branch from commits measured before tak was. With it on, those runs exit successfully, the report says allow_empty let them through, and a warning goes to stderr — as a ::warning:: annotation under GitHub Actions.

The cost is that the broken causes above warn as well instead of failing. Only the empty case is waived: a regression still fails, and so do a failed check and a failed instruction count against a baseline.

--allow-empty turns it on for one run, and TAK_ALLOW_EMPTY=0 off. Like the rest of its gate, tak compare reads it from the base revision’s tak.toml, so a pull request cannot waive its own empty comparison; turning it on takes effect once the change is merged. tak detect and tak run --baseline read the working tree’s.

§credit: bool

Whether generated reports end with a line naming tak.

On by default. A report that appears in someone’s pull request should say what put it there — a reader who has never heard of tak needs a way to find out, and a maintainer evaluating the comment needs to know what to turn off.

Turn it off with --no-credit, TAK_CREDIT=0, or credit = false under [report]. Nothing else about the report changes.

§runner_class: String

The machine class a measurement is recorded under, and compared within.

Empty means derive it: gha-<os>-<arch> under GitHub Actions, local-<os>-<arch> otherwise. That is right until something about the machine changes without the name changing.

Series are partitioned on this, and must be. Absolute instruction counts shift between machine types by more than a real regression does, so tak will not compare across classes — it reports the old series as removed and the new one as added rather than inventing a step change.

Set it when the environment changes in a way the derived name cannot see. The common case is a toolchain bump: a hosted runner image or a compiler upgrade between the base measurement and this one is attributed to the code otherwise, and on a one-percent gate that is a false failure. Encoding the compiler version into the class starts a fresh series at the bump, which is honest — the numbers either side genuinely are not comparable.

tak cannot detect this for you. It measures programs, not build systems, and has no way to know what produced the binary it is timing.

Implementations§

Source§

impl Settings

Source

pub const SETTINGS_PROPS: &'static [PropMeta] = <Self as ::usage_rs::config::Props>::PROPS

Every setting this struct declares, one entry per field, flattened groups included. The registry a build.rs used to generate, generated from the struct instead — there is no second declaration to keep in step.

Source

pub const SETTINGS_REGISTRY: Registry

The registry over Self::SETTINGS_PROPS, for resolve, drift, and the layers.

Source

pub const SETTINGS_SPEC: ConfigSpec

Metadata used only when lowering this declaration into a usage spec.

Source

pub fn read(__usage_resolved: &Resolved) -> Result<Self, ReadErrors>

This resolution’s values, as the struct.

Every field is read before anything is returned, so the error is the whole list of what is wrong rather than the first thing found.

Source

pub fn read_lossy(__usage_resolved: &Resolved) -> (Option<Self>, ReadErrors)

This resolution’s values, keeping every setting that reads.

Self::read is all or nothing, which leaves a CLI two moves when one field is bad: refuse to start, or fall back to a struct of declared defaults and lose the environment and every config file along with the offending value. Neither is a choice this crate should be making.

So: a field that will not read falls back to its own declared default and the rest keep what the merge gave them, with every failure returned alongside for the CLI to raise, log, or ignore as it sees fit. The errors are the same [::usage_config::ReadError]s Self::read returns, so a caller that decides a bad value is fatal has lost nothing by asking.

None only where a setting has no value and no declared default — a hole in the declaration rather than a bad value, and nothing to fall back to.

Source

pub fn spec_kdl() -> String

The spec config block for these settings, as KDL.

What documents, JSON schema and completions read. A CLI deriving usage::Cli names this type in #[usage(config = ...)] instead of calling this, and its to_kdl carries the block.

Source§

impl Settings

Source

pub fn resolve( cli: &CliLayer, env: &EnvLayer, config: &TakConfigLayer, ) -> Result<Self>

Resolve every setting from the given layers, highest precedence first.

Source

pub fn from_process(cli: &CliLayer) -> Result<Self>

Resolve against the real process environment and the tak.toml found upward from the current directory.

Source

pub fn from_process_at(cli: &CliLayer, config: Option<&Path>) -> Result<Self>

As Self::from_process, reading config instead of searching for tak.toml when one is given.

Source

pub fn display_value(&self, name: &str) -> Option<String>

The value of a setting, by its registry key.

Exists so display code cannot silently omit a setting: SETTINGS_PROPS is generated, so a new entry appears in tak settings whether or not anything can produce its value. A test asserts this returns Some for every registry entry, which turns “added a setting, forgot the accessor” into a build failure instead of a blank row.

Source

pub fn scrubbed_env(&self) -> impl Iterator<Item = &str>

Variables to remove from a benchmark subject: denied, less allowed.

Allow subtracts from deny rather than sitting beside it, so opting one variable back in does not mean restating the whole default list.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Settings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Settings

Source§

fn default() -> Self

The declared defaults, read the same way any other resolution is.

Source§

impl PartialEq for Settings

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Props for Settings

Source§

const PROPS: &'static [PropMeta]

This group’s settings, in declaration order. Read more
Source§

const PROP_SPECS: &'static [PropSpec]

Spec-only metadata parallel to Props::PROPS.
Source§

impl StructuralPartialEq for Settings

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.