Skip to content

Output memory as KB, MB, GB. Accept memory arguments as KB, MB, GB.#14

Open
ericjster wants to merge 1 commit intopshved:masterfrom
ericjster:master
Open

Output memory as KB, MB, GB. Accept memory arguments as KB, MB, GB.#14
ericjster wants to merge 1 commit intopshved:masterfrom
ericjster:master

Conversation

@ericjster
Copy link
Copy Markdown

No description provided.

Comment thread timeout
# 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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not change the output format

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other ppl's software might depend on it, and also I find it a bit superfluous.

Comment thread README

* `--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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@ericjster
Copy link
Copy Markdown
Author

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).
Before I submit another change, do you think this a good wording for the usage, and good examples?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants