Firebird Tour 2017: Performance. Vlad Khorsun, Firebird Project

Similar documents
Firebird Tour 2017: Performance. Vlad Khorsun, Firebird Project

Firebird 3.0 statistics and plans

Advanced Trace API. Vlad Khorsun, Firebird Project. Advanced Trace API. Firebird Tour 2017

Diagnosing and fixing Firebird performance problems

Firebird in 2011/2012: Development Review

Firebird performance degradation: tests, myths and truth IBSurgeon, 2014

Firebird databases recovery and protection for enterprises and ISVs. Alexey Kovyazin, IBSurgeon

How Firebird transactions work

Working With Very Large Firebird Databases

TUNING LINUX, WINDOWS AND FIREBIRD FOR HEAVY WORKLOAD

Mastering the art of indexing

Column Stores vs. Row Stores How Different Are They Really?

STORING DATA: DISK AND FILES

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Orphans, Corruption, Careful Write, and Logging, or Gfix says my database is CORRUPT or Database Integrity - then, now, future

OS and Hardware Tuning

OS and HW Tuning Considerations!

12 Common Mistakes while Backing Up Databases

JANUARY 20, 2016, SAN JOSE, CA. Microsoft. Microsoft SQL Hekaton Towards Large Scale Use of PM for In-memory Databases

Field Testing Buffer Pool Extension and In-Memory OLTP Features in SQL Server 2014

Advanced Database Systems

The Btrfs Filesystem. Chris Mason

SSDs vs HDDs for DBMS by Glen Berseth York University, Toronto

Using Transparent Compression to Improve SSD-based I/O Caches

Switching to Innodb from MyISAM. Matt Yonkovit Percona

SRM-Buffer: An OS Buffer Management SRM-Buffer: An OS Buffer Management Technique toprevent Last Level Cache from Thrashing in Multicores

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Synergetics-Standard-SQL Server 2012-DBA-7 day Contents

TokuDB vs RocksDB. What to choose between two write-optimized DB engines supported by Percona. George O. Lorch III Vlad Lesin

MySQL Performance Optimization and Troubleshooting with PMM. Peter Zaitsev, CEO, Percona

Week 2: Tiina Niklander

The Google File System

SQL Server 2014: In-Memory OLTP for Database Administrators

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

OPERATING SYSTEM. Chapter 9: Virtual Memory

Scalable Concurrent Hash Tables via Relativistic Programming

GFS: The Google File System

Operating Systems, Fall

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

Past: Making physical memory pretty

Distributed Systems 16. Distributed File Systems II

SHRD: Improving Spatial Locality in Flash Storage Accesses by Sequentializing in Host and Randomizing in Device

VIRTUAL MEMORY READING: CHAPTER 9

Database Architecture 2 & Storage. Instructor: Matei Zaharia cs245.stanford.edu

Chapter 3 - Memory Management

ASN Configuration Best Practices

<Insert Picture Here> Filesystem Features and Performance

Chapter 8: Virtual Memory. Operating System Concepts

FILE SYSTEMS, PART 2. CS124 Operating Systems Fall , Lecture 24

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 15: Caching: Demand Paged Virtual Memory

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

! Design constraints. " Component failures are the norm. " Files are huge by traditional standards. ! POSIX-like

MySQL Database Scalability

Azor: Using Two-level Block Selection to Improve SSD-based I/O caches

ZBD: Using Transparent Compression at the Block Level to Increase Storage Space Efficiency

Chapter 10: Mass-Storage Systems

Build ETL efficiently (10x) with Minimal Logging

CS510 Operating System Foundations. Jonathan Walpole

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

Choosing Hardware and Operating Systems for MySQL. Apr 15, 2009 O'Reilly MySQL Conference and Expo Santa Clara,CA by Peter Zaitsev, Percona Inc

Storage Technologies - 3

Ext3/4 file systems. Don Porter CSE 506

