[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: physmem: a new program to report memory information
From: |
Pádraig Brady |
Subject: |
Re: physmem: a new program to report memory information |
Date: |
Sat, 01 Sep 2012 02:58:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 08/30/2012 04:35 PM, Assaf Gordon wrote:
> Hello,
>
> Related to the previous sort+memory envvar usage thread:
> http://thread.gmane.org/gmane.comp.gnu.coreutils.general/3028/focus=3090 .
>
> Attached is a suggestion for a tiny command-line program "physmem", that
> similarly to "nproc", exposes the gnulib functions "physmem_total()" and
> "physmem_available()".
>
> The code is closely modeled after nproc, and the "recommended" memory usage
> is calculated using sort's default_sort_size() .
>
> The program works like this:
> ===
> $ ./src/physmem --help
> Usage: ./src/physmem [OPTION]...
> Prints information about physical memory.
>
> -t, --total print the total physical memory.
> -a, --available print the available physical memory.
> -r, --recommended print a safe recommended amount of useable memory.
> -h, --human-readable print sizes in human readable format (e.g., 1K 234M
> 2G)
> --si like -h, but use powers of 1000 not 1024
> --help display this help and exit
> --version output version information and exit
>
> Report physmem bugs to address@hidden
> GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
> General help using GNU software: <http://www.gnu.org/gethelp/>
> Report physmem translation bugs to <http://translationproject.org/team/>
> For complete documentation, run: info coreutils 'physmem invocation'
> ===
>
> The actual working code (at the bottom of physmem.c) is:
> ===
> switch(memory_report_type)
> {
> case total:
> memory = physmem_total();
> break;
>
> case available:
> memory = physmem_available();
> break;
>
> case recommended:
> memory = default_sort_size();
> break;
> }
>
> char buf[LONGEST_HUMAN_READABLE + 1];
> fputs (human_readable (memory, buf, human_output_opts,1,1),stdout);
> fputs("\n", stdout);
> ===
>
> So it's very simple, and rely on existing coreutils code.
>
> Please let me know if this is something you'd be willing to include in
> coreutils.
>
> Thanks,
> -gordon
Thanks for taking the time to do a patch.
However this seems more appropriate for maybe util-linux.
Also it might be better as an option to the existing free(1) program?
Also RAM is just one aspect of the memory hierarchy.
For a separate tool, it should probably be more general
and allow inspection of any level. This already exists
in the hwloc utils for example:
$ hwloc-info -p -v --only machine
Machine (2860MB)
$ hwloc-info -p -v --only cache
L3 (3072KB)
L2 (256KB)
L1 (32KB)
So I wouldn't be that enthusiastic for such a util,
in coreutils at least.
cheers,
Pádraig.