Threading through InterBase, Firebird, and beyond

Mind The Firebird
Mind The FirebirdLead at charity
Threading in Firebird and the Future 
Ann W. Harrison 
James A. Starkey
A Word of Thanks to our Sponsors
Why Threads? 
Improve multi-user performance 
Utilize multi-processor systems 
Databases are too easy to multi-thread
What are Atomic Instructions? 
Most machine instructions can be interrupted, allowing 
the world to change. 
Atomic instructions (e.g. CAS) run to completion. 
Essential for multi-thread performance.
Wasn’t Firebird Always Threaded? 
Earliest versions of shared server ran query for one 
user until it stalled before responding to next user. 
Not friendly. 
Multi-threaded server runs to the next wait or for a fixed 
period plus the time to make the database state 
consistent. 
Threads never run concurrently.
Firebird Classic 
Designed for VAX Clusters 
Multiple independent computers 
Shared intelligent disk controller 
Cluster-wide lock manager
Firebird Classic Multi-Processor 
Single Machine, Multi-Processor 
O/S schedules Firebird clients on processors 
Clients share 
Disk 
Lock manager 
Clients do not share 
Page Cache 
Metadata
Non-shared cache 
Firebird classic, super classic 
Client B wants 
page 123 
Client A changed 
page 123 
Yes, that is really a disk write
Shared cache - Superserver 
Client A changed 
page 123 
Client B wants 
page 123 
Client A releases 
lock on page 123 
Client B locks 
page 123 
1 
2 
3
Threading, 101 
Thread 
PC: Instruction stream of control 
Dedicated Stack (1 mb+) 
Thread specific data 
All threads share process memory 
Expensive to create, cheap to use 
(If you don’t thrash)
Threading 101 
Interlocked Instruction: Atomic compare and swap 
Compares given value to value at given address 
If equal, store new value at given address 
If not, fails and does nothing 
Interlocked instructions are the mortar of multi-threading
Threading 101 
Non-interlocked data structures 
Data structures managed only by interlocked 
instructions 
Completely non-blocking 
The fastest – and hardest – form of multi-programming
Threading 101 
RW-lock, aka SyncObject 
Can be locked for read/shared 
Can be locked for write/exclusive 
Blocks until access can be granted 
Monitor semantics: Thread doesn’t lock against itself 
Implemented with interlocked CAS
Threading 101 
Coarse grain multi-threading 
Single mutex controls an entire subsystem 
Individual data structures are not interlocked 
Fine grain multi-threading 
Individual RW-lock per data structure 
Allows many threads to share a subsystem
Threading 101 
Dedicated Thread 
Thread assigned specific task 
Garbage collector, network listener, etc. 
Client thread 
Thread executing user request 
Worker Thread 
Thread idle or executing user request 
Thread pool 
Manages worker threads
Threading Models 
Thread per connection 
Worker thread assigned at connection time 
Worker thread == Client thread 
Idle client threads consume resources 
Many connections => high contention
Threading Models 
Limited worker threads 
Limit active worker threads to approx. number of 
processors 
User requests queued until work thread becomes 
available 
If worker thread stalls (page read), thread pool can 
release next user request 
Utilizes processors without unnecessary contention
Threading Models 
Limited Worker Threads: 
Dedicated listener thread waits for readable socket 
Connection object (on listener thread) does socket 
read 
When packet is complete, connection object queue 
to thread pool 
When worker thread becomes available, connection 
object is executed
Threading Model 
Thread per connection is first step 
Limited worker threads is essential for scalability
Interbase Threads: The Beginning 
The concept of threads was known at the birth of 
Interbase, but no implementations existed on small 
machines. 
SMP didn’t exist in the mini or workstation world 
The initial version of Interbase used signals for 
communication 
User requests executed with “looper”; when a request 
stalled, another request could run
Interbase Theads: The V3 Disaster 
Apollo was the first workstation vendor with threads 
I implemented a VMS threading package 
Sun’s first attempt at threads didn’t even compile 
Interbase V3 was going to be mixed signals + threads 
Then disaster: Apollo Domain had unfixable 
architectural flaw mixing threads and signals 
A long slip ensued
Interbase Threads: V3 Reborn 
The engine was either threaded or signal based 
Dedicated threads for lock manager, event manager, 
etc. 
Server was thread per client 
Engine continued with coarse grain multi-threading
Firebird Threading: Vulcan 
Vulcan, now deceased, introduced limited fine grain 
multi-threading 
Threads synchronized with SyncObject: User mode 
read/write locks with monitor semantics 
SMP had arrived, followed shortly by processor based 
threads
Some Performance Lessons 
The goal is to saturate CPU, network, memory, and disk 
bandwidth simultaneously. 
There is no reason to run more worker threads than 
cores (and many reasons not to), but 
A stalled thread is an efficient way to maintain request 
state (death to “looper”!)
A Winning Architecture 
A single dedicated thread waiting for readable sockets 
Request starts are posted to thread manager for 
available worker thread 
When active worker threads drops below threshold, a 
pending request is assigned a worker thread 
A stalling thread checks in with thread manager to drop 
the number of active worker threads 
An unstalled request bumps the number of a.w.t.
1 of 25