Accelerating OLTP performance with NVMe SSDs Veronica Lagrange Changho Choi Vijay Balakrishnan

Disks, Memories & Buffer Management

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Parser. Select R.text from Report R, Weather W where W.image.rain() and W.city = R.city and W.date = R.date and R.text.

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Percona Live September 21-23, 2015 Mövenpick Hotel Amsterdam

IBM V7000 Unified R1.4.2 Asynchronous Replication Performance Reference Guide

File Systems. Kartik Gopalan. Chapter 4 From Tanenbaum s Modern Operating System

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

Build ETL efficiently (10x) with Minimal Logging

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Princeton University. Computer Science 217: Introduction to Programming Systems. The Memory/Storage Hierarchy and Virtual Memory

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

* Contributed while interning at SAP. September 1 st, 2017 PUBLIC

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

CS3600 SYSTEMS AND NETWORKS

Algorithms and Data Structures for Efficient Free Space Reclamation in WAFL

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 420, York College. November 21, 2006

CMSC424: Database Design. Instructor: Amol Deshpande

Caching and reliability

PostgreSQL Performance The basics

Build ETL efficiently (10x) with Minimal Logging

Shared snapshots. 1 Abstract. 2 Introduction. Mikulas Patocka Red Hat Czech, s.r.o. Purkynova , Brno Czech Republic

Operating Systems and Computer Networks. Memory Management. Dr.-Ing. Pascal A. Klein

Chapter 12: Query Processing. Chapter 12: Query Processing

<Insert Picture Here> DBA Best Practices: A Primer on Managing Oracle Databases

Using PostgreSQL in Tantan - From 0 to 350bn rows in 2 years

External Sorting. Chapter 13. Comp 521 Files and Databases Fall

Distributed File Systems II

What the Hekaton? In-memory OLTP Overview. Kalen Delaney

CSE506: Operating Systems CSE 506: Operating Systems

Inside the PostgreSQL Shared Buffer Cache

COS 318: Operating Systems. NSF, Snapshot, Dedup and Review

WHITEPAPER. Improve PostgreSQL Performance with Memblaze PBlaze SSD

InnoDB Scalability Limits. Peter Zaitsev, Vadim Tkachenko Percona Inc MySQL Users Conference 2008 April 14-17, 2008

Firebird Conference 2012

CSE 190D Database System Implementation

Transcription:

Firebird Tour 2017: Performance Vlad Khorsun, Firebird Project

About Firebird Tour 2017 Firebird Tour 2017 is organized by Firebird Project, IBSurgeon and IBPhoenix, and devoted to Firebird Performance. The Platinum sponsor is Moscow Exchange Tour's locations and dates: October 3, 2017 Prague, Czech Republic October 5, 2017 Bad Sassendorf, Germany November 3, 2017 Moscow, Russia

Platinum Sponsor Sponsor of «Firebird 2.5 SQL Language Reference» «Firebird 3.0 SQL Language Reference» «Firebird 3.0 Developer Guide» «Firebird 3.0 Operations Guide» Sponsor of Firebird 2017 Tour seminars www.moex.com

Replication, Recovery and Optimization for Firebird since 2002 Platinum Sponsor of Firebird Foundation Based in Moscow, Russia www.ib-aid.com

Engine internals Performance related changes in FB3 SMP-friendly Super Server Hash Join algorithm Improved nbackup synchronization Reduced number of Pointer Page fetches Delayed Header and\or TIP Page writes for read-only transactions 5

Performance related changes in FB3 ODS12 Primary and Secondary Data Pages Flag Swept for Data and Pointer Pages Allocate and free Data Pages by extents Extent is a group of 8 consecutive pages SCN Pages for physical backup 6

Test machine Benchmarks CPU: Intel i4770, 4/8 cores HDD: 2 SATA drives in RAID 1 (mirror) SSD: Samsung 850 Pro, SATA RAM: 16 GB OS: Windows 7 7

