Performance Config
GitHub Link to Code.
Performance configuration for PipelineManager.
This module defines a small configuration container that triggers a callback whenever its values change. PipelineManager uses it to re-apply process-level resource limits when the user edits pipeline.config.performance at runtime.
- class mdxplain.pipeline.manager.performance_config.PerformanceConfig(defaults: Dict[str, Any], on_change: Callable[[], None] | None = None)
Mutable performance settings that apply process limits on change.
The configuration stores process-level tuning knobs such as CPU priority, I/O priority, CPU affinity, and BLAS/OpenMP thread limits. It does not apply any settings by itself; instead it calls a provided callback whenever one of its fields changes. This keeps the configuration lightweight while allowing PipelineManager to centralize the actual resource management.
Fields
- auto_resource_limitsbool
If True, compute a recommended CPU affinity based on reserve_cores and apply process-level limits when configuration changes.
- reserve_coresint
Number of CPU cores to keep free when auto_resource_limits is enabled.
- resource_niceint or None
POSIX nice value (or Windows priority mapping). None means “do not set”.
- resource_io_prioritystr or None
I/O priority hint (“idle”, “low”, “normal”, “high”). None means “do not set”.
- resource_cpu_affinitysequence of int or None
Explicit CPU affinity list. When set, it overrides auto selection.
- auto_blas_thread_limitbool
If True, cap BLAS/OpenMP threads to the active CPU set size.
- __init__(defaults: Dict[str, Any], on_change: Callable[[], None] | None = None) None
Create a performance configuration with explicit defaults.
Parameters
- defaultsdict
Mapping from field name to initial value. All fields must be provided so that pipeline.config.performance has a complete set of tunables visible to the user.
- on_changecallable, optional
Callback invoked after a value changes. PipelineManager passes a function that re-applies resource limits based on this config.
Returns
- None
Creates a configuration object with defaults applied.
- update(**kwargs: Any) None
Update multiple fields and apply once.
This helper avoids repeated re-application when several settings are changed together. It validates field names and triggers the callback only once after all updates are applied.
Parameters
- kwargs
Field names and values to update.
Returns
- None
Applies all updates and triggers a single on_change callback.