Skip to main content

Crate secs_compute

Crate secs_compute 

Source
Expand description

Resource rules for heavy computation.

One place for what every expensive job must obey:

  • Memory budget. A job estimates its bytes and takes a weighted permit before it allocates; a single job larger than the budget is refused up front with the reason, instead of exhausting RAM halfway.
  • Threads. A rayon pool sized by cores and budget. Parallel work is map only; floating-point accumulation runs in its original order, so results do not depend on the thread count.
  • Cancellation and progress. A cooperative cancel token checked at stage, channel, input and iteration boundaries, and a progress sink that reports stage, done/total and an ETA from the observed rate.

The available-memory probe is a seam (MemoryProbe): the app injects the OS adapter from secs-sys; tests inject a fixed value.

Structs§

CancelToken
Cooperative cancellation shared by a job and everything it starts.
Cancelled
A computation was cooperatively cancelled.
Context
Cancellation, progress, threads and memory available to one heavy job.
FixedMemory
A fixed memory reading, useful for tests and deterministic callers.
MemoryBudget
A weighted byte budget shared by concurrent work.
MemoryPermit
A byte reservation which releases itself on drop.
NoProgress
A sink that drops every progress report.
Progress
One progress report.
StageProgress
Progress tracker for one stage.

Enums§

MapError
Failure from an ordered fallible map.
MemoryError
Failure to reserve bytes from a MemoryBudget.

Traits§

MemoryProbe
Reports the memory currently available to the process.
ProgressSink
Destination for progress reports.