Discrepancy between ps -i -o inblk and figuring numbers by hand

Dan Nelson dnelson at allantgroup.com
Thu Mar 24 19:23:28 PST 2005


In the last episode (Mar 24), Jonathan Stewart said:
> When I run the command ps -u -o inblock on a process reading a
> 262144000 byte file the highest block count I see is ~2010 but my
> filesystem block size is 16384 and 262144000/16384 is 16000 so it
> seems to be off by about a factor of 8. I even tried looking through
> the source code for the ps command but my C is not good enough for me
> to figure it out. Can someone explain or help me figure out what is
> going on please.

That ps column actually looks at the rusage value ru_inblk, which
doesn't count the number blocks read, but the number of times the
kernel did physical I/O on behalf of the process (how often the kernel
blocked doing a read).  The clustering code will fetch up to
sysctl(vfs.read_max) blocks at a time into disk cache, so reading
sequential files will increment ru_inblock (blocks_in_file/read_max)
times.  Raising vfs.read_max to 32 will greatly increase sequential
read performance on fast RAID arrays.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list