Benchmarks Test database Generated by TPCC load tool Physical parameters 8 KB page size 8.75 GB Forced Writes = ON Restored from the file copy before each test run Table Rows Data Pages CUSTOMER 3`000`000 235`808 DISTRICT 1`000 24 ITEM 100`000 1`520 STOCK 10`000`000 421`528 WAREHOUSE 100 2 8

Read-only, single table Test Query: SELECT COUNT(*) FROM STOCK Page cache 500`000 buffers Caching effect Direct read from disk, not cached by OS nor by Firebird HDD SSD Cached by OS, Firebird cache is empty all reads are from OS cache, no read from physical disk Fully cached by Firebird no reads at all 9

Read-only, single table Test Query: SELECT COUNT(*) FROM STOCK Time, s 50 45 40 35 30 25 20 15 10 5 0 Direct read from disk 43,42 41,87 46,33 39,28 30,68 28,99 HDD, not cached SSD, not cached Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 10

Direct read from disk HDD Read-only, single table Almost identical speed while FB3 is a bit faster than FB 2.5 SSD Due to extents allocation? FB 2.5 slower than on HDD! It requires extra investigation FB 3 30% faster on SSD As expected 11

Read-only, single table Test Query: SELECT COUNT(*) FROM STOCK 6 5,56 No reads from physical disk 5 4 4,01 4,23 4,22 Time, s 3 2 2,57 2,75 1 0 cached by OS cached by FB Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 12

Read-only, single table Firebird 3.0.0 is much slower than Firebird 2.5.8 Minimal cost of page access in Super Server before Firebird 3 is very cheap : just increment and decrement Minimal cost of page access in Super Server in Firebird 3 is much larger : four interlocked operations Firebird 3.0.2 is almost as fast as Firebird 2.5.8 Small internal cache of physical numbers of Data Pages Allows to avoid most accesses of Pointer Pages Reduces number of page accesses (fetches) almost two times 13

Read-only, single table Test Query: SELECT COUNT(*) FROM STOCK 25 000 000 20 000 000 Fetches 20 838 039 20 838 113 Fetches 15 000 000 10 000 000 11 675 220 5 000 000 0 Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 14

Query Read-only, LOOP JOIN PLAN SELECT W.W_NAME, SUM(S.S_QUANTITY), SUM(I.I_PRICE * S.S_QUANTITY) FROM WAREHOUSE W JOIN STOCK S ON W.W_ID = S.S_W_ID JOIN ITEM I ON S.S_I_ID = I.I_ID GROUP BY W.W_NAME SORT (JOIN ( W NATURAL, S INDEX (STOCK_PK), I INDEX (ITEM_PK))) Result set 100 rows 15

Read-only, LOOP JOIN Execution statistics Firebird 2.5.8 Firebird 3.0.2 Firebird 2.5.8 Firebird 3.0.2 Buffers 50 000 50 000 500 000 500 000 Fetches 70 015 390 60 413 829 70 015 390 60 413 828 Reads 10 188 968 10 300 878 0 0 Time 74,99 83,53 35,93 38,55 Per-table statistics Table Indexed Non-indexed ITEM 10 000 000 0 STOCK 10 000 000 0 WAREHOUSE 0 100 16

Read-only, LOOP JOIN Firebird 3 still 7-11% slower than Firebird 2.5 Firebird 3 makes a bit less fetches but not enough less to catch up Firebird 2.5 Table STOCK read all 10M records Using index far not efficient Table ITEMS read all 100K records 100 times! Using index far not efficient Plan and performance is very far from optimal Try to disable index access to avoid LOOP join? 17

