Solaris tmpfs

Solaris also provides /tmp area with tmpfs file system structure inside virtual swap. If you did not read prior this doc, you must first read  Solaris swapfs part to understand this part better. At time t, there will be unallocated reserved areas inside virtual swap. Tmpfs data will be allocated from page cache and/or from these unallocated reserved areas.

Tmpfs is not ramdisk. Ramdisk just allocates from RAM, tmpfs allocates from virtual swap. Virtual swap usage for tmpfs is better because ramdisk would completely dedicate RAM and need separate carefull Management, virtual swap would not fully consume RAM and has already stable management methods inside swapfs.

 /tmp is not an ordinary disk because /tmp is heavily used by many applications and memory is faster than disk, so application performance would be better with tmpfs rather than ordinary disk. Also it is very meaningfull for short-living processes, doing their work immediately instead of waiting disk. Tmpfs has also a limit that it can never reserve from swapfs. This limiting variable is tmpfs_minfree. It can be changed by /etc/system. Although existence of tmps_minfree variable, it is always advised to put limit to /tmp size. This is needed to prevent wrong human usage, making /tmp full and reserving memory. Until 16 GB of system memory, /tmp limit can be maximum RAM * 0,3. After 16 GB system RAM, this limit can be RAM * 0,2. If /tmp size limit is activated, you wont get afraid of system health when /tmp is %100. Of course applications will suffer if /tmp is %100 and we will never want it, but we mean here system health, it means system wont hung and continue working. If your /tmp is unlimited and it is %100, your whole virtual swap area may suffer and system may freeze, So setting limit for /tmp is essential for Solaris, you must not forget setting it.

You can see tmpfs is faster than an ordinary disk from below  example.

root@server1:/# time dd if=/dev/zero of=/test1.out bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
real    0m15.090s
user    0m1.701s
sys     0m10.564s
root@server1:/# time dd if=/dev/zero of=/tmp/test1.out bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
real    0m4.286s
user    0m1.675s
sys     0m2.612s

You can also see from below example that tmpfs allocated from page cache

root@server1:/# swap -s;echo “::memstat” | mdb –k | grep –i “page cache”; dd if=/dev/zero of=/tmp/test1.out bs=1024 count=11000000; swap -s; echo “::memstat” | mdb –k | grep –i “page cache”

 total: 1998288k bytes allocated + 343384k reserved = 2341672k used, 10711296k available
Page cache                  131456              1.0G    6%
11000000+0 records in
11000000+0 records out

total: 11996496k bytes allocated + 349000k reserved = 12345496k used, 900040k available

Page cache                 1313556             10.0G   63%

 


*** Please feel free to communicate by
bulent.yucesoy@gmail.com