benchmarking freebsd

44
Benchmarking FreeBSD Benchmarking FreeBSD Ivan Voras <[email protected]>

Upload: ivan-voras

Post on 02-Dec-2015

225 views

Category:

Documents


3 download

DESCRIPTION

BSDCan 2013 talk on benchmarking in general

TRANSCRIPT

Page 1: Benchmarking FreeBSD

Benchmarking FreeBSDBenchmarking FreeBSD

Ivan Voras <[email protected]>

Page 2: Benchmarking FreeBSD

What and why?

● Everyone likes a nice benchmark graph :)– And it's nice to keep track of these things

● The previous major run comparing FreeBSD to Linux was done by Kris Kennaway in 2008.

● There are occasional benchmarks appearing on blogs and mailing lists which show “interesting” results...

Page 3: Benchmarking FreeBSD

Target audience

● Mostly developers– The results are decent, but not rosy– Significant space for improvement

● Some system administrator material– What to do, what not to do– Tuning?

● “Avoid benchmarking?”– Do you need it?

Page 4: Benchmarking FreeBSD

Purpose of benchmarking...

● To check your system for configuration bugs and obvious problems (hw/sw)

● To check your capacity for running an application (web server, db server, etc.)

● To compare your hardware to others'● To compare your favorite application /

operating system to others...

Page 5: Benchmarking FreeBSD

Repeatability

● The best benchmarks are performed in a way anyone can repeat them

● Both result verification (error checking) and a way to compare their own setup to the one tested

● Repeatability is a good thing...

Page 6: Benchmarking FreeBSD

Test hardware

● 2x IBM x3250 M3● Xeon E3-1220 3.1 GHz, 4-core (no HTT)● 32 GB RAM● 4x SATA drive

RAID0● 1 Gbps

NIC (2 ports)Directly connected NICs

Page 7: Benchmarking FreeBSD

Test software

● FreeBSD 9.1 and 10-CURRENT (HEAD)● CentOS 6.3● PostgreSQL 9.2.3● blogbench 1.1● bonnie++ 1.97● filebench 1.4.8● Mdcached 1.0.7

Page 8: Benchmarking FreeBSD

Accuracy and precision

● Accurate = if it measures what we think it measures (or is it off the mark)

● Precise = is the measured value good approximation of the “real” one (or is it affected by noise)

Page 9: Benchmarking FreeBSD

Systematic and random errors

● Systematic = we're not measuring what we thing we're measuring (the method of benchmarking is wrong, even though the results may be repeatable and look correct).

● Random = affected by “noise” outside our control, results in non-repeatable measurements.

Page 10: Benchmarking FreeBSD

Expressing precision

● Find meaningful precision– (or: avoid false precision)

● 412.567 MB/s● 412.5 MB/s● 412 MB/s● 410 MB/s

Page 11: Benchmarking FreeBSD

Standard deviation

● The “error bars”● 1234 +/- 5 of something● Expresses confidence in your

measurement – how precise they are (clustered around the measured value)

Page 12: Benchmarking FreeBSD

outside middle inside0

50

100

150

200

250

300

350

Example: hard drive performance

● (Systematic: you are not measuring what you think are measuring)

● File systems vs (spinning) drives

diskinfo -vt /dev/da0

MB/s

Page 13: Benchmarking FreeBSD

1 2 3 4 5 6 7 80

50

100

150

200

250

300

350

400

Whole drive

outside

middle

inside

File systems are hard to measure

● Data location-dependant performance● Data structure (re)use-dependant

performance (newfs vs old system)– Double for flash drives

● NoiseMB/s

Page 14: Benchmarking FreeBSD

Speaking of noise...

Page 15: Benchmarking FreeBSD

0

50

100

150

200

250

300

350

outside

middle

inside

Reducing the difference

● Create a partition spanning the minimal required disk space(e.g. 3x-4x the RAM size)

partition whole drive

MB/s

Page 16: Benchmarking FreeBSD

bonnie++

● File system bandwidth & file op latency

Write Rewrite Read0

100

200

300

400

500

600

CentOS 6.3 FreeBSD 9.1 FreeBSD 10

MB/s

Page 17: Benchmarking FreeBSD

File systems are complex beasts

● Think about it – it's a database...● Data layout issues (esp. on rotating rust)● Concurrent access issues● “miscellaneous” features such as

