Linuxpiter 2015 Kosmodemiansky Linux
Linuxpiter 2015 Kosmodemiansky Linux
performance
Ilya Kosmodemiansky
[email protected]
The modern linux kernel
CPU
Memory
Storage
Other
PostgreSQL specifics
Kernel buffer
WAL
Disks
How to make pages travel faster from disk to memory
NUMA
Huge pages
Swap
NUMA
What goes on
Non Uniform Memory Access
CPUs have their own memory, CPU + memory nodes
connected via NUMA interconnect
CPU uses its own memory, then accesses remaining memory by
interconnect (numactl hardware shows distances)
If node interleaving disabled, CPU tries to use its local memory
(for page cache for example;-))
NUMA
What goes on
By default OS allocates memory by 4kB chunk
OS translates physical addresses into virtual addresses and
cache the result in Translation Lookaside Buffer (TLB)
1Gb
4kB = 262144 - huge TLB overhead and cache misses
Better to allocate memory in larger chunks
Huge pages
What goes on
It happens when there are a lot of RAM on server
Swap
What goes on
By default vm.dirty_ratio = 20, vm.dirty_background_ratio
= 10
Nothing happens until kernel buffer is 10% full of dirty pages
From 10% to 20% - background flushing
From 20% IO effectively stops until pdflush/flushd/kdflush
finishes its job
This is almost crazy if your shared_buffers setting is
32Gb/64Gb or more with any cache on RAID-controller or SSD
More effective flushing pages to disk
Scheduler tuning
Power saving
Scheduler tuning