Recommended

Orphans, Corruption, Careful Write, and Logging by
Orphans, Corruption, Careful Write, and LoggingOrphans, Corruption, Careful Write, and Logging
Orphans, Corruption, Careful Write, and LoggingMind The Firebird
1.5K views29 slides
Using ТРСС to study Firebird performance by
Using ТРСС to study Firebird performanceUsing ТРСС to study Firebird performance
Using ТРСС to study Firebird performanceMind The Firebird
1.9K views56 slides
Java script anywhere. What Nombas was doing pre-acquisition. by
Java script anywhere. What Nombas was doing pre-acquisition.Java script anywhere. What Nombas was doing pre-acquisition.
Java script anywhere. What Nombas was doing pre-acquisition.Brent Noorda
1.7K views27 slides
Debugging the Web with Fiddler by
Debugging the Web with FiddlerDebugging the Web with Fiddler
Debugging the Web with FiddlerIdo Flatow
976 views36 slides
Effectively Deploying MongoDB on AEM by
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMNorberto Leite
1.3K views61 slides
Lessons Learned From Running Spark On Docker by
Lessons Learned From Running Spark On DockerLessons Learned From Running Spark On Docker
Lessons Learned From Running Spark On DockerSpark Summit
15.5K views17 slides

More Related Content

What's hot

Right-Sizing your SQL Server Virtual Machine by
Right-Sizing your SQL Server Virtual MachineRight-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual Machineheraflux
6.9K views46 slides
AEM WITH MONGODB by
AEM WITH MONGODBAEM WITH MONGODB
AEM WITH MONGODBNate Nelson
1.9K views15 slides
Breaking IO Performance Barriers: Scalable Parallel File System for AWS by
Breaking IO Performance Barriers: Scalable Parallel File System for AWSBreaking IO Performance Barriers: Scalable Parallel File System for AWS
Breaking IO Performance Barriers: Scalable Parallel File System for AWSAmazon Web Services
3.3K views27 slides
Migrate Oracle database to Amazon RDS by
Migrate Oracle database to Amazon RDSMigrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDSJesus Guzman
717 views20 slides
Bcache and Aerospike by
Bcache and AerospikeBcache and Aerospike
Bcache and AerospikeAnshu Prateek
10.2K views28 slides
Wordpress optimization by
Wordpress optimizationWordpress optimization
Wordpress optimizationAlmog Baku
26.6K views51 slides

What's hot(20)