attributes, security, reliability, TRIM● NFS is also a horror but for different

reasons

Page 18: Benchmarking FreeBSD

Blogbench

● Stresses file system parallelism and random disk IO

– Creates a tree of small-ish files (2 KiB – 64 KiB)

– Reads and writes them– Atomic renames for (some) writes– Multithreaded

Page 19: Benchmarking FreeBSD

Blogbench results

Linux read FreeBSD 9.1 read FreeBSD 10 read0

200000

400000

600000

800000

1000000

1200000

1400000

1600000

1800000

2000000

Linux write FreeBSD 9.1 write FreeBSD 10 write0

500

1000

1500

2000

2500

3000

3500

4000

4500

1,900,000

700,000

Page 20: Benchmarking FreeBSD

Blogbench FreeBSD 9.1 vs 10x read-91+ read-10+----------------------------------------------------------------------+|xx x * x x*x + * x +* + + + + +|| |__________AM|________|______M__A_________________| |+----------------------------------------------------------------------+ N Min Max Median Avg Stddevx 11 509450 695303 600394 593580.45 60234.934+ 11 577355 893889 695303 708560.45 102923.93Difference at 95.0% confidence 114980 +/- 75005.3 19.3706% +/- 12.6361% (Student's t, pooled s = 84325.5)

x write-91+ write-10+----------------------------------------------------------------------+| + ||+ + + ++* * x+ x x x x * x x+ x|| |__________M_______A|_________________|M_________________| |+----------------------------------------------------------------------+ N Min Max Median Avg Stddevx 11 1299 2173 1734 1716.6364 287.0642+ 11 1111 2104 1299 1416 296.7814Difference at 95.0% confidence -300.636 +/- 259.694 -17.5131% +/- 15.128% (Student's t, pooled s = 291.963)

Page 21: Benchmarking FreeBSD

Why is Blogbench slow on FreeBSD?

● A multithreaded mix of file operations● On FreeBSD (UFS):

– open(O_WRITE)– write()– rename()– etc ... block each other (exclusive lock)– + writers block readers

● So called “write bias” of FreeBSD

Page 22: Benchmarking FreeBSD

Why is Blogbench slow on FreeBSD?

884 100130 blogbench 1.472372 CALL open(0x7ffffebf5770,0x601<O_WRONLY|O_CREAT|O_TRUNC>,0x180<S_IRUSR|S_IWUSR>) 884 100190 blogbench 1.472381 CALL close(0x2a) 884 100162 blogbench 1.472382 CALL read(0x31,0x602f60,0x10000) 884 100141 blogbench 1.472386 CALL read(0x32,0x602f60,0x10000) 884 100190 blogbench 1.472387 CALL open(0x7ffff73b9ba0,0<O_RDONLY>,<unused>0) 884 100162 blogbench 1.472395 CALL read(0x31,0x602f60,0x10000) 884 100130 blogbench 1.472398 CALL write(0x2a,0x612f60,0x1df2) 884 100141 blogbench 1.472402 CALL read(0x32,0x602f60,0x10000) 884 100162 blogbench 1.472407 CALL close(0x31) 884 100130 blogbench 1.472412 CALL close(0x2a) 884 100190 blogbench 1.472403 CALL open(0x7ffff73b9ba0,0<O_RDONLY>,<unused>0) 884 100162 blogbench 1.472418 CALL open(0x7ffffabd5ba0,0<O_RDONLY>,<unused>0) 884 100130 blogbench 1.472421 CALL rename(0x7ffffebf5770,0x7ffffebf5ba0) 884 100141 blogbench 1.472415 CALL close(0x32) 884 100190 blogbench 1.472423 CALL read(0x2a,0x602f60,0x10000) 884 100141 blogbench 1.472430 CALL open(0x7ffffd5eaba0,0<O_RDONLY>,<unused>0) 884 100162 blogbench 1.472433 CALL read(0x31,0x602f60,0x10000) 884 100190 blogbench 1.472438 CALL read(0x2a,0x602f60,0x10000) 884 100130 blogbench 1.472442 CALL open(0x7ffffebf5770,0x601<O_WRONLY|O_CREAT|O_TRUNC>,0x180<S_IRUSR|S_IWUSR>) 884 100190 blogbench 1.472443 CALL close(0x2a) 884 100141 blogbench 1.472451 CALL open(0x7ffffd5eaba0,0<O_RDONLY>,<unused>0) 884 100162 blogbench 1.472451 CALL read(0x31,0x602f60,0x10000) 884 100190 blogbench 1.472450 CALL open(0x7ffff73b9ba0,0<O_RDONLY>,<unused>0) 884 100141 blogbench 1.472460 CALL read(0x2a,0x602f60,0x10000) 884 100130 blogbench 1.472464 CALL write(0x32,0x612f60,0x13f2) 884 100190 blogbench 1.472465 CALL open(0x7ffff73b9ba0,0<O_RDONLY>,<unused>0) 884 100162 blogbench 1.472461 CALL close(0x31) 884 100190 blogbench 1.472475 CALL read(0x31,0x602f60,0x10000) 884 100162 blogbench 1.472477 CALL open(0x7ffffabd5ba0,0<O_RDONLY>,<unused>0) 884 100141 blogbench 1.472480 CALL read(0x2a,0x602f60,0x10000) 884 100130 blogbench 1.472478 CALL close(0x32)

Page 23: Benchmarking FreeBSD

Why is Blogbench slow on FreeBSD?

0

100000

200000

300000

400000

500000

600000

700000

800000

read()

close()

open()

write()

(not distinguishingbetween open(O_RD)and open(O_WR) )

Page 24: Benchmarking FreeBSD

PostgreSQL pgbench

● Initialized with -s 1000● 100,000,000 records, 16 GB size

– (fits in RAM, for RO)● PostgreSQL configuration:

– 8 GB shared buffers– 32 MB work memory– autovacuum off– 30 checkpoint segments

Page 25: Benchmarking FreeBSD

PostgreSQL / pgbench caveats

● WAL logging means:– data is written to checkpoint segments,

restarts are needed between WRITE benchmarks

– data is transferred to “proper” storage almost unpredictably, long-ish runs are needed for repeatable benchmarks

● Autovacuum can run almost unpredictably

Page 26: Benchmarking FreeBSD

PostgreSQL results

1 2 4 8 12 16 24 32 48 64 1280

10000

20000

30000

40000

50000

60000

Linux disk RO avg Linux disk RW avg Linux ramfs RO avg

Linux ramfs RW avg Linux remote ramfs RO avg FreeBSD disk RO avg

FreeBSD disk RW avg FreeBSD tmpfs RO avg FreeBSD tmpfs RW avg

FreeBSD remote tmpfs RO avg

Page 27: Benchmarking FreeBSD

1 2 4 8 12 16 24 32 48 64 1280

10000

20000

30000

40000

50000

60000

Linux disk RO avg Linux ramfs RO avg

FreeBSD disk RO avg FreeBSD tmpfs RO avg

PostgreSQL result notes

● On Linux, there's almost no difference between ext4 when data is fully cached (warmed) and ramfs

● On FreeBSD,tmpfs isfaster

Page 28: Benchmarking FreeBSD

PostgreSQL result notes

● Linux is consistently 5%-10% better

1 2 4 8 12 16 24 32 48 64 1280

200

400

600

800

1000

1200

Linux disk RW avg FreeBSD disk RW avg

Page 29: Benchmarking FreeBSD

1 2 4 8 12 16 24 32 48 64 1280

10000

20000

30000

40000

50000

60000

Linux ramfs RO avg Linux remote ramfs RO avg FreeBSD tmpfs RO avg FreeBSD remote tmpfs RO avg

PostgreSQL result notes

● Remote access doesn't help much

Scheduler issue

Page 30: Benchmarking FreeBSD

However...

● Different benchmark, by Florian Smeets● 40-core, 80-thread system, 256 GB RAM● scale 100 – 10,000,000 records

Threads 2 Threads 4 Threads 8 Threads 10 Threads 16 Threads 20 Threads 24 Threads 320

20000

40000

60000

80000

100000

120000

140000

160000

180000

200000

FreeBSD-VMC-233854-postgres-9.2-devel Linux-kernel-3.3.0-glibc-2.15-postgres-9.2-devel FreeBSD-head-r233892

Linux winsafter 32 threads

Page 31: Benchmarking FreeBSD

Filebench

● Dubious correctness of the port...● “fileserver” and “webproxy” profiles

– fileserver: “Emulates simple file-server I/O activity. This workload performs a sequence of creates, deletes, appends, reads, writes and attribute operations on a directory tree. 50 threads are used by default. The workload generated is somewhat similar to SPECsfs.”

– webproxy: “Emulates I/O activity of a simple web proxy server. A mix of create-write-close, open-read-close, and delete operations of multiple files in a directory tree and a file append to simulate proxy log. 100 threads are used by default.”

● Local drive, NFSv3 and NFSv4

Page 32: Benchmarking FreeBSD

fileserver profile

0

100

200

300

400

500

600

700

800

900

Linux – local MB/s Linux – NFSv3 MB/s Linux – NFSv4 MB/s FreeBSD – local MB/s FreeBSD – NFSv3 MB/s FreeBSD – NFSv4 MB/s

Should not be possibleNFSv4 is sloweven on Linux

Page 33: Benchmarking FreeBSD

webproxy profile

0

100

200

300

400

500

600

700

800

Linux – local MB/s Linux – NFSv3 MB/s Linux – NFSv4 MB/s FreeBSD – local MB/s FreeBSD – NFSv3 MB/s FreeBSD – NFSv4 MB/s

Possible,but improbable

Page 34: Benchmarking FreeBSD

Cross-benchmarking

● FreeBSD server, Linux client● Linux does caching...

0

50

100

150

200

250

Linux – NFSv3 MB/s Linux client, FreeBSD 10 server, NFSv3 MB/s

Page 35: Benchmarking FreeBSD

Bullet Cache

● My own cache server, presented at BSDCan 2012 :)

● Lots of small (32 byte – 128 byte) TCP command / response transactions

● Multithreaded + non-blocking IO● (nearly 2,000,000 TPS over Unix sockets

on medium-end hardware)

Page 36: Benchmarking FreeBSD

CentOS 6.3 FreeBSD 9.1 FreeBSD 100

100000

200000

300000

400000

500000

600000

100 conn 200 conn 300 conn 400 conn 500 conn

● Linux support incomplete, lacks epoll()● Within measurement error, 9.1 == 10

Page 37: Benchmarking FreeBSD

Result notes

● TCP is fairly concurrent in FreeBSD, multiple TCP streams do not blockeach other

● > 470,000 PPS per direction● Over Unix sockets (local): 1,020,000 TPS

Page 38: Benchmarking FreeBSD

On tuning...

● The year is 2013 and FreeBSD actually auto-tunes reasonably well

● Example #1: vfs.read_max● Example #2: hw.em.txd/rxd● Example #3: kern.maxusers● Example #4: vm.pmap.shpgperproc

+ hi/lobufspace

Page 39: Benchmarking FreeBSD

Why no CPU benchmarks?

● You are not going to influence raw CPU performance from the OS (except in edge cases / misconfiguration)

● You can test the quality of the libc and libm implementations... but be sure that is what you want to

● You can also test the quality of compiler optimizations... if you want to.

Page 40: Benchmarking FreeBSD

(LLVM vs GCC)

● (do not draw conclusions based on this)● (Phoronix benchmark, Botan/KASUMI)

OpenBenchmarking.orgMbytes/s, More Is Better

Botan v1.10.3Test: KASUMI

GCC 4.7.2

GCC 4.8.0

LLVM Clang 3.2

LLVM Clang 3.3 SVN

15 30 45 60 75

SE +/- 0.0039.35

SE +/- 0.0037.91

SE +/- 0.0039.34

SE +/- 0.0065.75

Powered By Phoronix Test Suite 4.4.1

1. (CXX) g++ options: -m64 -ldl -lpthread -lrt

Page 41: Benchmarking FreeBSD

Why NOT benchmark?

● When is benchmarking important?– Is performance more important than

features?– Is it cheaper to buy another machine than

to reconfigure / develop a better OS?● The future is actually quite good

– During 7.x timeframe: 8 CPU scalability– During 10.x timeframe: 32 CPU scalability

Page 42: Benchmarking FreeBSD

When you do need to benchmark?

● As a sysadmin, you just want to know● Planning / budgeting for a project● When your boss tells you to :)● Advocacy...

Page 43: Benchmarking FreeBSD

Continuous benchmarking?

● Some talks were had...● It would probably be easier to set up now

after the developer cluster has been updated...

● Performance regression monitoring

Page 44: Benchmarking FreeBSD

The End

Benchmarking FreeBSDBenchmarking FreeBSD

Ivan Voras <[email protected]>