Monday, April 10, 2017

The physical memory

The physical memory is a crucial and precious resource and is commonly one of the major system bottlenecks as well as one of the system components that bumps a system price to the skies.

Knowing and, better yet, determining at runtime the amount of physical memory that is physically installed on a host and that is actually available to the system is important to many deployment and administration strategies.

Without recurring to programming at the system APIs level, it is possible to easily determine such figures as shown below.

$ prtconf | grep Mem
Memory size: 8192 Megabytes


# echo ::memstat | mdb -k | grep Total
Total            2096958            7.9G


$ kstat -p -n system_pages | egrep 'avail|physmem|locked|total'
unix:0:system_pages:availrmem    930155
unix:0:system_pages:pageslocked 1162706
unix:0:system_pages:pagestotal  2092861
unix:0:system_pages:physmem     2092861


Note that pagestotal = availrmem + pageslocked and that it seems that interestingly pagestotal = physmem, all in multiples of page sizes.

$ pagesize
4096


Then we can now compare things and better grasp the reality:

$ echo "(2092861 * `pagesize`) / 1024 ^ 2" | bc
8175


$ echo "(2096958 * `pagesize`) / 1024 ^ 2" | bc
8191

 
To me the 16 MB (4096 pages) difference between 8191 and 8175 seems to be fixed (non-pageable) and is still a mystery, a matter to open investigation, perhaps some part of the kernel known only by the internal staff.

That is, according to system's best result it actually sees 8191 MB, 1 MB less than what's physically installed on the host and that's not so hard to wonder why (perhaps set aside for the on-board video or so). Using closer to perfect figures ought to provide more exact results for planning and assessments.