564 Block Buffer Cache

The buffer cache used in Solaris for caching of inodes and file metadata is now also dynamically sized. In old versions of UNIX, the buffer cache was fixed in size by the nbuf kernel parameter, which specified the number of 512-byte buffers. We now allow the buffer cache to grow by nbuf, as needed, until it reaches a ceiling specified by the bufhwm kernel parameter. By default, the buffer cache is allowed to grow until it uses 2% of physical memory. We can look at the upper limit for the buffer cache by using the sysdef command.

# sysdef

* Tunable Parameters

# sysdef

* Tunable Parameters

7757824

maximum memory allowed in buffer cache (bufhwm)

5930

maximum number of processes (v.v proc)

99

maximum global priority in sys class (MAXCLSYSPRI

5925

maximum processes per user id (v.v maxup)

30

auto update time limit in seconds (NAUTOUP)

25

page stealing low water mark (GPGSLO)

5

fsflush run rate (FSFLUSHR)

11618 1347693 10787 76686 0 0 0 1 0

3013

94467.490008162

oiding deadlock (MINARMEM) 25 minimum swapable memory for avoiding deadlock (MINASMEM)

Now that we only keep inode and metadata in the buffer cache, we don't need a very large buffer. In fact, we need only 300 bytes per inode and about 1 megabyte per 2 gigabytes of files that we expect to be accessed concurrently (note that this rule of thumb is for UFS file systems).

For example, if we have a database system with 100 files totaling 100 gigabytes of storage space and we estimate that we will access only 50 gigabytes of those files at the same time, then at most we would need 100 x 300 bytes = 30 kilobytes for the inodes and about 50 ^ 2 x 1 megabyte = 25 megabytes for the metadata (direct and indirect blocks). On a system with 5 gigabytes of physical memory, the defaults for bufhwm would provide us with a bufhwm of 102 megabytes, which is more than sufficient for the buffer cache. If we are really memory misers, we could limit bufhwm to 30 megabytes (specified in kilobytes) by setting the bufhwm parameter in the /etc/system file. To set bufhwm smaller for this example, we would put the following li ne into the /etc/system file.

* Limit size of bufhwm

set bufhwm=30 0 0 0

You can monitor the buffer cache hit statistics by using sar -b. The statistics for the buffer cache show the number of logical reads and writes into the buffer cache, the number of physical reads and writes out of the buffer cache, and the read/write hit ratios.

SunOS zangief 5.7 Generic sun4u 06/27/99

SunOS zangief 5.7 Generic sun4u 06/27/99

22 :

: 01:

51

bread/s

lread/s

%rcache

bwrit/s

lwrit/s

%wcache

pread/s

pwrit/s

22:

: 01:

54

0

7118

100

0

0

100

0

0

22:

: 01:

57

0

7863

100

0

0

100

0

0

22:

: 02:

00

0

7931

100

0

0

100

0

0

22:

: 02:

: 03

0

7736

100

0

0

100

0

0

22:

: 02:

06

0

7643

100

0

0

100

0

0

22:

: 02:

09

0

7165

100

0

0

100

0

0

22:

: 02:

12

0

6306

100

8

25

68

0

0

22:

: 02:

15

0

8152

100

0

0

100

0

0

22:

: 02:

: 18

0

7893

100

0

0

100

0

0

On this system we can see that the buffer cache is caching 100% of the reads and that the number of writes is small. This measurement was taken on a machine with 100 gigabytes of files that were being read in a random pattern. You should aim for a read cache hit ratio of 100% on systems with only a few, but very large, files (for example, database systems) and a hit ratio of 90% or better for systems with many files.

0 0

Post a comment

  • Receive news updates via email from this site