Query Read-only, MERGE JOIN SELECT W.W_NAME, SUM(S.S_QUANTITY), SUM(I.I_PRICE * S.S_QUANTITY) FROM WAREHOUSE W JOIN STOCK S ON W.W_ID +0 = S.S_W_ID +0 JOIN ITEM I ON S.S_I_ID = I.I_ID +0 GROUP BY W.W_NAME Plan, Firebird 2.5.8 SORT (MERGE ( SORT (MERGE ( SORT (S NATURAL), SORT (I NATURAL)) ), SORT (W NATURAL)) ) 18

MERGE JOIN algorithm Read-only, MERGE JOIN Requires both input datasources to be sorted on the join columns Sort both inputs Join sorted data within one pass 19

Query Read-only, HASH JOIN SELECT W.W_NAME, SUM(S.S_QUANTITY), SUM(I.I_PRICE * S.S_QUANTITY) FROM WAREHOUSE W JOIN STOCK S ON W.W_ID +0 = S.S_W_ID +0 JOIN ITEM I ON S.S_I_ID = I.I_ID +0 GROUP BY W.W_NAME Plan, Firebird 3.0.2 SORT ( HASH ( HASH (S NATURAL, I NATURAL), W NATURAL ) ) 20

HASH JOIN algorithm Read-only, HASH JOIN Set larger datasource as left input, smaller datasource as right input Build hash table for the right (smaller) datasource Scan left datasource in natural order and probe hash table for matching rows 21

Read-only, MERGE vs HASH Execution statistics Firebird 2.5.8 Firebird 3.0.2 Firebird 2.5.8 Firebird 3.0.2 Buffers 50 000 50 000 500 000 500 000 Fetches 21 040 678 12 027 694 21 040 678 12 027 694 Reads 420 343 423 272 0 0 Time 29,48 23,02 28,27 21,54 Per-table statistics Table Indexed Non-indexed ITEM 0 100 000 STOCK 0 10 000 000 WAREHOUSE 0 100 22

Read-only, MERGE vs HASH Firebird 2.5, MERGE vs LOOP >23 times less reads (420K vs 10M) 3.5 times less fetches (21M vs 70M) Firebird 3, HASH vs LOOP >23 times less reads (423K vs 10M) 5 times less fetches (12M vs 60M) Both versions Much faster Almost independent on Firebird cache size Firebird 3 now >22% faster than Firebird 2.5 23

Read-only, LOOP vs MERGE vs HASH 50`000 buffers Time, s 100 80 60 40 20 74,99 83,53 29,48 23,02 Firebird 2.5.8 Firebird 3.0.2 0 Loop Join Merge\Hash Join 500`000 buffers Time, s 50 40 30 20 10 35,93 38,55 28,27 21,54 Firebird 2.5.8 Firebird 3.0.2 0 Loop Join Merge\Hash Join 24

Read-only, multi-threaded Multi-threaded read-only benchmark Table STOCK have 10'000'000 records 100 warehouses, 100'000 items in each Each reader reads random items in own warehouse We don't test network subsystem client application executes procedure, which selects a number of random items (100 by default) of the same warehouse SELECT * FROM BENCH_1 (:W_ID, 100) We don't test IO subsystem before each test series we ensure whole table STOCK is fully cached by filesystem We do test Firebird scalability 25

Read-only, multi-threaded CREATE OR ALTER PROCEDURE BENCH_1 ( W_ID INTEGER, NUM INTEGER) RETURNS ( I_ID INTEGER) AS DECLARE I1 INTEGER; BEGIN WHILE (NUM > 0) DO BEGIN I1 = RAND() * (100000 1); SELECT S.S_I_ID FROM STOCK S WHERE S.S_W_ID = :W_ID AND S.S_I_ID = :I1 INTO :I_ID; SUSPEND; NUM = NUM 1; END END 26

Read-only, multi-threaded Multi-threaded read-only benchmark Firebird versions 2.5.8 base version for comparison 3.0.0 first release of v3, have some perf problems 3.0.2 current release of v3, have some improvements Super Server default cache size (2 048) medium cache size (50 000) huge cache size (500 000) Classic big cache size (2 048) SuperClassic for Firebird 2.5 Classic mode for Firebird 3 27

