bencher.worker_job
Classes
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 ``WorkerJobwith unset hashes is unrepresentable (plan 23 P5, C8). They used to be fourNone-default fields filled by asetup_hashes()method every constructor site had to remember to call – two-phase init, with nothing preventing caching under aNonejob key.Picklability is preserved and pinned by
test/test_multiprocessing_executor.py, though not because aWorkerJobcrosses a process boundary – it does not. OnlyJob(function +job_args) is sent to an executor (bencher.py’s submit loop); aWorkerJobis 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, becausehash_sha1is 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_hashand deliberately not folded in here.