Right-Sizing your SQL Server Virtual Machine by heraflux
Right-Sizing your SQL Server Virtual MachineRight-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual Machine
heraflux6.9K views
AEM WITH MONGODB by Nate Nelson
AEM WITH MONGODBAEM WITH MONGODB
AEM WITH MONGODB
Nate Nelson1.9K views
Breaking IO Performance Barriers: Scalable Parallel File System for AWS by Amazon Web Services
Breaking IO Performance Barriers: Scalable Parallel File System for AWSBreaking IO Performance Barriers: Scalable Parallel File System for AWS
Breaking IO Performance Barriers: Scalable Parallel File System for AWS
Amazon Web Services3.3K views
Migrate Oracle database to Amazon RDS by Jesus Guzman
Migrate Oracle database to Amazon RDSMigrate Oracle database to Amazon RDS
Migrate Oracle database to Amazon RDS
Jesus Guzman717 views
Bcache and Aerospike by Anshu Prateek
Bcache and AerospikeBcache and Aerospike
Bcache and Aerospike
Anshu Prateek10.2K views
Wordpress optimization by Almog Baku
Wordpress optimizationWordpress optimization
Wordpress optimization
Almog Baku26.6K views
Life in the fast lane. Full speed XPages by Ulrich Krause
Life in the fast lane. Full speed XPagesLife in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPages
Ulrich Krause13.1K views
Life In The FastLane: Full Speed XPages by Ulrich Krause
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPages
Ulrich Krause7.3K views
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB by MongoDB
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB
MongoDB6.8K views
Provisioning and automating high availability postgres on aws ec2 (1) by Payal Singh
Provisioning and automating high availability postgres on aws ec2 (1)Provisioning and automating high availability postgres on aws ec2 (1)
Provisioning and automating high availability postgres on aws ec2 (1)
Payal Singh1.8K views
Aem dispatcher – tips & tricks by Ashokkumar T A
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A5.4K views
PowerDNS with MySQL by I Goo Lee
PowerDNS with MySQLPowerDNS with MySQL
PowerDNS with MySQL
I Goo Lee1K views
Migrating enterprise workloads to AWS by Tom Laszewski
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
Tom Laszewski9.1K views
Geographically Distributed Multi-Master MySQL Clusters by Continuent
Geographically Distributed Multi-Master MySQL ClustersGeographically Distributed Multi-Master MySQL Clusters
Geographically Distributed Multi-Master MySQL Clusters
Continuent2.5K views
Deep Dive into RDS PostgreSQL Universe by Jignesh Shah
Deep Dive into RDS PostgreSQL UniverseDeep Dive into RDS PostgreSQL Universe
Deep Dive into RDS PostgreSQL Universe
Jignesh Shah672 views
Cassandra Summit 2014: Deploying Cassandra for Call of Duty by DataStax Academy
Cassandra Summit 2014: Deploying Cassandra for Call of DutyCassandra Summit 2014: Deploying Cassandra for Call of Duty
Cassandra Summit 2014: Deploying Cassandra for Call of Duty
DataStax Academy2.9K views
Scaling Up and Out your Virtualized SQL Servers by heraflux
Scaling Up and Out your Virtualized SQL ServersScaling Up and Out your Virtualized SQL Servers
Scaling Up and Out your Virtualized SQL Servers
heraflux726 views
From 100s to 100s of Millions by Erik Onnen
From 100s to 100s of MillionsFrom 100s to 100s of Millions
From 100s to 100s of Millions
Erik Onnen12.1K views
J2EE Performance And Scalability Bp by Chris Adkin
J2EE Performance And Scalability BpJ2EE Performance And Scalability Bp
J2EE Performance And Scalability Bp
Chris Adkin3K views

Viewers also liked

How does Linked Open Data change the publishing landscape? by
How does Linked Open Data change the publishing landscape?How does Linked Open Data change the publishing landscape?
How does Linked Open Data change the publishing landscape?Quentin Reul
3.2K views29 slides
FHWA MOU with the State of Alaska Regarding Delegation of CEs. by
FHWA MOU with the State of Alaska Regarding Delegation of CEs.FHWA MOU with the State of Alaska Regarding Delegation of CEs.
FHWA MOU with the State of Alaska Regarding Delegation of CEs.artba
684 views2 slides
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet... by
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...artba
953 views5 slides
Artba Senate Finance Committee May by
Artba Senate Finance Committee MayArtba Senate Finance Committee May
Artba Senate Finance Committee Mayartba
1K views11 slides
Accessibility Matters: Making Your Product Available to Everyone by
Accessibility Matters: Making Your Product Available to EveryoneAccessibility Matters: Making Your Product Available to Everyone
Accessibility Matters: Making Your Product Available to EveryoneChar James-Tanny
451 views31 slides
09/25/13: Senate EPW Highway Trust Fund Hearing by
09/25/13: Senate EPW Highway Trust Fund Hearing09/25/13: Senate EPW Highway Trust Fund Hearing
09/25/13: Senate EPW Highway Trust Fund Hearingartba
937 views17 slides

