SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI1
Firebird Tour 2017Firebird Tour 2017
Advanced Trace APIAdvanced Trace API
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
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI5
Trace Session Configuration
● fbtrace.conf file in Firebird root directory
● Self-documented
● Show all possible trace parameters
● Uses own XML-like syntax in Firebird 2.5
– Different from firebird.conf, fbintl.conf, etc
● In Firebird 3 all configuration files have same syntax
– Syntax for trace configuration slightly changed
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI6
User Trace and System Audit
● User trace session
● Initiated (started) by user
via special service
● Not preserved after
Firebird shutdown
● Output read by initiated
service connection
● Scope depends on user
privileges
● Audit trace session
● Initiated only by Firebird
itself
● Started with Firebird every
time
● Output stored in log file(s)
● Scope is not limited
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI7
User Trace and System Audit
● User trace session
● Could be temporary
paused by the Firebird
● Could be many user trace
sessions
● Could be managed by
creator user or by
SYSDBA
● Audit trace session
● Never interrupted by
Firebird
● Only one audit trace
session could exists
● Could be managed by
SYSDBA only
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI8
Trace Sessions in the Engine
Database Attachment
Trace Manager
session object
...
session object
Trace Config Storage
stored session record
stored session record
...
stored session record
Database Attachment
Trace Manager
session object
...
session object
Service Attachment
Trace Manager
session object
...
session object
Trace Services
● Start trace session
● Stop trace session
● Suspend trace session
● Resume trace session
● List of trace sessions
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI9
Trace Sessions in the Engine
● To support multiply trace sessions we need some kind of
manager
● Trace sessions need a place to keep its parameters
● ID, name, creator user, state, etc
● Trace session configuration
● TraceConfigStorage object is used for this goals
● One instance per engine process
● Common part is in shared memory
● Changes increments special counter
● Requires synchronization between engine processes
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI10
Trace Configuration Storage
● Consists from two files
● fb_trace, control file, mapped into shared memory
● fb_trace_AAAAAA, storage of trace sessions records
● Both files placed at Firebird lock directory
● by default COMMON_APPDATAfirebird
● Creates when Firebird process starts
● Shared by all Firebird processes (embedded too !)
● Deleted when last Firebird process gone
● trace sessions is not preserved between Firebird restarts
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI11
Trace Sessions in the Engine
● All trace activity in the engine done using TraceManager
object
● Each database connection has own instance of
TraceManager
● Each service connection has own instance of TraceManager
● No additional synchronization between any kind of
connections is required
● TraceManager sits between the engine and trace plugin(s)
● Load and initialize trace plugin
● Put events data into trace plugin methods
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI12
Trace Manager
● Maintains list of active trace session objects which should
be used at databaseservice connection
● Maintains list of trace plugin’s which should receive
corresponding events
● Two main tasks
● React on changes in trace sessions list
– New trace session created
– Requests to stop trace session
– Requests to suspendresume trace session
● Pass events produced by the engine into trace plugin(s)
● Should have minimal impact on engine performance!
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI13
Trace Manager
TraceManager::change_number ==
TraceConfigStorage::change_number
Event to trace
TraceManager::
update_sessions()
No
TraceManager :
Pass event into every
session object
Yes
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI14
Trace session's output
● User trace
● Many writers
– Other connections, produced events to trace
● One reader
– The service connection which creates trace session
● It is hard to directly pass events data from different engine
processes into given service connection
● Writers needs to store it somewhere and reader should
read it
● Disk space used should be limited
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI15
Trace session's output
● User trace
● Many writers
● One reader
● Disk space released while
reading
● Delete whole log when
reader gone
● Log file name set by
Firebird
● System audit trace
● Many writers
● No readers
● Log files rotation
● Log files not deleted by
Firebird
● Log file name set in trace
configuration on per-
database (service) basis
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI16
Output of user trace
Log Control File
fb_trace.{GUID}
struct ShMemHeader
{
volatile unsigned int readFileNum;
volatile unsigned int writeFileNum;
...
● Log files placed at Firebird's lock directory
● by default COMMON_APPDATAfirebird
● Maximum size of each log file is 1MB
● Maximum summary log size set in firebird.conf
● MaxUserTraceLogSize = 10
Log Files
fb_trace.{GUID}.NNNNNNN
ATTACH_DATABASE
...
START_TRANSACTION
...
COMMIT_TRANSACTION
...
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI17
Output of System Audit trace
● Stored in disk file(s)
● File name is set in trace configuration file on per-database
(per-service) basis
● «log_filename» setting in database or service section
● Each traced database or service could have own trace log file
● Log file could be “rotated” when its size reached
«max_log_size» MB
● Current log file is renamed
– log_filename.<timestamp>
● New log file is created
● Old log files should be removed by the administrator
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI18
Trace tips and hints
● The more events is traced the more performance delay
could happen
● Be careful:
● Trigger related events will appear for every record affected by
DML statements!
● If you use some PSQL function in SQL statement – function
execution could be traced as many times as records
processed!
● Same about joins with stored procedures
● Same about RDB$SET_CONTEXT usage
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI19
Trace tips and hints
● Statements like
EXECUTE PROCEDURE, or
SELECT ... FROM<procedure>
will produce
● set of SQL statement related events
– log_statement_prepare
– log_statement_free
– log_statement_start
– log_statement_finish
● set of PSQL related events
– log_procedure_start
– log_procedure_finish
● Choose what you really need
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI20
Trace tips and hints
● Question
● Database could be accessed by file name or by alias, or
● I need to trace same set of events for few databases using
one trace session
● Solution
● set all required events and params at default database
section, but do not enable it
● add few more database sections using patterns and set
enable = true there
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI21
Trace tips and hints
database
{
enabled = false
log_statement_finish = true
print_perf = true
time_threshold = 60
}
# by the file name pattern
database = c:databases%.fdb
{
enabled = true
}
# by database alias
database = mycooldb
{
enabled = true
}
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI22
Trace tips and hints
● Consider to “mark” interesting queries using comments
embedded into query text and later add filter at trace
configuration to include (or exclude) such queries:
/* no trace me */ SELECT …
exclude_filter = %(no trace me)%
● Big app with a lot of modulesqueries:
mark queries with module names to easy find source
module which run the query
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI23
Trace tips and hints
● Performance statistics in trace and in tools (isql, etc) could
be different
● Trace shows “clear” time spent by the engine only to
execute statement
● ISQL time includes
● network delays
● prepare time
● commit time (DDL statements and autoddl = on)
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI24
Trace tips and hints
● Performance statistics in trace and in tools (isql, etc) could
be different
● How ISQL measure stats and time:
● take "before" stats
● free previous stmt
● prepare current stmt
● ask for PLAN (if required)
● execute statement
● ask for record counts (if query is insupddel)
● fetch and print results
● take "after" stats
● print difference "after" - "before"
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI25
Trace tips and hints
● Log of slow queries
database
{
log_statement_finish = true
print_perf = true
time_threshold = 10000
}
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI26
Trace tips and hints
● Log DDL statements
database
{
log_statement_start = true
include_filter = %(CREATE|ALTER|DROP)%
time_threshold = 0
}
case insensitive filter could looks a bit more complex
%([Cc]Rr[Ee][Aa][Tt][Ee])%
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI27
Trace tips and hints
● Trace configuration uses regexp patterns with the same
syntax as Firebird itself
● You may check regexp patternfilter with Firebird:
SELECT ‘Matched’ FROM RDB$DATABASE
WHERE <string> IS SIMILAR TO <pattern string>
Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI28
THANK YOU FOR ATTENTION !THANK YOU FOR ATTENTION !
Questions ?Questions ?
Firebird official web site
Firebird tracker
hvlad@users.sf.net

Mais conteúdo relacionado

Semelhante a Firebird Advanced Trace API

CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQueryCodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQueryMárton Kodok
 
Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB Gaurav Bhardwaj
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Valeriy Kravchuk
 
Sprint 44 review
Sprint 44 reviewSprint 44 review
Sprint 44 reviewManageIQ
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
 
guider: a system-wide performance analyzer
guider: a system-wide performance analyzerguider: a system-wide performance analyzer
guider: a system-wide performance analyzerPeace Lee
 
Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUN Masahiro
 
Headless Magento - Meet Magento Poland 2017
Headless Magento - Meet Magento Poland 2017Headless Magento - Meet Magento Poland 2017
Headless Magento - Meet Magento Poland 2017Sander Mangel
 
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...NETWAYS
 
GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101yinonavraham
 
MySQL 8.0 achitecture and enhancement
MySQL 8.0 achitecture and enhancementMySQL 8.0 achitecture and enhancement
MySQL 8.0 achitecture and enhancementlalit choudhary
 
3 Ways to Improve Performance from a Storage Perspective
3 Ways to Improve Performance from a Storage Perspective3 Ways to Improve Performance from a Storage Perspective
3 Ways to Improve Performance from a Storage PerspectivePerforce
 
Oh Crap, My Code is Slow - Madison PHP 2016
Oh Crap, My Code is Slow - Madison PHP 2016Oh Crap, My Code is Slow - Madison PHP 2016
Oh Crap, My Code is Slow - Madison PHP 2016Chris Tankersley
 

Semelhante a Firebird Advanced Trace API (20)

CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQueryCodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
CodeCamp Iasi - Creating serverless data analytics system on GCP using BigQuery
 
SuperServer in Firebird 3
SuperServer in Firebird 3SuperServer in Firebird 3
SuperServer in Firebird 3
 
Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB Large Scale Log collection using LogStash & mongoDB
Large Scale Log collection using LogStash & mongoDB
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
Sprint 71
Sprint 71Sprint 71
Sprint 71
 
SCOM Tips and Tricks
SCOM Tips and TricksSCOM Tips and Tricks
SCOM Tips and Tricks
 
Sprint 69
Sprint 69Sprint 69
Sprint 69
 
Sprint 44 review
Sprint 44 reviewSprint 44 review
Sprint 44 review
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
guider: a system-wide performance analyzer
guider: a system-wide performance analyzerguider: a system-wide performance analyzer
guider: a system-wide performance analyzer
 
Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EU
 
Pcp
PcpPcp
Pcp
 
Headless Magento - Meet Magento Poland 2017
Headless Magento - Meet Magento Poland 2017Headless Magento - Meet Magento Poland 2017
Headless Magento - Meet Magento Poland 2017
 
Sprint 68
Sprint 68Sprint 68
Sprint 68
 
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
OSMC 2021 | pg_stat_monitor: A cool extension for better database (PostgreSQL...
 
GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101
 
MySQL 8.0 achitecture and enhancement
MySQL 8.0 achitecture and enhancementMySQL 8.0 achitecture and enhancement
MySQL 8.0 achitecture and enhancement
 
3 Ways to Improve Performance from a Storage Perspective
3 Ways to Improve Performance from a Storage Perspective3 Ways to Improve Performance from a Storage Perspective
3 Ways to Improve Performance from a Storage Perspective
 
Spark Meetup
Spark MeetupSpark Meetup
Spark Meetup
 
Oh Crap, My Code is Slow - Madison PHP 2016
Oh Crap, My Code is Slow - Madison PHP 2016Oh Crap, My Code is Slow - Madison PHP 2016
Oh Crap, My Code is Slow - Madison PHP 2016
 

Mais de Marius Adrian Popa

Python with Firebird: FDB driver 101
Python with Firebird: FDB driver 101Python with Firebird: FDB driver 101
Python with Firebird: FDB driver 101Marius Adrian Popa
 
The State of the Romanian Game Developers Industry Rgda 2019 report
The State of the Romanian Game Developers Industry Rgda 2019 reportThe State of the Romanian Game Developers Industry Rgda 2019 report
The State of the Romanian Game Developers Industry Rgda 2019 reportMarius Adrian Popa
 
Understanding the firebird optimizer
Understanding the firebird optimizerUnderstanding the firebird optimizer
Understanding the firebird optimizerMarius Adrian Popa
 
Firebird 3.0 statistics and plans
Firebird 3.0 statistics and plansFirebird 3.0 statistics and plans
Firebird 3.0 statistics and plansMarius Adrian Popa
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadMarius Adrian Popa
 
Firebird Performance 2.5/3.0.x/4.0
 Firebird Performance 2.5/3.0.x/4.0 Firebird Performance 2.5/3.0.x/4.0
Firebird Performance 2.5/3.0.x/4.0Marius Adrian Popa
 

Mais de Marius Adrian Popa (11)

Python with Firebird: FDB driver 101
Python with Firebird: FDB driver 101Python with Firebird: FDB driver 101
Python with Firebird: FDB driver 101
 
The State of the Romanian Game Developers Industry Rgda 2019 report
The State of the Romanian Game Developers Industry Rgda 2019 reportThe State of the Romanian Game Developers Industry Rgda 2019 report
The State of the Romanian Game Developers Industry Rgda 2019 report
 
Understanding the firebird optimizer
Understanding the firebird optimizerUnderstanding the firebird optimizer
Understanding the firebird optimizer
 
Firebird 3.0 statistics and plans
Firebird 3.0 statistics and plansFirebird 3.0 statistics and plans
Firebird 3.0 statistics and plans
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy Workload
 
Firebird Performance 2.5/3.0.x/4.0
 Firebird Performance 2.5/3.0.x/4.0 Firebird Performance 2.5/3.0.x/4.0
Firebird Performance 2.5/3.0.x/4.0
 
Django firebird project
Django firebird projectDjango firebird project
Django firebird project
 
Proiectul django firebird
Proiectul django firebirdProiectul django firebird
Proiectul django firebird
 
Firebird Myths in Romanian
Firebird Myths in RomanianFirebird Myths in Romanian
Firebird Myths in Romanian
 
2 Firebird Technical Ro
2 Firebird Technical Ro2 Firebird Technical Ro
2 Firebird Technical Ro
 
0 What Is Mind The Bird Ro
0 What Is Mind The Bird Ro0 What Is Mind The Bird Ro
0 What Is Mind The Bird Ro
 

Último

Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxolyaivanovalion
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 

Último (20)

Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 

Firebird Advanced Trace API

  • 1. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI1 Firebird Tour 2017Firebird Tour 2017 Advanced Trace APIAdvanced Trace API Vlad Khorsun, Firebird Project
  • 2. 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
  • 3. • 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
  • 4. • Replication, Recovery and Optimization for Firebird since 2002 • Platinum Sponsor of Firebird Foundation • Based in Moscow, Russia www.ib-aid.com
  • 5. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI5 Trace Session Configuration ● fbtrace.conf file in Firebird root directory ● Self-documented ● Show all possible trace parameters ● Uses own XML-like syntax in Firebird 2.5 – Different from firebird.conf, fbintl.conf, etc ● In Firebird 3 all configuration files have same syntax – Syntax for trace configuration slightly changed
  • 6. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI6 User Trace and System Audit ● User trace session ● Initiated (started) by user via special service ● Not preserved after Firebird shutdown ● Output read by initiated service connection ● Scope depends on user privileges ● Audit trace session ● Initiated only by Firebird itself ● Started with Firebird every time ● Output stored in log file(s) ● Scope is not limited
  • 7. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI7 User Trace and System Audit ● User trace session ● Could be temporary paused by the Firebird ● Could be many user trace sessions ● Could be managed by creator user or by SYSDBA ● Audit trace session ● Never interrupted by Firebird ● Only one audit trace session could exists ● Could be managed by SYSDBA only
  • 8. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI8 Trace Sessions in the Engine Database Attachment Trace Manager session object ... session object Trace Config Storage stored session record stored session record ... stored session record Database Attachment Trace Manager session object ... session object Service Attachment Trace Manager session object ... session object Trace Services ● Start trace session ● Stop trace session ● Suspend trace session ● Resume trace session ● List of trace sessions
  • 9. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI9 Trace Sessions in the Engine ● To support multiply trace sessions we need some kind of manager ● Trace sessions need a place to keep its parameters ● ID, name, creator user, state, etc ● Trace session configuration ● TraceConfigStorage object is used for this goals ● One instance per engine process ● Common part is in shared memory ● Changes increments special counter ● Requires synchronization between engine processes
  • 10. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI10 Trace Configuration Storage ● Consists from two files ● fb_trace, control file, mapped into shared memory ● fb_trace_AAAAAA, storage of trace sessions records ● Both files placed at Firebird lock directory ● by default COMMON_APPDATAfirebird ● Creates when Firebird process starts ● Shared by all Firebird processes (embedded too !) ● Deleted when last Firebird process gone ● trace sessions is not preserved between Firebird restarts
  • 11. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI11 Trace Sessions in the Engine ● All trace activity in the engine done using TraceManager object ● Each database connection has own instance of TraceManager ● Each service connection has own instance of TraceManager ● No additional synchronization between any kind of connections is required ● TraceManager sits between the engine and trace plugin(s) ● Load and initialize trace plugin ● Put events data into trace plugin methods
  • 12. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI12 Trace Manager ● Maintains list of active trace session objects which should be used at databaseservice connection ● Maintains list of trace plugin’s which should receive corresponding events ● Two main tasks ● React on changes in trace sessions list – New trace session created – Requests to stop trace session – Requests to suspendresume trace session ● Pass events produced by the engine into trace plugin(s) ● Should have minimal impact on engine performance!
  • 13. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI13 Trace Manager TraceManager::change_number == TraceConfigStorage::change_number Event to trace TraceManager:: update_sessions() No TraceManager : Pass event into every session object Yes
  • 14. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI14 Trace session's output ● User trace ● Many writers – Other connections, produced events to trace ● One reader – The service connection which creates trace session ● It is hard to directly pass events data from different engine processes into given service connection ● Writers needs to store it somewhere and reader should read it ● Disk space used should be limited
  • 15. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI15 Trace session's output ● User trace ● Many writers ● One reader ● Disk space released while reading ● Delete whole log when reader gone ● Log file name set by Firebird ● System audit trace ● Many writers ● No readers ● Log files rotation ● Log files not deleted by Firebird ● Log file name set in trace configuration on per- database (service) basis
  • 16. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI16 Output of user trace Log Control File fb_trace.{GUID} struct ShMemHeader { volatile unsigned int readFileNum; volatile unsigned int writeFileNum; ... ● Log files placed at Firebird's lock directory ● by default COMMON_APPDATAfirebird ● Maximum size of each log file is 1MB ● Maximum summary log size set in firebird.conf ● MaxUserTraceLogSize = 10 Log Files fb_trace.{GUID}.NNNNNNN ATTACH_DATABASE ... START_TRANSACTION ... COMMIT_TRANSACTION ...
  • 17. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI17 Output of System Audit trace ● Stored in disk file(s) ● File name is set in trace configuration file on per-database (per-service) basis ● «log_filename» setting in database or service section ● Each traced database or service could have own trace log file ● Log file could be “rotated” when its size reached «max_log_size» MB ● Current log file is renamed – log_filename.<timestamp> ● New log file is created ● Old log files should be removed by the administrator
  • 18. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI18 Trace tips and hints ● The more events is traced the more performance delay could happen ● Be careful: ● Trigger related events will appear for every record affected by DML statements! ● If you use some PSQL function in SQL statement – function execution could be traced as many times as records processed! ● Same about joins with stored procedures ● Same about RDB$SET_CONTEXT usage
  • 19. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI19 Trace tips and hints ● Statements like EXECUTE PROCEDURE, or SELECT ... FROM<procedure> will produce ● set of SQL statement related events – log_statement_prepare – log_statement_free – log_statement_start – log_statement_finish ● set of PSQL related events – log_procedure_start – log_procedure_finish ● Choose what you really need
  • 20. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI20 Trace tips and hints ● Question ● Database could be accessed by file name or by alias, or ● I need to trace same set of events for few databases using one trace session ● Solution ● set all required events and params at default database section, but do not enable it ● add few more database sections using patterns and set enable = true there
  • 21. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI21 Trace tips and hints database { enabled = false log_statement_finish = true print_perf = true time_threshold = 60 } # by the file name pattern database = c:databases%.fdb { enabled = true } # by database alias database = mycooldb { enabled = true }
  • 22. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI22 Trace tips and hints ● Consider to “mark” interesting queries using comments embedded into query text and later add filter at trace configuration to include (or exclude) such queries: /* no trace me */ SELECT … exclude_filter = %(no trace me)% ● Big app with a lot of modulesqueries: mark queries with module names to easy find source module which run the query
  • 23. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI23 Trace tips and hints ● Performance statistics in trace and in tools (isql, etc) could be different ● Trace shows “clear” time spent by the engine only to execute statement ● ISQL time includes ● network delays ● prepare time ● commit time (DDL statements and autoddl = on)
  • 24. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI24 Trace tips and hints ● Performance statistics in trace and in tools (isql, etc) could be different ● How ISQL measure stats and time: ● take "before" stats ● free previous stmt ● prepare current stmt ● ask for PLAN (if required) ● execute statement ● ask for record counts (if query is insupddel) ● fetch and print results ● take "after" stats ● print difference "after" - "before"
  • 25. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI25 Trace tips and hints ● Log of slow queries database { log_statement_finish = true print_perf = true time_threshold = 10000 }
  • 26. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI26 Trace tips and hints ● Log DDL statements database { log_statement_start = true include_filter = %(CREATE|ALTER|DROP)% time_threshold = 0 } case insensitive filter could looks a bit more complex %([Cc]Rr[Ee][Aa][Tt][Ee])%
  • 27. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI27 Trace tips and hints ● Trace configuration uses regexp patterns with the same syntax as Firebird itself ● You may check regexp patternfilter with Firebird: SELECT ‘Matched’ FROM RDB$DATABASE WHERE <string> IS SIMILAR TO <pattern string>
  • 28. Firebird Tour 2017Firebird Tour 2017 Advanced TraceAdvanced Trace APIAPI28 THANK YOU FOR ATTENTION !THANK YOU FOR ATTENTION ! Questions ?Questions ? Firebird official web site Firebird tracker hvlad@users.sf.net