Read-only, multi-threaded Different modes within same version 2 500 Exec\sec Firebird 2.5.8 2 000 1 500 1 000 500 0 1 2 4 8 16 32 64 100 SS 2048 SS 50000 SS 500000 SC 2048 Threads 28

Read-only, multi-threaded Different modes within same version 4 000 3 500 3 000 2 500 2 000 1 500 1 000 500 Exec\sec Firebird 3.0.0 0 1 2 4 8 16 32 64 100 Threads SS 2048 SS 50000 SS 500000 CS 2048 29

Read-only, multi-threaded Different modes within same version 4 500 4 000 3 500 3 000 2 500 2 000 1 500 1 000 500 Exec\sec Firebird 3.0.2 0 1 2 4 8 16 32 64 100 Threads SS 2048 SS 50000 SS 500000 CS 2048 30

Read-only, multi-threaded Different versions, same mode 1 600 1 400 1 200 1 000 800 600 400 200 Exec\s Super Server, cache 2048 0 1 2 4 8 16 32 64 100 Threads Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 31

Read-only, multi-threaded Different versions, same mode 2 500 Exec\s Super Server, cache 50000 2 000 1 500 1 000 500 0 1 2 4 8 16 32 64 100 Threads Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 32

Read-only, multi-threaded Different versions, same mode 4 500 4 000 3 500 3 000 2 500 2 000 1 500 1 000 500 Exec\s Super Server, cache 500000 0 1 2 4 8 16 32 64 100 Threads Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 33

Read-only, multi-threaded Different versions, same mode 2 500 Exec\s Classic, cache 2048 2 000 1 500 1 000 500 0 1 2 4 8 16 32 64 100 Threads Firebird 2.5.8 Firebird 3.0.0 Firebird 3.0.2 34

Read-only, multi-threaded Super Classic 2.5.8 scales well up to 8 threads, keeps the performance at 16 threads and then performance drops Classic v3 scales to the almost same level as 2.5.8 but degrades in less degree Super v3 with small and medium cache run a bit worse than Classic v3 Super 3.0.0 with huge cache scales up to 8 threads, then performance drops significantly Super 3.0.2 with huge cache scales well up to 8 threads, slightly adds at 16 threads and then performance drops less than by 4% (for 100 threads) Super 3.0.2 with huge cache works two times faster than Classic 35

TPCC benchmark TPCC database Generated by TPCC load tool 100 warehouses Standard scaling factor Physical parameters 8 KB page size 8.75 GB Forced Writes = ON Restored from the file copy before each test run 36

TPCC benchmark TPCC test parameters Terminals: 1, 2, 4, 8, 16, 32, 64, 100 Each terminal uses own connection Each terminal works within own thread Whole test time: 35 min Warm time: 5 min Steady time: 30 min Measurements: every 10 sec 37

TPCC benchmark What Firebird architectures to test? Firebird 2.5.8 base for comparison, choose better one Super Server no, it doesn t scale well Classic Server or Super Classic Super Classic is faster Firebird 3.0.2 Super yes, sure? Classic yes, lets compare it with 2.5 Classic Server SuperClassic no, it have no benefits in v3 as it was in v2.5 38

TPCC benchmark Firebird configuration Local protocol (XNET) Super Classic 2.5.8 and Classic Server 3.0.2 Page cache = 1 024 Super Server 3.0.2 Page cache = 524 288 (4GB) FileSystemCacheThreshold = 1 073 741 824 (8TB) My mistake, planned to set it to 1 048 576 pages (8GB), but it not changes final results TempCacheLimit = 1 073 741 824 (1GB) LockHashSlots = 22 111 GCPolicy = cooperative cooperative is best choice for TPCC load 39