Viewers also liked(20)

How does Linked Open Data change the publishing landscape? by Quentin Reul
How does Linked Open Data change the publishing landscape?How does Linked Open Data change the publishing landscape?
How does Linked Open Data change the publishing landscape?
Quentin Reul3.2K views
FHWA MOU with the State of Alaska Regarding Delegation of CEs. by artba
FHWA MOU with the State of Alaska Regarding Delegation of CEs.FHWA MOU with the State of Alaska Regarding Delegation of CEs.
FHWA MOU with the State of Alaska Regarding Delegation of CEs.
artba684 views
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet... by artba
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...
Coalition Letter to Senate Majority Leader McConnell (R-Ky) on Chemical Safet...
artba953 views
Artba Senate Finance Committee May by artba
Artba Senate Finance Committee MayArtba Senate Finance Committee May
Artba Senate Finance Committee May
artba1K views
Accessibility Matters: Making Your Product Available to Everyone by Char James-Tanny
Accessibility Matters: Making Your Product Available to EveryoneAccessibility Matters: Making Your Product Available to Everyone
Accessibility Matters: Making Your Product Available to Everyone
Char James-Tanny451 views
09/25/13: Senate EPW Highway Trust Fund Hearing by artba
09/25/13: Senate EPW Highway Trust Fund Hearing09/25/13: Senate EPW Highway Trust Fund Hearing
09/25/13: Senate EPW Highway Trust Fund Hearing
artba937 views
Suggested Best Practices for Design-Build in Transportation Construction by artba
Suggested Best Practices for Design-Build in Transportation ConstructionSuggested Best Practices for Design-Build in Transportation Construction
Suggested Best Practices for Design-Build in Transportation Construction
artba1.4K views
Accessibility Matters - Supplemental Links by Char James-Tanny
Accessibility Matters - Supplemental LinksAccessibility Matters - Supplemental Links
Accessibility Matters - Supplemental Links
Char James-Tanny307 views
Coalition Letter to House Energy and Commerce Committee Leaders on Chemical S... by artba
Coalition Letter to House Energy and Commerce Committee Leaders on Chemical S...Coalition Letter to House Energy and Commerce Committee Leaders on Chemical S...
Coalition Letter to House Energy and Commerce Committee Leaders on Chemical S...
artba924 views
02/12/14: Testimony to Senate Environment & Public Works Committee by artba
02/12/14: Testimony to Senate Environment & Public Works Committee02/12/14: Testimony to Senate Environment & Public Works Committee
02/12/14: Testimony to Senate Environment & Public Works Committee
artba893 views
Coalition Comments on OSHA Clarification to Workplace Injury and Illness Regu... by artba
Coalition Comments on OSHA Clarification to Workplace Injury and Illness Regu...Coalition Comments on OSHA Clarification to Workplace Injury and Illness Regu...
Coalition Comments on OSHA Clarification to Workplace Injury and Illness Regu...
artba734 views
Comments Objecting to ESA protections for the Long-Eared Bat by artba
Comments Objecting to ESA protections for the Long-Eared BatComments Objecting to ESA protections for the Long-Eared Bat
Comments Objecting to ESA protections for the Long-Eared Bat
artba804 views
Multi-Industry Letter to Congress on EPA Ozone Standards by artba
Multi-Industry Letter to Congress on EPA Ozone StandardsMulti-Industry Letter to Congress on EPA Ozone Standards
Multi-Industry Letter to Congress on EPA Ozone Standards
artba649 views
Technical Delivery - Expanded Role for Technical Communicators, STC New Engla... by Todd DeLuca, MTSC
Technical Delivery - Expanded Role for Technical Communicators, STC New Engla...Technical Delivery - Expanded Role for Technical Communicators, STC New Engla...
Technical Delivery - Expanded Role for Technical Communicators, STC New Engla...
Todd DeLuca, MTSC565 views
New York Times Ad opposing tighter ozone standards by artba
New York Times Ad opposing tighter ozone standardsNew York Times Ad opposing tighter ozone standards
New York Times Ad opposing tighter ozone standards
artba738 views
The Experience Comes First (STC New England - InterChange2016) by Deborah Sauer
The Experience Comes First (STC New England - InterChange2016)The Experience Comes First (STC New England - InterChange2016)
The Experience Comes First (STC New England - InterChange2016)
Deborah Sauer262 views

