solprop.driver.executors.pool#
Run bounded spawned workers with explicit threads and memory admission control.
Functions
|
Return this process's peak resident memory in bytes. |
Classes
|
Point work a pool can stop and watch (SEP 41, S4 and S17). |
|
Record the admission calculation without treating it as a hard RSS limit. |
|
The four scalars of a plane's summary, as a worker sends them to its controller. |
|
Execute independent points in memory-sized spawned processes. |
- class solprop.driver.executors.pool.ControlledWork(*args, **kwargs)[source]#
Bases:
ProtocolPoint work a pool can stop and watch (SEP 41, S4 and S17).
Optional, beside the
probeandfailurehooks: a pool runs any callable, and only work with these members is stopped through its worker’s pipe and has its run’s progress sent back. The scan’s own work implements it.- dispatched(point)[source]#
Record in the controller that a point was sent to a worker.
- Parameters:
- pointobject
The point description.
- relay(point, call, args)[source]#
Make, in the controller, a reporter call a worker sent for a point.
- Parameters:
- pointobject
The point description the worker is running.
- callstr
The reporter method: summary, started, plane, finished or interrupted.
- argstuple
Its arguments, as _WorkerReporter sends them.
- run_point(point, stop, reporter)[source]#
Run one point in a worker under a stop flag and reporter of the worker’s.
- Parameters:
- pointobject
The point description.
- stopStopFlag
Set when the controller asks the worker to stop.
- reporterProgressReporter or None
Sends the run’s calls to the controller;
Nonewhen not watched.
- Returns:
- object
The point’s result.
- class solprop.driver.executors.pool.MemoryBudget(limit, controller, per_worker, cores, threads)[source]#
Bases:
objectRecord the admission calculation without treating it as a hard RSS limit.
- Attributes:
- limitint
Effective memory allocation, bytes, positive.
- controllerint
Controller resident memory and output allowance, bytes, non-negative.
- per_workerint
Worker estimate, bytes, positive; backend RSS is counted once.
- coresint
CPUs available to this controller, positive.
- threadsint
Threads per worker, positive.
- workers(requested=None)[source]#
Choose a count within both CPU and memory allocations.
- Parameters:
- requestedint or None, optional
Optional upper bound on workers, positive.
- Returns:
- int
Admitted workers after reserving 20 percent of memory.
- Raises:
- DriverError
If inputs are invalid or one worker cannot fit.
- class solprop.driver.executors.pool.PlaneScalars(n_steps, n_rejected, max_norm, wall_time)[source]#
Bases:
objectThe four scalars of a plane’s summary, as a worker sends them to its controller.
Satisfies
solprop.log.PlaneSummary; a frozen copy rather than the backend’s own summary so that what crosses the pipe is small and always pickles.- Attributes:
- n_stepsint
Steps taken to reach the plane, accepted and rejected together.
- n_rejectedint
Rejected steps among them.
- max_normfloat
Largest scaled error norm over the accepted steps.
- wall_timefloat
Seconds the plane took, s.
Examples
>>> from solprop.log import PlaneSummary >>> isinstance(PlaneScalars(8, 0, 0.4, 0.1), PlaneSummary) True
- class solprop.driver.executors.pool.Pool(workers=None, memory_limit=None, threads=1, pin=True, fresh=False)[source]#
Bases:
objectExecute independent points in memory-sized spawned processes.
- Attributes:
- workersint or None
Positive maximum workers; None uses the CPU and memory admission rule.
- memory_limitint or None
Positive memory cap, bytes; None reads the allocation and physical memory.
- threadsint
Threads per worker, positive and one by default.
- pinbool
Pin workers within Linux CPU affinity; unavailable on macOS.
- freshbool
Start a fresh interpreter for every point instead of persistent workers.
- budgetMemoryBudget or None
Last measured admission calculation, absent before execution.
- budget: MemoryBudget | None = None#
- run(points, work)[source]#
Probe memory and run bounded work, yielding results as they finish.
Work that implements
ControlledWorkis stopped and watched through each worker’s pipe (SEP 41, S4 and S17). Once its caller’s flag is set, the pool sends every busy worker the stop message, which that worker’s run polls before every trial step, collects their results, dispatches nothing more and shuts the workers down; the abruptterminateof a worker that does not exit stays the last resort. While a watched point runs, its worker sends the run’s reporter calls, which the pool hands toControlledWork.relay().- Parameters:
- pointsiterable
Independent point descriptions with global indices.
- workcallable
Pickleable worker operation; an optional probe reports RSS and ledger.
- Yields:
- object
Results in completion order, each retaining its input identity.
- Raises:
- DriverError
If resource admission fails or a worker exits abnormally.