Output memory as KB, MB, GB. Accept memory arguments as KB, MB, GB.#14
Output memory as KB, MB, GB. Accept memory arguments as KB, MB, GB.#14ericjster wants to merge 1 commit intopshved:masterfrom
Conversation
| # Print generic information to STDERR | ||
| my $ticks = $timeinfo->{ticks_stale} || 0; | ||
| printf STDERR "${id_str}%s CPU %.2f MEM %d MAXMEM %d STALE %d MAXMEM_RSS %d\n", $reason, $timeinfo->{total}, $meminfo, $maxmem, ceil($ticks/$frequency), $maxmem_rss if ($reason ne 'FINISHED') || $info_on_success; | ||
| printf STDERR "${id_str}%s CPU %.2f MEM %d KB %d MB %d GB MAXMEM %d KB %d MB %d GB STALE %d MAXMEM_RSS %d KB %d MB %d GB\n", $reason, $timeinfo->{total}, $meminfo, $meminfo/1024, $meminfo/1024/1024, $maxmem, $maxmem/1024, $maxmem/1024/1024, ceil($ticks/$frequency), $maxmem_rss, $maxmem_rss/1024, $maxmem_rss/1024/1024 if ($reason ne 'FINISHED') || $info_on_success; |
There was a problem hiding this comment.
Please do not change the output format
There was a problem hiding this comment.
Other ppl's software might depend on it, and also I find it a bit superfluous.
|
|
||
| * `--memlimit-rss`, `-s` - monitor RSS (resident set size) memory limit | ||
| * `--memlimit-rss`, `-s` - monitor RSS (resident set size) memory limit. | ||
| Memory limits may be specified as KB (default), MB, or GB. |
There was a problem hiding this comment.
I like that you documented that the default is Kilobytes. These days, however, it's not clear if that means 1000 bytes or 1024 bytes; can you please clarify?
|
Hi Pavel, thanks for reviewing. I agree that people may rely on the output and it should be unaltered. (And yes the output was too verbose, I should have only output it for debug). These days "KiB" and "KB" mean 1024 and "kB" means 1000. We could update the usage text and allow both in the parse_memory_arg subroutine. I am happy to either leave, or add "KiB" and "kB" to follow wikipedia "Kibibyte" definitions. (My preference is to keep it simple.) Usage:
timeout [-t timelimit] [-m memlimit] [-s memlimit-rss] [-x hertz] command [arguments ...]
Memory limits may be specified as KB (1024 bytes, default), MB, or GB, and are
output as KB (1024 bytes).
Examples:
timeout -t 2 -m 321.0MB -s 123.4MB perl -e 'while (1) {push @a, 1}'
timeout -t 2 -m 321.0MB -s 123.4MB perl -e 'while (1) {$a += 1}'
The first example will be killed due to exceeding the 123.4 MB rss (resident
set size) limit, and the second example will be killed due to exceeding the 2
second CPU time limit. The values at the time the process is killed will vary
due to the timeout program only waking up periodically to compare the current
values against the limits.
Thanks |
No description provided.