TPCC, scaling 60 000 TpmC Classic Servers 50 000 40 000 30 000 20 000 10 000 0 1 2 4 8 16 32 64 100 Terminals Firebird 2.5.8 SC Firebird 3.0.2 CS 40

TPCC, scaling 60 000 TpmC Firebird 3.0.2 Super Server 50 000 40 000 30 000 20 000 10 000 0 1 2 4 8 16 32 64 100 Terminals With filesystem cache No filesystem cache 41

TPCC, scaling 60 000 TpmC All together 50 000 40 000 30 000 20 000 10 000 0 1 2 4 8 16 32 64 100 Firebird 2.5.8 SC Firebird 3.0.2 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) Terminals 42

TPCC Scalability is very important factor, but not the only one Good database engine should also Avoid performance degradation over time Deliver stable performance (with small or no fluctuations) Ensure equal performance for every connection with the same queries etc 43

TPCC, load over time 60 000 TpmC TPCC, 64 terminals 50 000 40 000 30 000 20 000 10 000 0 Firebird 2.5.8 SC Firebird 3.0.2 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) time, sec 44

TPCC, load over time 60 000 TpmC TPCC, 100 terminals 50 000 40 000 30 000 20 000 10 000 0 Firebird 2.5.8 SC Firebird 3.0.2 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) time, sec 45

TPCC and Sweep Test A Goal: evaluate pure sweep performance Run sweep on clean database Run TPCC test Run sweep on dirty database 46

TPCC and Sweep 200 180 160 140 120 100 80 Sweep time, sec 101 166 141 Sweep 77 125 173 160 87 156 184 60 40 20 0 13 51 Clean Dirty, 64 terminals Dirty, 100 terminals Firebird 2.5.8 SC Firebird 3.0.2 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) 47

TPCC and Sweep Why sweep in Firebird 3 is much slower than Firebird 2.5 on clean database? Firebird 2.5 just read database, no writes happens Database file is fully cached by OS Firebird 3 set swept flag on every Data Page when run first time after data is loaded After swept flag is set next sweep run in near zero time 48

TPCC and Sweep Why v3 in Super mode sweeps clean database two times longer than v3 in Classic mode? When Firebird allocates page cache (4GB) OS take some memory from fully cached database file. Thus Firebird needs to read pages from disk, not from the file system cache. When database cache was reset to default 2048 pages, Super run sweep in the same 50 seconds as Classic Flash algorithm works sub-optimal with a huge cache used in Super mode To be fixed in Firebird 3.0.3 Quick fix reduced sweep time from 110 to 80 sec 49

TPCC and Sweep Test B Goal: evaluate engine and sweep performance with high load Run sweep on clean database Run TPCC test Run sweep every 5 minutes Run sweep on dirty database 50

TPCC and Sweep Firebird 3.0.2 Problems found Sweep under load in Classic mode is very slow, looks like lock starvation problem. Quick fix is ready, but issue requires more investigations. Test B uses Firebird 3.0.3 in Classic mode with quick fix. With fix it runs a bit slower 51

TPCC and sweep, load over time 30 000 TpmC TPCC + sweep, 64 terminals, Classic Server 25 000 20 000 15 000 10 000 5 000 0 Firebird 2.5.8 SC Firebird 3.0.3 CS time, sec 52

TPCC and sweep, load over time Firebird in Classic mode Affected slightly by the sweep Performance drops about 10% and restored after the sweep 53

TPCC and sweep, load over time 60 000 TpmC TPCC + sweep, 64 terminals, Super Server 50 000 40 000 30 000 20 000 10 000 0 Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) time, sec 54

TPCC and sweep, load over time Firebird in Super mode Performance drops significantly when sweep starts Should be investigated Performance restored relatively quickly (20-30 sec), much before sweep end (50-90 sec) 55

TPCC and sweep, load over time 60 000 TpmC TPCC + sweep, 64 terminals, all together 50 000 40 000 30 000 20 000 10 000 0 Firebird 2.5.8 SC Firebird 3.0.3 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) time, sec 56

