bencher.worker_job

Classes

WorkerJob

Represents a benchmark worker job with input variables and caching information.

Module Contents

class bencher.worker_job.WorkerJob

Represents a benchmark worker job with input variables and caching information.

This class encapsulates the information needed to execute a benchmark function, including input variables, dimension information, and caching metadata. It handles the preparation of function inputs and calculation of hash signatures for caching.

The derived inputs and hash signatures are cached_property``s computed from the constructor fields, so a ``WorkerJob with unset hashes is unrepresentable (plan 23 P5, C8). They used to be four None-default fields filled by a setup_hashes() method every constructor site had to remember to call – two-phase init, with nothing preventing caching under a None job key.

Picklability is preserved and pinned by test/test_multiprocessing_executor.py, though not because a WorkerJob crosses a process boundary – it does not. Only Job (function + job_args) is sent to an executor (bencher.py’s submit loop); a WorkerJob is built and consumed entirely in the parent process. It survives a round trip anyway: already-computed properties travel in __dict__, and ones not yet accessed recompute on demand, deterministically, because hash_sha1 is content-based.

function_input_vars

The values of the input variables to pass to the function

Type:

list

index_tuple

The indices of these values in the N-dimensional result array

Type:

tuple[int]

dims_name

The names of the input dimensions

Type:

list[str]

constant_inputs

Dictionary of any constant input values

Type:

dict | None

bench_cfg_sample_hash

Hash of the benchmark configuration without repeats

Type:

str

tag

Tag for grouping related jobs

Type:

str

function_input_vars: list[Any]
index_tuple: tuple[int, ...]
dims_name: list[str]
constant_inputs: dict | None
bench_cfg_sample_hash: str
tag: str
property canonical_input: tuple[Any, ...]

Canonical representation of the swept inputs, used as a holomap key.

Computed from the swept dimensions only – constant inputs are deliberately excluded (they are merged into function_input, not here).

property function_input: dict

Complete input as a dictionary with dimension names as keys.

property fn_inputs_sorted: list[tuple[str, Any]]

Sorted representation of the function inputs.

property function_input_signature_pure: str

Hash of the function inputs and tag.

The signature is the hash of the inputs to the function + meta variables such as repeat and time. The hash of the benchmark sweep as a whole (without the repeats hash) is kept separately in bench_cfg_sample_hash and deliberately not folded in here.