Similar to Threading through InterBase, Firebird, and beyond

Os by
OsOs
OsDeepaR42
70 views15 slides
W-9.pptx by
W-9.pptxW-9.pptx
W-9.pptxalianwarr
3 views16 slides
Operating System 4 by
Operating System 4Operating System 4
Operating System 4tech2click
3.2K views37 slides
Operating System 4 1193308760782240 2 by
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2mona_hakmy
1.2K views37 slides
Chorus - Distributed Operating System [ case study ] by
Chorus - Distributed Operating System [ case study ]Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]Akhil Nadh PC
3K views85 slides
Multithreading 101 by
Multithreading 101Multithreading 101
Multithreading 101Tim Penhey
2.6K views45 slides

Similar to Threading through InterBase, Firebird, and beyond(20)

Operating System 4 by tech2click
Operating System 4Operating System 4
Operating System 4
tech2click3.2K views
Operating System 4 1193308760782240 2 by mona_hakmy
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
mona_hakmy1.2K views
Chorus - Distributed Operating System [ case study ] by Akhil Nadh PC
Chorus - Distributed Operating System [ case study ]Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]
Akhil Nadh PC3K views
Multithreading 101 by Tim Penhey
Multithreading 101Multithreading 101
Multithreading 101
Tim Penhey2.6K views
Parallel Computing - Lec 3 by Shah Zaib
Parallel Computing - Lec 3Parallel Computing - Lec 3
Parallel Computing - Lec 3
Shah Zaib29 views
Intro To .Net Threads by rchakra
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
rchakra2.3K views
Achieving mass scale with Quasar Fibers by Idan Sheinberg
Achieving mass scale with Quasar FibersAchieving mass scale with Quasar Fibers
Achieving mass scale with Quasar Fibers
Idan Sheinberg807 views
Chapter04 new by vmummaneni
Chapter04 newChapter04 new
Chapter04 new
vmummaneni2.6K views
Thread by Mohd Arif
ThreadThread
Thread
Mohd Arif4.2K views
Concept of thread, multi thread, tcb by Kanza batool
Concept of thread, multi thread, tcbConcept of thread, multi thread, tcb
Concept of thread, multi thread, tcb
Kanza batool122 views
Operating Systems R20 Unit 2.pptx by Prudhvi668506
Operating Systems R20 Unit 2.pptxOperating Systems R20 Unit 2.pptx
Operating Systems R20 Unit 2.pptx
Prudhvi6685066 views

More from Mind The Firebird

Tips for using Firebird system tables by
Tips for using Firebird system tablesTips for using Firebird system tables
Tips for using Firebird system tablesMind The Firebird
6K views38 slides
Using Azure cloud and Firebird to develop applications easily by
Using Azure cloud and Firebird to develop applications easilyUsing Azure cloud and Firebird to develop applications easily
Using Azure cloud and Firebird to develop applications easilyMind The Firebird
2.2K views9 slides
A year in the life of Firebird .Net provider by
A year in the life of Firebird .Net providerA year in the life of Firebird .Net provider
A year in the life of Firebird .Net providerMind The Firebird
1.2K views16 slides
How Firebird transactions work by
How Firebird transactions workHow Firebird transactions work
How Firebird transactions workMind The Firebird
2.9K views72 slides
SuperServer in Firebird 3 by
SuperServer in Firebird 3SuperServer in Firebird 3
SuperServer in Firebird 3Mind The Firebird
6.7K views27 slides
Copycat presentation by
Copycat presentationCopycat presentation
Copycat presentationMind The Firebird
1.9K views17 slides

More from Mind The Firebird(20)