TPCC and sweep, load over time 160 140 Sweep time, sec 134 TPCC + sweep, 64 terminals 120 110 109 100 80 60 53 69 50 68 91 93 80 81 83 83 76 73 72 75 71 73 66 86 88 84 40 20 13 36 34 27 21 0 Clean 1 2 3 4 5 Dirty Firebird 2.5.8 SC Firebird 3.0.3 CS Firebird 3.0.2 SS (FS+) Firebird 3.0.2 SS (FS-) 57

TPCC and sweep, load over time Firebird 3 run first sweep pass slow as it requires to mark all Data Pages as swept On heavy loaded system sweep run faster in Firebird 3 Super mode with huge own cache and file system support sweep time greater than Classic mode, but note Super make >70% more transactions and produces more work for sweep to do Super mode with huge own cache and with no file system support Runs faster under load Slow when Firebird cache is empty It is expected 58

Test TPCC and nbackup Goal: evaluate engine and nbackup performance with high load Run TPCC test After warm-up period run nbackup level 0 Every 5 minutes run nbackup and increment backup level All backup files are stored on separate from main database disk drive 59

TPCC and nbackup File system cache nbackup utility reads database file itself, i.e. not using Firebird page cache Switch -DIRECT ON don t use file system cache, default on Windows OFF use file system cache, default on Linux When cached file opens without buffering, Windows removes it from file system cache immediately With default settings, nbackup usage will remove database file from file system cache (on Windows) 60

File system cache We run nbackup with TPCC and nbackup -DIRECT OFF for Classics and for Super, when it run with support of file system cache -DIRECT ON for Super, when it run with no support of file system cache Firebird 2.5.8 SC Firebird 3.0.3 SS (FS+) Firebird 3.0.3 CS Firebird 3.0.3 SS (FS-) File system cache used used used not used -DIRECT OFF OFF OFF ON 61

TPCC and nbackup Firebird 3.0.2 Problems found and fixed CORE-5613: SuperServer could hung when changing physical backup state under high load CORE-5614: Physical backup merge stage could run too long, especially with huge page cache TPCC and nbackup tests done using current snapshot build of Firebird 3.0.3 62

TPCC and nbackup 30 000 TpmC TPCC + nbackup, Classic, 64 terminals 25 000 20 000 15 000 10 000 5 000 0 Firebird 2.5.8 SC Firebird 3.0.3 CS time, sec 63

Classic v2.5 vs v3 TPCC and nbackup Firebird performance drops significantly when physical backup run Firebird 3 suffers in much less degree than Firebird 2.5 64

TPCC and nbackup 60 000 TpmC TPCC + nbackup, Super, 64 terminals 50 000 40 000 30 000 20 000 10 000 0 Firebird 3.0.3 SS (FS+) Firebird 3.0.3 SS (FS-) time, sec 65

TPCC and nbackup Super v3: with\without file system cache File system cache support helps physical backup to run faster With file system cache performance drops less Even without file system cache performance is better than in Classic v2.5 66

TPCC and nbackup 120 100 80 60 40 20 0 10000 8000 Backup time, sec 56 57 54 91 38 TPCC + nbackup, 64 terminals 104 103 104 106 32 33 34 24 15 15 14 14 14 8 8 8 9 9 0 1 2 3 4 5 Backup file size, MB 6000 4000 2000 9029,75 9164,75 9 043,25 9144,75 2570,68 3267,82 2597,27 3569,34 2602,9 3209,02 2592,41 3531,51 2571,03 3091,42 2614,79 3447,59 2548,78 3083,7 2669,00 3462,36 2429,82 3083,99 2613,44 0 0 1 2 3 4 5 Firebird 2.5.8 SC Firebird 3.0.3 SS (FS+) Backup level Firebird 3.0.3 CS Firebird 3.0.3 SS (FS-) 67

