Today we discuss some small adjustments to make to a NetBSD default config in order to increase performance on desktop targets

kernel config

# set max number of allowed processes to 1044 maxusers 64 # Alternate buffer queue strategies for better responsiveness under high # disk I/O load. options BUFQ_READPRIO options BUFQ_PRIOCSCAN

resource limits

Add this to your /etc/login.conf in order to increase 'capabilities' (=loosen session resource limits) for the 'default' login class (hence every user), system-wide:

default:\ :path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/pkg/bin /usr/pkg/sbin /usr/local/bin:\ :umask=022:\ :datasize-max=3072M:\ :datasize-cur=1024M:\ :maxproc-max=1044:\ :maxproc-cur=1024:\ :openfiles-cur=512:\ :stacksize-cur=16M: :copyright=/dev/null:

kernel state tunables

Set those sysctl(7) values permanently at boot time but adding what follows to your /etc/sysctl.conf

# 128M PAGE_SIZE kern.ipc.shmmaxpgs=32768 # increase max number of file descriptors kern.maxfiles=1772 # automatic network buffers resize net.inet.tcp.recvbuf_auto=1 net.inet.tcp.sendbuf_auto=1 # 16MB buffers upper limit net.inet.tcp.sendbuf_max=16777216 net.inet.tcp.recvbuf_max=16777216 net.inet.ip.ifq.maxlen = 4096

FFSv2 WAPBL

WAPBL provides data journaling on NetBSD for the FFSv{1,2} filesystems .

Journaling improves writing performance noticeably by reducing synchronization, especially when creating a large number of inodes. It also avoids having to go through a thorough file-systems check during a crash recovery , speeding up boot time significantly in those cases

Enabling WAPBL on NetBSD is as easy as appending 'log' to FS mount options for each FFSv{1,2} partition found in /etc/fstab:

/dev/wd0a / ffs rw,log 1 1 /dev/wd0e /usr ffs rw,log 1 2 /dev/wd0f /var ffs rw,log 1 2 /dev/wd0g /home ffs rw,log 1 2

tmpfs

mount a tmpfs disk on directories with a high r/w turnover so as to decrease access time and increase maximum throughput, by adding suitable entries to /etc/fstab

tmpfs /tmp tmpfs rw,-m=1777,-s=4295467008 tmpfs /var/shm tmpfs rw,-m1777,-sram%25 tmpfs /var/tmp tmpfs rw,-m1777,-sram%25

optimized CC FLAGS and pkgsrc options

Use devel/cpuflags to determine the best compiler flags to set for your CPU;

Now you can specify them inside your /etc/mk.conf

PKGSRC_COMPILER?= gcc CFLAGS+= -O2 -mfpmath=sse -msse3 -march=x86-64 CPUFLAGS+= -mfpmath=sse -msse3 -march=x86-64 COPTS+= -O2 MAKE_JOBS= 3 GZIP?= --fast

# TIPS :

Add swap space to a running system

% dd if=/dev/zero bs=1M count=128 of=<FS>/swap % chmod 600 <FS>/swap % swapctl -a -p 1 <FS>/swap

Providing file-based swap is slower than a swap partition, giving the additional swap space a priority of 1 (through '-p 1', least is a value of '0' ) forces it be relied upon for paging only when the swap partition has been used up.

check for memory in use