Using Azure cloud and Firebird to develop applications easily by Mind The Firebird
Using Azure cloud and Firebird to develop applications easilyUsing Azure cloud and Firebird to develop applications easily
Using Azure cloud and Firebird to develop applications easily
Mind The Firebird2.2K views
A year in the life of Firebird .Net provider by Mind The Firebird
A year in the life of Firebird .Net providerA year in the life of Firebird .Net provider
A year in the life of Firebird .Net provider
Mind The Firebird1.2K views
Creating logs for data auditing in FirebirdSQL by Mind The Firebird
Creating logs for data auditing in FirebirdSQLCreating logs for data auditing in FirebirdSQL
Creating logs for data auditing in FirebirdSQL
Mind The Firebird2.8K views
Firebird Performance counters in details by Mind The Firebird
Firebird Performance counters in detailsFirebird Performance counters in details
Firebird Performance counters in details
Mind The Firebird1.7K views
Understanding Numbers in Firebird SQL by Mind The Firebird
Understanding Numbers in Firebird SQLUnderstanding Numbers in Firebird SQL
Understanding Numbers in Firebird SQL
Mind The Firebird6.5K views
New SQL Features in Firebird 3, by Vlad Khorsun by Mind The Firebird
New SQL Features in Firebird 3, by Vlad KhorsunNew SQL Features in Firebird 3, by Vlad Khorsun
New SQL Features in Firebird 3, by Vlad Khorsun
Mind The Firebird52.2K views
Firebird release strategy and roadmap for 2015/2016 by Mind The Firebird
Firebird release strategy and roadmap for 2015/2016Firebird release strategy and roadmap for 2015/2016
Firebird release strategy and roadmap for 2015/2016
Mind The Firebird3.5K views
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk... by Mind The Firebird
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
Mind The Firebird1.1K views
Working with Large Firebird databases by Mind The Firebird
Working with Large Firebird databasesWorking with Large Firebird databases
Working with Large Firebird databases
Mind The Firebird1.7K views
Superchaging big production systems on Firebird: transactions, garbage, maint... by Mind The Firebird
Superchaging big production systems on Firebird: transactions, garbage, maint...Superchaging big production systems on Firebird: transactions, garbage, maint...
Superchaging big production systems on Firebird: transactions, garbage, maint...
Mind The Firebird1.5K views
Continuous Database Monitoring with the Trace API by Mind The Firebird
Continuous Database Monitoring with the Trace APIContinuous Database Monitoring with the Trace API
Continuous Database Monitoring with the Trace API
Mind The Firebird2.7K views

Recently uploaded

Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionMárton Kodok
15 views55 slides
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...Marc Müller
41 views62 slides
The Era of Large Language Models.pptx by
The Era of Large Language Models.pptxThe Era of Large Language Models.pptx
The Era of Large Language Models.pptxAbdulVahedShaik
7 views9 slides
JioEngage_Presentation.pptx by
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptxadmin125455
6 views4 slides
SAP FOR TYRE INDUSTRY.pdf by
SAP FOR TYRE INDUSTRY.pdfSAP FOR TYRE INDUSTRY.pdf
SAP FOR TYRE INDUSTRY.pdfVirendra Rai, PMP
28 views3 slides
Dapr Unleashed: Accelerating Microservice Development by
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice DevelopmentMiroslav Janeski
12 views29 slides

Recently uploaded(20)

Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok15 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller41 views
JioEngage_Presentation.pptx by admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254556 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski12 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta7 views
predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app9 views
Bootstrapping vs Venture Capital.pptx by Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic14 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app7 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert26 views

