Calculating Dirty Memory
lacey.leanne at gmail.com
Tue Jan 13 07:05:22 UTC 2015
On 01/12/2015 17:41, RW wrote:
> On Mon, 12 Jan 2015 15:10:29 -0800
> Lacey Powers wrote:
>> Hello Everyone,
>> I was working on trying to improve some database benchmarking tools
>> for PostgreSQL, to work better on FreeBSD.
>> One of the things that the tools do under Linux is
>> read /proc/meminfo, and grab the value of the Dirty parameter, which
>> is this:
>> "Dirty ? The total amount of memory, in kilobytes, waiting to be
>> written back to the disk." according to the CentOS documentation and
>> other sources.
> AFAIK the word "dirty" can refer to any page that isn't synchronized
> with it's backing store, including swap-backed memory that may never be
> written to disk.
>> Poking around the FreeBSD documentation, Google, and sysctls, I came
>> to this calculation:
>> (vm.stats.vm.v_page_size * vm.stats.vm.v_inactive_count) / 1024 =
>> Inactive (Dirty) kB (page size in bytes *number of pages) / 1024
> v_inactive_count includes dirty and clean pages.
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
Thank you for the reply. =)
I based the choice of v_inactive_count off of these lines from my
previously linked documentation:
"The system must make a distinction between clean pages which can
theoretically be freed up at any time, and dirty pages which must first
be written to their backing store before being reusable. When a page
candidate has been found it is moved to the inactive queue if it is
dirty, or the cache queue if it is clean. A separate algorithm based on
the dirty-to-clean page ratio determines when dirty pages in the
inactive queue must be flushed to disk."
However, considering your comment regarding v_inactive_count, several
more reads through that document, and this later line
"What this means is that FreeBSD will not try very hard to separate out
dirty pages (inactive queue) from clean pages (cache queue) when the
system is not being stressed, nor will it try to deactivate pages
(active queue -> inactive queue) when the system is not being stressed,
even if they are not being used."
It seems that any of the vm stats exposed via sysctl are a poor metric
for calculating memory waiting to be written to disk, due to the "lazy"
So much for an easy answer. =)
Should I instead be looking at the filesystems in FreeBSD?
Are there additional resources you could recommend?
Again, thank you for your reply and assistance. =)
More information about the freebsd-questions