Messages in this thread | | | Date | Mon, 25 Mar 1996 17:38:56 +0100 | From | (Benoit Poulot-Cazajous) | Subject | Performance problems with 1.3.7x |
| |
Hi everybody !
There is a BIG performance problem with the way caches (page and buffer) are handled in recent kernels :
1) the buffer cache can not grow if there is no free memory 2) the page cache can steal pages from the buffer cache 3) writes go through the buffer cache.
1) and 2) imply that the buffer cache can become and STAY very small if memory is not freed by umount, exit, unlink, etc... With 3), it is easy to have a system that becomes slower and slower as time passes...
It is quite surprising that nobody noticed that !
You will find at the end of the message a small shell script that : a) creates a big file. b) creates a small file (Ok, 4 Mb is not so small) c) fills the page cache with the content of the big file. The buffer cache then shrinks. d) measures the time it takes to copy the small file. As the buffer cache is so small, it takes a long time. The copy is performed three times. e) removes the big file, freeing a log of memory. The buffer cache can grow... f) copies again the small file. This time it is fast.
Here are the result of this shell script on 1.3.24 and 1.3.78 on a 486DX2/66 with 16 Mb and an empty ext2 filesystem with 1k blocks (results are worse with 4k blocks...) :
On 1.3.78: ---------- ... 0.05user 2.41system 0:08.37elapsed 29%CPU 0.03user 2.33system 0:07.20elapsed 32%CPU 0.09user 2.34system 0:07.31elapsed 33%CPU ^^^^^^^ not very good... ... 0.07user 1.54system 0:02.91elapsed 55%CPU 0.07user 1.56system 0:02.04elapsed 79%CPU 0.02user 1.60system 0:02.15elapsed 75%CPU
On 1.3.24: ---------- ... 0.07user 1.85system 0:02.33elapsed 82%CPU 0.11user 1.63system 0:02.21elapsed 78%CPU 0.03user 1.71system 0:02.16elapsed 80%CPU ... 0.09user 2.18system 0:02.47elapsed 91%CPU 0.14user 1.63system 0:02.18elapsed 81%CPU 0.08user 1.69system 0:02.17elapsed 81%CPU
The promised shell script :
---------------------------------------------------------------------------- #!/bin/sh set -x
# Set MEMSIZE to the size (in Mb) of the physical memory. MEMSIZE=16 FILESIZE=4
# create two files : # a_big_file will fill the page cache # a_small_file will be copied via the buffer cache dd if=/dev/hda bs=1024k count=$MEMSIZE > a_big_file dd if=a_big_file of=a_small_file bs=1024k count=$FILESIZE
# sync everything sync
# bring those files into the page cache. # the buffer cache is reduced to almost nothing. cp a_big_file /dev/null cp a_small_file /dev/null
# copy the small file. time cp a_small_file another_small_file sync time cp a_small_file another_small_file sync time cp a_small_file another_small_file sync
# remove the big file, this should free some memory for the buffer cache rm -f a_big_file sync
# copy the small file again, should be faster now time cp a_small_file another_small_file sync time cp a_small_file another_small_file sync time cp a_small_file another_small_file sync
# cleanup rm -f a_small_file another_small_file ----------------------------------------------------------------------------
-- Benoit
| |