4

I'm using Ubuntu with kernel 3.2.1, x86_64. I'm trying to benchmark a file system, and I want to limit the page cache size to avoid the file system cache taking up too much RAM, which would obviously improve performance (but would not reflect the results on systems with less memory).

Is there a way to do that? I've seen an option in some RHEL distribution for tuning /proc/sys/vm/pagecaches which seems to satisfy this, but I dont see anything useful in Ubuntu except dirty_background_ratio, which will only trigger flushing to disk, not more caching (so I can get a lot more sync I/O etc)

Thank you

user331398
  • 179
  • 2
  • 9
  • 3
    Why do you think it is obvious that reducing file system cache size in RAM would improve performance? – iruvar Jun 17 '13 at 13:16
  • 1
    I meant that using more RAM would improve performance, but unrealistically, since in a real system I would have less RAM available – user331398 Jun 25 '13 at 06:06

2 Answers2

1

ubuntu does not seem to have vm.pagecache settings

ls -l /proc/sys/vm/
total 0
-rw-r--r-- 1 root root 0 Jun 17 14:13 block_dump
--w------- 1 root root 0 Jun 17 14:13 compact_memory
-rw-r--r-- 1 root root 0 Jun 17 14:13 dirty_background_bytes
-rw-r--r-- 1 root root 0 Jun 17 09:16 dirty_background_ratio
-rw-r--r-- 1 root root 0 Jun 17 14:13 dirty_bytes
-rw-r--r-- 1 root root 0 Jun 17 14:13 dirty_expire_centisecs
-rw-r--r-- 1 root root 0 Jun 17 09:16 dirty_ratio
-rw-r--r-- 1 root root 0 Jun 17 09:16 dirty_writeback_centisecs
-rw-r--r-- 1 root root 0 Jun 17 14:13 drop_caches
-rw-r--r-- 1 root root 0 Jun 17 14:13 extfrag_threshold
-rw-r--r-- 1 root root 0 Jun 17 14:13 hugepages_treat_as_movable
-rw-r--r-- 1 root root 0 Jun 17 14:13 hugetlb_shm_group
-rw-r--r-- 1 root root 0 Jun 17 09:16 laptop_mode
-rw-r--r-- 1 root root 0 Jun 17 14:13 legacy_va_layout
-rw-r--r-- 1 root root 0 Jun 17 14:13 lowmem_reserve_ratio
-rw-r--r-- 1 root root 0 Jun 17 14:13 max_map_count
-rw-r--r-- 1 root root 0 Jun 17 14:13 memory_failure_early_kill
-rw-r--r-- 1 root root 0 Jun 17 14:13 memory_failure_recovery
-rw-r--r-- 1 root root 0 Jun 17 14:13 min_free_kbytes
-rw-r--r-- 1 root root 0 Jun 17 14:13 min_slab_ratio
-rw-r--r-- 1 root root 0 Jun 17 14:13 min_unmapped_ratio
-rw-r--r-- 1 root root 0 Jun 17 09:15 mmap_min_addr
-rw-r--r-- 1 root root 0 Jun 17 14:13 nr_hugepages
-rw-r--r-- 1 root root 0 Jun 17 14:13 nr_hugepages_mempolicy
-rw-r--r-- 1 root root 0 Jun 17 14:13 nr_overcommit_hugepages
-r--r--r-- 1 root root 0 Jun 17 14:13 nr_pdflush_threads
-rw-r--r-- 1 root root 0 Jun 17 14:13 numa_zonelist_order
-rw-r--r-- 1 root root 0 Jun 17 14:13 oom_dump_tasks
-rw-r--r-- 1 root root 0 Jun 17 14:13 oom_kill_allocating_task
-rw-r--r-- 1 root root 0 Jun 17 09:15 overcommit_memory
-rw-r--r-- 1 root root 0 Jun 17 14:13 overcommit_ratio
-rw-r--r-- 1 root root 0 Jun 17 14:13 page-cluster
-rw-r--r-- 1 root root 0 Jun 17 14:13 panic_on_oom
-rw-r--r-- 1 root root 0 Jun 17 14:13 percpu_pagelist_fraction
-rw-r--r-- 1 root root 0 Jun 17 14:13 scan_unevictable_pages
-rw-r--r-- 1 root root 0 Jun 17 14:13 stat_interval
-rw-r--r-- 1 root root 0 Jun 17 14:13 swappiness
-rw-r--r-- 1 root root 0 Jun 17 14:13 vfs_cache_pressure
-rw-r--r-- 1 root root 0 Jun 17 14:13 zone_reclaim_mode

you could try the following:

vi /etc/sysctl.conf

vm.min_free_kbytes=1024
vm.swappiness = 100

then run

sysctl -p
vm.min_free_kbytes = 1024
vm.swappiness = 100

Unsure if it is of any help.

The swapiness 100 Swap more application data to disk when ram is exhausted

V H
  • 8,382
  • 2
  • 28
  • 48
  • I dont think that helps. I dont want to create a huge swap unnaturally, and min_free_kbytes if I understand correctly would just force more frequent reclamations. This is still not exactly what I'm after. – user331398 Jun 18 '13 at 08:05
  • Well unless you wish to go to some ancient kernel I can't see how you wish to enable/set something no longer available ! http://www.mjmwired.net/kernel/Documentation/sysctl/vm.txt – V H Jun 18 '13 at 08:39
  • I know sysctl doesnt support it. Thought perhaps someone knows of an other way, or a aptch or something. I gather that is not so. Thanks – user331398 Jun 18 '13 at 10:01
  • http://stackoverflow.com/questions/7044863/how-to-change-kernel-i-o-buffer-size this may be of help – V H Jun 18 '13 at 13:08
0

Set the parameter echo 3019053 > /proc/sys/vm/min_free_kbytes , the current value represents 2.8-GB. then check the value by giving the command line : sysctl -a | grep min_free_kbytes.

now to answer this question, if you want to avoid too much of cache to be accumulated set this value to about 70-90% of the Total RAM.

now to avoid swap to be accumulated, turn the swap off by giving the command as : swapoff -a and commenting the line for swap under /etc/fstab to turn it off permanently after reboots. this will make things happen as the questioner wants.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253