progress.resources¶
The cores and the memory a run uses, for its progress.
The progress of a long run says what of the machine it uses: the cores it may
use (the CPUs of the process bounded by the quota of its cgroup, see
sbmlsim.cgroup), the processes it runs on, the CPU it uses, the memory of its
processes and the memory of the machine. A run which is held up by the cores
and a run which is held up by the memory then look different on the console, in
the log and in the events.
The sample is taken from /proc on linux: the stat of the process and of every
process below it gives the seconds of the CPU and the resident memory of the
tree, meminfo the memory of the machine. The pool of a run is a tree of
children, so the sample covers the workers as well, which
resource.getrusage does not: it counts a child when it ends. Without /proc
(a platform which has none) the CPU is the one of getrusage and the memory is
left out, and on a platform without resource (windows) the CPU is left out as
well, which the reporters leave out of their text.
The sample costs a scan of /proc, so it is taken at most every second and
every reporter of a process takes the same one, see SAMPLER.
Resources
dataclass
¶
What of the machine a run uses.
Attributes:
| Name | Type | Description |
|---|---|---|
cores |
int
|
the cores the run may use. |
workers |
int | None
|
the processes it runs on, |
cpu_percent |
float | None
|
the CPU it used since the sample before, in percent of a
core, |
rss |
int | None
|
the resident bytes of its processes, |
memory_used |
int | None
|
the bytes of the memory of the machine which are used,
|
memory_total |
int | None
|
the bytes of the memory of the machine, |
Sampler
¶
The samples of the resources of a process, one per interval.
Attributes:
| Name | Type | Description |
|---|---|---|
sample_ |
Resources | None
|
the sample of the interval which runs, |
Create the sampler without a sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
now
|
object
|
the monotonic clock, for the tests. |
_now
|
sample
¶
Get what of the machine the run uses, at most one sample per interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workers
|
int | None
|
the processes the run runs on, for the text of the sample. |
None
|
interval
|
float
|
the seconds a sample is kept before the next one is taken. |
INTERVAL
|
Returns:
| Type | Description |
|---|---|
Resources
|
The sample, the one of the interval which runs if it is young |
Resources
|
enough. |