Improving DragonFly's performance with PostgreSQL by Francois Tigeot
-
Upload
eurobsdcon -
Category
Technology
-
view
69 -
download
0
Transcript of Improving DragonFly's performance with PostgreSQL by Francois Tigeot
![Page 1: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/1.jpg)
1/21
PostgreSQL as a benchmarking tool
How it was used to check and improve the scalability of the DragonFly operating system
François [email protected]
![Page 2: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/2.jpg)
2/21
About Me
● Independent consultant, sysadmin● Former ccTLD system engineer● *BSD user since ~= 1999● Also a PostgreSQL user since ~= 1999● Introduced FreeBSD in the .fr registry● DragonFly developer since 2011
![Page 3: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/3.jpg)
3/21
About DragonFly
● Unix-like Operating System● Forked from FreeBSD 4.8 in 2003 by Matthew
Dillon (not the actor)● Aims to be high-performance● Uses per-core replicated resources and
messaging● Many operations are naturally lockless
![Page 4: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/4.jpg)
4/21
About DragonFly (2)
● Innovative features very useful for some workloads
● Swapcache: second-level file cache● Uses existing swap infrastructure● Optimized for SSDs
![Page 5: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/5.jpg)
5/21
Swapcache
50 75 100 125 150 175 2000
20
40
60
80
100
120
Relative PostgreSQL performance
Dfly 3.2
With swapcache
Database size relative to main memory (%)
Pe
rce
nta
ge
of p
erf
orm
an
ce r
ela
ting
to m
axi
mu
m
![Page 6: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/6.jpg)
6/21
November 2011
● PostgreSQL 9.1● DragonFly 2.10 and 2.13 (development version)● Dual Xeon, 24 threads, 96GB RAM● Global MP lock removed from the kernel after
version 2.10● Was looking for benchmarks showing CPU
scalability● PGbench (read-only) was a good fit
![Page 7: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/7.jpg)
7/21
November 2011 (2)
● Some crashes and bugs with high PGbench loads
● Quickly fixed (generally in less than a day)● Deadlocks in the VM subsystem● Overflows and races in zalloc()● Races in the SysV shared memory subsystem● Etc...
![Page 8: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/8.jpg)
8/21
November 2011 (3)
1 2 4 8 12 16 20 24 28 32 48 64 800
20000
40000
60000
80000
100000
120000
Pgbench 127.0.0.1 TPS scaling
DragonFly 2.10
Scientific Linux 6.1
![Page 9: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/9.jpg)
9/21
November 2011 (4)
● System changes to improve performance● Remove MP lock from SysV semaphore code● Improve select() and poll()● New “dmalloc” lockless memory allocator in libc● Improve other memory allocation code paths● Make it possible to concurrently process huge
numbers of page faults
![Page 10: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/10.jpg)
10/21
November 2011 (5)
1 2 4 8 12 16 20 24 28 32 48 64 800
20000
40000
60000
80000
100000
120000
Pgbench 127.0.0.1 TPS scaling
DragonFly 2.10
DragonFly 2.13
Scientific Linux 6.1
![Page 11: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/11.jpg)
11/21
September-October 2012
● PostgreSQL 9.3 (development branch using mmap)● DragonFly 3.0 and 3.1 (development, future 3.2)● Dual-Xeon, 24 threads, 24GB RAM● Benchmark● Find bottleneck● Fix or tweak● Repeat● Very time consuming
![Page 12: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/12.jpg)
12/21
September-October 2012 (2)
1 3 6 9 12 15 18 24 32 48 64 800
20000
40000
60000
80000
100000
120000
140000
160000
180000
PostgreSQL 9.3 performance
DragonFly-3.0
Scientific Linux 6.2
clients
tps
![Page 13: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/13.jpg)
13/21
September-October 2012 (3)
1 3 6 9 12 15 18 24 32 48 64 800
20000
40000
60000
80000
100000
120000
140000
160000
180000
PostgreSQL 9.3 performance
DragonFly-3.0
DragonFly 3.2
Scientific Linux 6.2
clients
tps
![Page 14: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/14.jpg)
14/21
September-October 2012 (4)
● Mihai Carabas added a CPU topology framework to the kernel (work sponsored by Google)
● Old BSD scheduler changed to take this information into account
● Still significant limitations due to the original design
● The scheduler itself was single-threaded
![Page 15: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/15.jpg)
15/21
September-October 2012 (5)
● Matt Dillon wrote a new scheduler● Schedules processes as close as possible to the
place they were last run on● Avoids unnecessary competition for resources● Doesn't use different hardware threads from the
same CPU core at the same time if possible● Globally balances the load and takes the
machine topology into account to avoid hot spots
![Page 16: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/16.jpg)
16/21
September-October 2012 (6)
● Other improvements● Many default values tuned for new 64-bit
machines (buffer cache)● PMAP MMU optimizations. Avoids having to
fault huge amounts of pages for processes using shared memory.
● Read shortcuts through the VM subsystem
![Page 17: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/17.jpg)
17/21
September-October 2012 (7)
1 3 6 9 12 15 18 24 32 48 64 800
20000
40000
60000
80000
100000
120000
140000
160000
180000
PostgreSQL 9.3 performance : various improvements
DragonFly-3.0
pmap mmu optimize
vm_read_shortcut
DragonFly 3.2 (new scheduler)
clients
tps
![Page 18: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/18.jpg)
18/21
September-October 2012 (8)
● Performance improvements not PostgreSQL-specific
● Number of MP MMU invalidations globally reduced
● read() performance globally improved● Across the board improvements of performance
under load
![Page 19: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/19.jpg)
19/21
March 2014
● PostgreSQL 9.3, DragonFly 3.6.1● Dual-Xeon, 40 threads, 128GB RAM● No PostgreSQL-specific performance work this time● Improvements wrt DragonFly 3.2 likely caused by
analysis of Poudrière runs in 2013● Poudrière = package building tool originally from
FreeBSD● Very CPU + fork/exec + I/O intensive
![Page 20: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/20.jpg)
20/21
March 2014 (2)
1 5 10 15 20 25 30 35 40 60 800
50000
100000
150000
200000
250000
300000
350000
PostgreSQL 9.3 performance
DragonFly 3.6.1
Debian 7.0
Centos 6.5
Clients
TP
S
![Page 21: Improving DragonFly's performance with PostgreSQL by Francois Tigeot](https://reader030.fdocuments.us/reader030/viewer/2022032714/55ab12ba1a28ab39698b47f9/html5/thumbnails/21.jpg)
21/21
Thank you
● Questions ?