Firebird 4 Performance features in Firebird 4 New Batch API Pool for external connections of EXECUTE STATEMENT Implementation available in HQbird Server-side cache of SQL statements Implementation available in HQbird Garbage collection of intermediate record versions 68

Firebird 4 New Batch API Send single query with multiply set of params Including BLOB s Expected benefits Radical less number of network roundtrips Usage Import tools gbak restore Current availability Separate branch batch in Firebird source tree on GitHub 69

External connections pool Firebird 4 EXECUTE STATEMENT ON EXTERNAL DATA SOURCE Put unused external connection into pool Lookup for the new external connection at pool Check for connection string, user name, role, password Hash used for fast search connection liveness Broken connection silently removed from pool 70

Firebird 4 External connections pool, properties Scope : single pool instance per server process Super and SuperClassic modes : all local connections uses same pool of external connections despite of local database Classic mode : each Firebird process contains own pool Common for all external databases To be discussed 71

Firebird 4 External connections pool, properties Limited number of inactive (unused) external connections Use LRU algorithm when pool is full Limit could be changed by DBA Limited lifetime of inactive external connection Free inactive external connections after specified time Lifetime could be changed by DBA 72

Firebird 4 External connections pool, management Manage pool properties using new DDL-like statement ALTER EXTERNAL CONNECTIONS POOL SET SIZE SET LIFETIME CLEAR ALL CLEAR OLDEST It could be changed in release version? 73

Firebird 4 External connections pool, management Query pool state with RDB$GET_CONTEXT() Namespace : SYSTEM Variables : EXT_CONN_POOL_SIZE EXT_CONN_POOL_IDLE_COUNT EXT_CONN_POOL_ACTIVE_COUNT EXT_CONN_POOL_LIFETIME Support in monitoring tables to be discussed 74

External connections pool Benefits Firebird 4 Radical less connection time when using EXECUTE STATEMENT with external databases Much lower network and CPU load Usage Any application intensively works with external queries Current availability HQBird 2.5 Firebird 4 (soon) 75

Firebird 4 Server-side cache of SQL statements Put unused SQL statement into statements cache isc_dsql_free_statement(..., DSQL_drop) Release of last reference on IStatement or IResultSet Lookup cache when preparing new SQL statement Explicit prepare isc_dsql_prepare() IAttachment::prepare() Implicit prepare isc_dsql_execute_immediate() IAttachment::execute(), IAttachment::openCursor() Check for Hash of SQL statement text SQL statement text itself 76

Firebird 4 SQL statements cache, properties Scope Attachment Each attachment have its own cache of SQL statements Limits Number of statements in cache Set using firebird.conf Could be changed in Firebird release version? DML statements only No sense to cache DDL statements 77

Firebird 4 SQL statements cache LRU algorithm defines which statement to keep in cache Freed by application statement put into head of LRU list If cache already full, statement from the tail of the LRU list is removed and released It allows to keep in cache statements that really often used by application To be discussed before include into Firebird: Control memory usage not number of statements? Manage limits in run-time Support in monitoring tables 78

SQL statements cache Firebird 4 Benefits Instant time of prepare of most often used SQL statements Much lower network and CPU load Use cases Application that not re-used prepared statements by itself Application that can t use prepared statements Connections pool at client side often makes it impossible Place to improve connections pool at client side? Current availability HQBird 3 79

Firebird 4 Garbage collection of intermediate record versions Allows to clean up inner versions at version chain Benefits Keep record versions chains short, despite of long running transactions Performance stability less affected by apps with bad transactions management Usage All kind of applications Current availability Branch read_consistency at redsoftbiz/firebird fork: https://github.com/redsoftbiz/firebird.git Could be included into v4 beta1 80

THANK YOU FOR ATTENTION Questions? Firebird official web site Firebird tracker hvlad@users.sf.net 81