Threading through InterBase, Firebird, and beyond

  • 1. Threading in Firebird and the Future Ann W. Harrison James A. Starkey
  • 2. A Word of Thanks to our Sponsors
  • 3. Why Threads? Improve multi-user performance Utilize multi-processor systems Databases are too easy to multi-thread
  • 4. What are Atomic Instructions? Most machine instructions can be interrupted, allowing the world to change. Atomic instructions (e.g. CAS) run to completion. Essential for multi-thread performance.
  • 5. Wasn’t Firebird Always Threaded? Earliest versions of shared server ran query for one user until it stalled before responding to next user. Not friendly. Multi-threaded server runs to the next wait or for a fixed period plus the time to make the database state consistent. Threads never run concurrently.
  • 6. Firebird Classic Designed for VAX Clusters Multiple independent computers Shared intelligent disk controller Cluster-wide lock manager
  • 7. Firebird Classic Multi-Processor Single Machine, Multi-Processor O/S schedules Firebird clients on processors Clients share Disk Lock manager Clients do not share Page Cache Metadata
  • 8. Non-shared cache Firebird classic, super classic Client B wants page 123 Client A changed page 123 Yes, that is really a disk write
  • 9. Shared cache - Superserver Client A changed page 123 Client B wants page 123 Client A releases lock on page 123 Client B locks page 123 1 2 3
  • 10. Threading, 101 Thread PC: Instruction stream of control Dedicated Stack (1 mb+) Thread specific data All threads share process memory Expensive to create, cheap to use (If you don’t thrash)
  • 11. Threading 101 Interlocked Instruction: Atomic compare and swap Compares given value to value at given address If equal, store new value at given address If not, fails and does nothing Interlocked instructions are the mortar of multi-threading
  • 12. Threading 101 Non-interlocked data structures Data structures managed only by interlocked instructions Completely non-blocking The fastest – and hardest – form of multi-programming
  • 13. Threading 101 RW-lock, aka SyncObject Can be locked for read/shared Can be locked for write/exclusive Blocks until access can be granted Monitor semantics: Thread doesn’t lock against itself Implemented with interlocked CAS
  • 14. Threading 101 Coarse grain multi-threading Single mutex controls an entire subsystem Individual data structures are not interlocked Fine grain multi-threading Individual RW-lock per data structure Allows many threads to share a subsystem
  • 15. Threading 101 Dedicated Thread Thread assigned specific task Garbage collector, network listener, etc. Client thread Thread executing user request Worker Thread Thread idle or executing user request Thread pool Manages worker threads
  • 16. Threading Models Thread per connection Worker thread assigned at connection time Worker thread == Client thread Idle client threads consume resources Many connections => high contention
  • 17. Threading Models Limited worker threads Limit active worker threads to approx. number of processors User requests queued until work thread becomes available If worker thread stalls (page read), thread pool can release next user request Utilizes processors without unnecessary contention
  • 18. Threading Models Limited Worker Threads: Dedicated listener thread waits for readable socket Connection object (on listener thread) does socket read When packet is complete, connection object queue to thread pool When worker thread becomes available, connection object is executed
  • 19. Threading Model Thread per connection is first step Limited worker threads is essential for scalability
  • 20. Interbase Threads: The Beginning The concept of threads was known at the birth of Interbase, but no implementations existed on small machines. SMP didn’t exist in the mini or workstation world The initial version of Interbase used signals for communication User requests executed with “looper”; when a request stalled, another request could run
  • 21. Interbase Theads: The V3 Disaster Apollo was the first workstation vendor with threads I implemented a VMS threading package Sun’s first attempt at threads didn’t even compile Interbase V3 was going to be mixed signals + threads Then disaster: Apollo Domain had unfixable architectural flaw mixing threads and signals A long slip ensued
  • 22. Interbase Threads: V3 Reborn The engine was either threaded or signal based Dedicated threads for lock manager, event manager, etc. Server was thread per client Engine continued with coarse grain multi-threading
  • 23. Firebird Threading: Vulcan Vulcan, now deceased, introduced limited fine grain multi-threading Threads synchronized with SyncObject: User mode read/write locks with monitor semantics SMP had arrived, followed shortly by processor based threads
  • 24. Some Performance Lessons The goal is to saturate CPU, network, memory, and disk bandwidth simultaneously. There is no reason to run more worker threads than cores (and many reasons not to), but A stalled thread is an efficient way to maintain request state (death to “looper”!)
  • 25. A Winning Architecture A single dedicated thread waiting for readable sockets Request starts are posted to thread manager for available worker thread When active worker threads drops below threshold, a pending request is assigned a worker thread A stalling thread checks in with thread manager to drop the number of active worker threads An unstalled request bumps the number of a.w.t.