SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
DTrace support in MySQL: guide to identifying common
                performance problems

                Alexey.Kopytov@Sun.com


                     April 22, 2009




                                                  Test logo
DTrace Introduction




   A dynamic tracing framework
   No need to restart application
   No special builds
   Used for debugging, troubleshooting and perfomance analysis
   Support in Solaris, OpenSolaris, Mac OS X, FreeBSD and
   Linux (in development).




                                                                 Test logo
How does it work?




   Probe is an instrumentation point
   Probe “fires” when execution flow reaches probe location
   May have optional arguments describing the context
   No overhead for inactive probes
       Solaris kernel: ∼36,000 probes
       Solaris kernel + libraries: ∼50,000 probes
       Applications: Java VM, Apache, PHP, Ruby, MySQL, . . .




                                                                Test logo
Probe naming conventions




    probe_id := provider:module:function:name
               Collection of related probes (syscall, io, mysql)
   provider:
               Executable or library name
   module:
               Function name in the source code
   function:
               Probe name (query-start)
   name:
   Example:
       syscall::read:entry




                                                                   Test logo
Using probes
Scripts in D language:
    specify probes we want to trace
    describe actions to be run when a probe fires

Example

                                    reads.d
syscall :: read : entry
/ execname == quot; mysqld quot; /
{
   printf ( quot; % s : read (% d , 0 x %x , % d ) n quot; ,
            execname , arg0 , arg1 , arg2 );
}

# dtrace -qs ./reads.d
mysqld: read(31, 0x4ef1018,         16)
mysqld: read(31, 0x4ef1018,         4)
mysqld: read(31, 0x4ef1018,         4)
mysqld: read(31, 0x4ef1018,         20)
^C                                                      Test logo
Dynamic probes
    Dynamic probes:
          created on-the-fly
    ’pid’ provider:
          does not require any support from an application
          dynamic entry/return probes for every function
          function arguments are available in a script as arg0, arg1, . . .

Example

                                     mysql_parse.d
pid$target ::* mysql_parse *: entry
{
   printf ( quot; % s  n quot; , copyinstr ( arg1 ))
}

# dtrace -p ‘pgrep mysqld‘ -qs ./mysql_parse.d
BEGIN
SELECT c from sbtest where id=5042
...                                                                           Test logo
Static probes
Static probes:
    must be added into application source code
    may have arguments not available from dynamic ones

Example

                             sql/sql_parse.cc
bool dispatch_command (...)
{
  switch ( command ) {
  case COM_QUERY :
    MYSQL _QUERY_S TART ( query , thread_id , db , user , host );
    /* Query processing starts here */
    ...
  }
}

# dtrace -qn ’mysql*:::query-start 
{ printf(quot;%snquot;, copyinstr(arg0)) }’
BEGIN
SELECT c from sbtest where id=5042
...                                                                 Test logo
Comparison of static and dynamic probes




           Pros and cons of dynamic and static probes
                                              Dynamic   Static
       Work with any MySQL version              yes       no
       Stable interface                         no       yes
       Require knowledge of the source code     yes       no
       Coverage                                high      low




                                                                 Test logo
MySQL static probes


∼60 probes, 200 locations in MySQL 5.4/6.0:
    connections
    Query Cache
    MyISAM key cache
    network I/O
    SQL query execution:
         parsing
         table locks
         row operations in storage engines
         filesort
    individual query types (SELECT, INSERT, UPDATE, ...)


                                                           Test logo
Overhead
sysbench, OLTP read-only, 1 thread, all-in-memory
D script
mysql*:::
{
  @nprobes = count();
}

                               89.57
                   88.22

                                                    w/o DTrace
                                                    w/DTrace, all
                                                    probes disabled
                                                    w/DTrace, all
       tps
                                                    probes enabled,
                                                    ~10,000
                                                    probes/sec

                                            3.69




    inactive probes do have zero overhead
    24x slowdown for 10,000 probes/sec                                Test logo
Overhead

         88.22

                       66.17          64.77             62.04

                                                                43.56
     tps


                                                                        3.69

            0             10            100             1000    5000    10000
                                            probes/sec

  ∼25% slowdown with rates < 1000 probes/sec
  sharp performance drop with rates > 1000 probes/sec


                                                                                Test logo
Examples




           Test logo
Query tracing: storage engine operations



Measuring time spent in a storage engine for each query.
Row operation probes:
read - row - start / done
index - read - row - start / done
update - row - start / done
delete - row - start / done
insert - row - start / done




                                                           Test logo
Query tracing: storage engine operations
D script
mysql$target ::: query - start ,
{
  self - > query = copyinstr ( arg0 );
  self - > query_start = timestamp ;
  self - > engine = 0;
}

mysql$target :::* - row - start
{
  self - > engine_start = timestamp ;
}

mysql$target :::* - row - done
{
  self - > engine = self - > engine + timestamp -    self - > engine_start ;
}

mysql$target ::: query - done ,
/ self - > query != 0 /
{
  printf ( quot; % s  n quot; , self - > query );
  printf ( quot; Total : % dus Engine : % dus  n quot; ,
            ( timestamp - self - > query_start ) / 1000 ,
            self - > engine / 1000 ,
  self - > query = 0;
}
                                                                               Test logo
Query tracing: network I/O
Measuring time spent on network operations.

Network I/O probes:
net - read - start / done
net - write - start / done


D script
...
mysql$target ::: net -* - start
{
  self - > net_start = timestamp ;
}

mysql$target ::: net -* - done
{
  self - > network = self - > network + timestamp - self - > net_start ;
}
...



                                                                           Test logo
Query tracing: table locks and filesort
Measuring time spent on table locks and filesort.


Table locks probes:                            Filesort probes:
handler - rdlock - start / done                    filesort - start / done
handler - wrlock - start / done
handler - unlock - start / done


D script
...
mysql$target ::: handler -* lock - start
{
  self - > lock_start = timestamp ;
}

mysql$target ::: handler -* lock - done
{
  self - > locks = self - > locks + timestamp - self - > lock_start ;
}

mysql$target ::: filesort - start
{
  self - > filesort_start = timestamp ;
}

mysql$target ::: filesort - done
{
  self - > filesort = timestamp - self - > filesort_start ;
}
...
                                                                             Test logo
Putting it all together
Results
# dtrace -qp ‘pgrep mysqld‘ -s ./query_snoop.d
INSERT INTO order_line (ol_o_id, ol_d_id, ol_w_id, ol_number,
                        ol_i_id, ol_supply_w_id, ol_delivery_d,
                        ol_quantity, ol_amount, ol_dist_info)
VALUES (3302, 3, 8, 4, 32055, 8, NULL, 5, 106.500000, ’anYwJuccgMvV
*** Total: 595us Locks: 63us Engine: 378us Network: 101us Filesort: 0us

SELECT i_price, i_name, i_data
FROM item
WHERE i_id = 28416
*** Total: 753us Locks: 106us Engine: 462us Network: 123us Filesort: 0us




                                                                   Test logo
Hot tables: table reads
D script

                                      table_reads.d
mysql$target ::: index - read - row - start ,
mysql$target ::: read - row - start
{
  @tables [ copyinstr ( arg0 ) , copyinstr ( arg1 )] = count ();
}

END
{
  printa ( quot; % s .% s % @u  n quot; , @tables );
}



Probes used:
read - row - start ( db , table , scan_flag )
index - read - row - start ( db , table )



                                                                   Test logo
Hot tables: table reads



Results
# dtrace -qp ‘pgrep mysqld‘ -s ./table_reads.d
^C
dbt2w10.orders 15490
dbt2w10.warehouse 15990
dbt2w10.district 33152
dbt2w10.item 57559
dbt2w10.customer 78256
dbt2w10.order_line 219413
dbt2w10.stock 277777
dbt2w10.new_order 4421952



                                                 Test logo
Hot tables: table updates
D script

                                      table_updates.d
mysql$target ::: insert - row - start ,
mysql$target ::: update - row - start ,
mysql$target ::: delete - row - start
{
  @tables [ copyinstr ( arg0 ) , copyinstr ( arg1 )] = count ();
}

END
{
  printa ( quot; % s .% s % @u  n quot; , @tables );
}



Probes used:
insert - row - start ( db , table )
update - row - start ( db , table )
delete - row - start ( db , table )

                                                                   Test logo
Hot tables: table updates



Results
# dtrace -qp ‘pgrep mysqld‘ -s ./table_updates.d
^C
dbt2w10.orders 12247
dbt2w10.warehouse 12676
dbt2w10.district 26291
dbt2w10.item 45762
dbt2w10.customer 60011
dbt2w10.order_line 159498
dbt2w10.stock 211085
dbt2w10.new_order 3479681



                                                   Test logo
Queries accessing a particular table
D script

                                 table_snoop.d
mysql$target ::: query - exec - start
{
  self - > query = copyinstr ( arg0 );
  self - > used = 0;
}

mysql$target ::: handler -* lock - start
/ copyinstr ( arg0 ) == $$1 && copyinstr ( arg1 ) == $$2 /
{
  self - > used = 1;
}

mysql$target ::: query - exec - done
/ self - > query != 0 && self - > used == 1 /
{
  printf ( quot; % s ; n quot; , self - > query );
  self - > query = 0;
  self - > used = 0;
}



Probes used
query - exec - start ( query , connid , db_name , user , host , exec_type )
query - exec - done ( status )
handler - rdlock - start ( db , table )
handler - wrlock - start ( db , table )
handler - unlock - start ( db , table )
                                                                              Test logo
Queries accessing a particular table

Results
# dtrace -qp ‘pgrep mysqld‘ -s ./table_snoop.d 
 dbt2w10 new_order
SELECT no_o_id
FROM new_order
WHERE no_w_id = 9
  AND no_d_id = 10;
DELETE FROM new_order
WHERE no_o_id = 2197
  AND no_w_id = 9
  AND no_d_id = 10;
INSERT INTO new_order (no_o_id, no_w_id, no_d_id)
VALUES (3251, 2, 2);
...

                                                    Test logo
Stored procedures tracing
    Need to find slow/ineffective queries within a store routine
    Slow query log only shows the CALL statement for the stored procedure, not the individual queries

D script

                                              sp_trace.d
mysql$target ::: query - exec - start
/ arg5 == 3 /
{
  self - > query_start = timestamp ;
  self - > query = copyinstr ( arg0 );
}

mysql$target ::: query - exec - done
/ self - > query != 0 /
{
  printf ( quot; % uus % s  n quot; , ( timestamp - self - > query_start ) / 1000 ,
            self - > query );
  self - > query = 0;
}



Probes used
query - exec - start ( query , connid , db_name , user , host , exec_type )
/* exec_type = 3 for stored routines queries */
query - exec - done ( status )
                                                                                                        Test logo
Stored procedures tracing


Results:
# dtrace -qp ‘pgrep mysqld‘ -s ./sp_trace.d
523us SELECT no_o_id
     INTO tmp_o_id
     FROM new_order
     WHERE no_w_id = NAME_CONST(’in_w_id’,1) AND no_d_id =
     NAME_CONST(’tmp_d_id’,1) limit 1
77us DELETE FROM new_order
       WHERE no_o_id = NAME_CONST(’tmp_o_id’,2381)
         AND no_w_id = NAME_CONST(’in_w_id’,1)
         AND no_d_id = NAME_CONST(’tmp_d_id’,1)
...


                                                        Test logo
What’s next?




   more engine-specific probes
   I/O probes (syscall and io are too limited with background I/O
   threads)
   optimizer
   replication




                                                                    Test logo
Links




    Section in the Reference Manual:
    “5.7. Tracing mysqld Using DTrace”.
    http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-server.htm
    DTrace documentation in Wiki:
    http://wikis.sun.com/display/DTrace/
    Feature preview tree:
    bzr branch lp:~akopytov/mysql-server/mysql-6.0-dtrace
    Alexey.Kopytov@Sun.com




                                                                   Test logo
Thank you!




             Test logo

Weitere ähnliche Inhalte

Was ist angesagt?

sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matterDawid Weiss
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introductionsatyajit_t
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортSergey Platonov
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
Lucene revolution 2011
Lucene revolution 2011Lucene revolution 2011
Lucene revolution 2011Takahiko Ito
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMKris Mok
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)Qiangning Hong
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨flyinweb
 
JPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APIJPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APItvaleev
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Roman Elizarov
 
Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門Takuya Okada
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemRafael Winterhalter
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 

Was ist angesagt? (20)

DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
 
Solaris DTrace, An Introduction
Solaris DTrace, An IntroductionSolaris DTrace, An Introduction
Solaris DTrace, An Introduction
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Live Updating Swift Code
Live Updating Swift CodeLive Updating Swift Code
Live Updating Swift Code
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
 
Lucene revolution 2011
Lucene revolution 2011Lucene revolution 2011
Lucene revolution 2011
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VM
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Java 10, Java 11 and beyond
Java 10, Java 11 and beyondJava 10, Java 11 and beyond
Java 10, Java 11 and beyond
 
JPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream APIJPoint 2016 - Валеев Тагир - Странности Stream API
JPoint 2016 - Валеев Тагир - Странности Stream API
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
 
Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 

Andere mochten auch

Getting The Most Out Of My Sql Enterprise Monitor 20
Getting The Most Out Of My Sql Enterprise Monitor 20Getting The Most Out Of My Sql Enterprise Monitor 20
Getting The Most Out Of My Sql Enterprise Monitor 20MySQLConference
 
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using NdbjWriting Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using NdbjMySQLConference
 
Open solaris customer presentation
Open solaris customer presentationOpen solaris customer presentation
Open solaris customer presentationxKinAnx
 
Presentatie 4x4 Griet Iob
Presentatie 4x4 Griet IobPresentatie 4x4 Griet Iob
Presentatie 4x4 Griet Iobjdhondt
 
Which base theme for your Drupal project
Which base theme for your Drupal projectWhich base theme for your Drupal project
Which base theme for your Drupal projectTwinbit
 
Inno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code StructureInno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code StructureMySQLConference
 
Using Continuous Etl With Real Time Queries To Eliminate My Sql Bottlenecks
Using Continuous Etl With Real Time Queries To Eliminate My Sql BottlenecksUsing Continuous Etl With Real Time Queries To Eliminate My Sql Bottlenecks
Using Continuous Etl With Real Time Queries To Eliminate My Sql BottlenecksMySQLConference
 
Всегда ли ваш Scrum великолепный - UNETA, Харьков
Всегда ли ваш Scrum великолепный - UNETA, ХарьковВсегда ли ваш Scrum великолепный - UNETA, Харьков
Всегда ли ваш Scrum великолепный - UNETA, ХарьковTimofey (Tim) Yevgrashyn
 

Andere mochten auch (9)

Getting The Most Out Of My Sql Enterprise Monitor 20
Getting The Most Out Of My Sql Enterprise Monitor 20Getting The Most Out Of My Sql Enterprise Monitor 20
Getting The Most Out Of My Sql Enterprise Monitor 20
 
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using NdbjWriting Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
 
Open solaris customer presentation
Open solaris customer presentationOpen solaris customer presentation
Open solaris customer presentation
 
Presentatie 4x4 Griet Iob
Presentatie 4x4 Griet IobPresentatie 4x4 Griet Iob
Presentatie 4x4 Griet Iob
 
Which base theme for your Drupal project
Which base theme for your Drupal projectWhich base theme for your Drupal project
Which base theme for your Drupal project
 
Inno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code StructureInno Db Internals Inno Db File Formats And Source Code Structure
Inno Db Internals Inno Db File Formats And Source Code Structure
 
The Smug Mug Tale
The Smug Mug TaleThe Smug Mug Tale
The Smug Mug Tale
 
Using Continuous Etl With Real Time Queries To Eliminate My Sql Bottlenecks
Using Continuous Etl With Real Time Queries To Eliminate My Sql BottlenecksUsing Continuous Etl With Real Time Queries To Eliminate My Sql Bottlenecks
Using Continuous Etl With Real Time Queries To Eliminate My Sql Bottlenecks
 
Всегда ли ваш Scrum великолепный - UNETA, Харьков
Всегда ли ваш Scrum великолепный - UNETA, ХарьковВсегда ли ваш Scrum великолепный - UNETA, Харьков
Всегда ли ваш Scrum великолепный - UNETA, Харьков
 

Ähnlich wie D Trace Support In My Sql Guide To Solving Reallife Performance Problems

Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteSriram Natarajan
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak PROIDEA
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profilerIhor Bobak
 
High Performance Django 1
High Performance Django 1High Performance Django 1
High Performance Django 1DjangoCon2008
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance DjangoDjangoCon2008
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
Building an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowBuilding an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowDatabricks
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachAlexandre Rafalovitch
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Lucidworks
 
Monitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapMonitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapPadraig O'Sullivan
 
Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Valeriy Kravchuk
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with PrometheusShiao-An Yuan
 
Tuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsTuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsSematext Group, Inc.
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Databricks
 
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014Amazon Web Services
 

Ähnlich wie D Trace Support In My Sql Guide To Solving Reallife Performance Problems (20)

Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web site
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Rails Performance
Rails PerformanceRails Performance
Rails Performance
 
High Performance Django 1
High Performance Django 1High Performance Django 1
High Performance Django 1
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance Django
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Building an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowBuilding an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflow
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 
Monitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTapMonitoring MySQL with DTrace/SystemTap
Monitoring MySQL with DTrace/SystemTap
 
Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
Run Node Run
Run Node RunRun Node Run
Run Node Run
 
Tuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsTuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for Logs
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
 
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
(SDD402) Amazon ElastiCache Deep Dive | AWS re:Invent 2014
 

Mehr von MySQLConference

Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMySQLConference
 
Using Open Source Bi In The Real World
Using Open Source Bi In The Real WorldUsing Open Source Bi In The Real World
Using Open Source Bi In The Real WorldMySQLConference
 
Partitioning Under The Hood
Partitioning Under The HoodPartitioning Under The Hood
Partitioning Under The HoodMySQLConference
 
Tricks And Tradeoffs Of Deploying My Sql Clusters In The Cloud
Tricks And Tradeoffs Of Deploying My Sql Clusters In The CloudTricks And Tradeoffs Of Deploying My Sql Clusters In The Cloud
Tricks And Tradeoffs Of Deploying My Sql Clusters In The CloudMySQLConference
 
My Sql Performance On Ec2
My Sql Performance On Ec2My Sql Performance On Ec2
My Sql Performance On Ec2MySQLConference
 
Inno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesInno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesMySQLConference
 
My Sql And Search At Craigslist
My Sql And Search At CraigslistMy Sql And Search At Craigslist
My Sql And Search At CraigslistMySQLConference
 
Solving Common Sql Problems With The Seq Engine
Solving Common Sql Problems With The Seq EngineSolving Common Sql Problems With The Seq Engine
Solving Common Sql Problems With The Seq EngineMySQLConference
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendMySQLConference
 
Unleash The Power Of Your Data Using Open Source Business Intelligence
Unleash The Power Of Your Data Using Open Source Business IntelligenceUnleash The Power Of Your Data Using Open Source Business Intelligence
Unleash The Power Of Your Data Using Open Source Business IntelligenceMySQLConference
 
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin Express
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin ExpressMy Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin Express
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin ExpressMySQLConference
 

Mehr von MySQLConference (12)

Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
 
Using Open Source Bi In The Real World
Using Open Source Bi In The Real WorldUsing Open Source Bi In The Real World
Using Open Source Bi In The Real World
 
Partitioning Under The Hood
Partitioning Under The HoodPartitioning Under The Hood
Partitioning Under The Hood
 
Tricks And Tradeoffs Of Deploying My Sql Clusters In The Cloud
Tricks And Tradeoffs Of Deploying My Sql Clusters In The CloudTricks And Tradeoffs Of Deploying My Sql Clusters In The Cloud
Tricks And Tradeoffs Of Deploying My Sql Clusters In The Cloud
 
My Sql Performance On Ec2
My Sql Performance On Ec2My Sql Performance On Ec2
My Sql Performance On Ec2
 
Inno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesInno Db Performance And Usability Patches
Inno Db Performance And Usability Patches
 
My Sql And Search At Craigslist
My Sql And Search At CraigslistMy Sql And Search At Craigslist
My Sql And Search At Craigslist
 
Solving Common Sql Problems With The Seq Engine
Solving Common Sql Problems With The Seq EngineSolving Common Sql Problems With The Seq Engine
Solving Common Sql Problems With The Seq Engine
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Unleash The Power Of Your Data Using Open Source Business Intelligence
Unleash The Power Of Your Data Using Open Source Business IntelligenceUnleash The Power Of Your Data Using Open Source Business Intelligence
Unleash The Power Of Your Data Using Open Source Business Intelligence
 
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin Express
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin ExpressMy Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin Express
My Sql High Availability With A Punch Drbd 83 And Drbd For Dolphin Express
 

Kürzlich hochgeladen

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

D Trace Support In My Sql Guide To Solving Reallife Performance Problems

  • 1. DTrace support in MySQL: guide to identifying common performance problems Alexey.Kopytov@Sun.com April 22, 2009 Test logo
  • 2. DTrace Introduction A dynamic tracing framework No need to restart application No special builds Used for debugging, troubleshooting and perfomance analysis Support in Solaris, OpenSolaris, Mac OS X, FreeBSD and Linux (in development). Test logo
  • 3. How does it work? Probe is an instrumentation point Probe “fires” when execution flow reaches probe location May have optional arguments describing the context No overhead for inactive probes Solaris kernel: ∼36,000 probes Solaris kernel + libraries: ∼50,000 probes Applications: Java VM, Apache, PHP, Ruby, MySQL, . . . Test logo
  • 4. Probe naming conventions probe_id := provider:module:function:name Collection of related probes (syscall, io, mysql) provider: Executable or library name module: Function name in the source code function: Probe name (query-start) name: Example: syscall::read:entry Test logo
  • 5. Using probes Scripts in D language: specify probes we want to trace describe actions to be run when a probe fires Example reads.d syscall :: read : entry / execname == quot; mysqld quot; / { printf ( quot; % s : read (% d , 0 x %x , % d ) n quot; , execname , arg0 , arg1 , arg2 ); } # dtrace -qs ./reads.d mysqld: read(31, 0x4ef1018, 16) mysqld: read(31, 0x4ef1018, 4) mysqld: read(31, 0x4ef1018, 4) mysqld: read(31, 0x4ef1018, 20) ^C Test logo
  • 6. Dynamic probes Dynamic probes: created on-the-fly ’pid’ provider: does not require any support from an application dynamic entry/return probes for every function function arguments are available in a script as arg0, arg1, . . . Example mysql_parse.d pid$target ::* mysql_parse *: entry { printf ( quot; % s n quot; , copyinstr ( arg1 )) } # dtrace -p ‘pgrep mysqld‘ -qs ./mysql_parse.d BEGIN SELECT c from sbtest where id=5042 ... Test logo
  • 7. Static probes Static probes: must be added into application source code may have arguments not available from dynamic ones Example sql/sql_parse.cc bool dispatch_command (...) { switch ( command ) { case COM_QUERY : MYSQL _QUERY_S TART ( query , thread_id , db , user , host ); /* Query processing starts here */ ... } } # dtrace -qn ’mysql*:::query-start { printf(quot;%snquot;, copyinstr(arg0)) }’ BEGIN SELECT c from sbtest where id=5042 ... Test logo
  • 8. Comparison of static and dynamic probes Pros and cons of dynamic and static probes Dynamic Static Work with any MySQL version yes no Stable interface no yes Require knowledge of the source code yes no Coverage high low Test logo
  • 9. MySQL static probes ∼60 probes, 200 locations in MySQL 5.4/6.0: connections Query Cache MyISAM key cache network I/O SQL query execution: parsing table locks row operations in storage engines filesort individual query types (SELECT, INSERT, UPDATE, ...) Test logo
  • 10. Overhead sysbench, OLTP read-only, 1 thread, all-in-memory D script mysql*::: { @nprobes = count(); } 89.57 88.22 w/o DTrace w/DTrace, all probes disabled w/DTrace, all tps probes enabled, ~10,000 probes/sec 3.69 inactive probes do have zero overhead 24x slowdown for 10,000 probes/sec Test logo
  • 11. Overhead 88.22 66.17 64.77 62.04 43.56 tps 3.69 0 10 100 1000 5000 10000 probes/sec ∼25% slowdown with rates < 1000 probes/sec sharp performance drop with rates > 1000 probes/sec Test logo
  • 12. Examples Test logo
  • 13. Query tracing: storage engine operations Measuring time spent in a storage engine for each query. Row operation probes: read - row - start / done index - read - row - start / done update - row - start / done delete - row - start / done insert - row - start / done Test logo
  • 14. Query tracing: storage engine operations D script mysql$target ::: query - start , { self - > query = copyinstr ( arg0 ); self - > query_start = timestamp ; self - > engine = 0; } mysql$target :::* - row - start { self - > engine_start = timestamp ; } mysql$target :::* - row - done { self - > engine = self - > engine + timestamp - self - > engine_start ; } mysql$target ::: query - done , / self - > query != 0 / { printf ( quot; % s n quot; , self - > query ); printf ( quot; Total : % dus Engine : % dus n quot; , ( timestamp - self - > query_start ) / 1000 , self - > engine / 1000 , self - > query = 0; } Test logo
  • 15. Query tracing: network I/O Measuring time spent on network operations. Network I/O probes: net - read - start / done net - write - start / done D script ... mysql$target ::: net -* - start { self - > net_start = timestamp ; } mysql$target ::: net -* - done { self - > network = self - > network + timestamp - self - > net_start ; } ... Test logo
  • 16. Query tracing: table locks and filesort Measuring time spent on table locks and filesort. Table locks probes: Filesort probes: handler - rdlock - start / done filesort - start / done handler - wrlock - start / done handler - unlock - start / done D script ... mysql$target ::: handler -* lock - start { self - > lock_start = timestamp ; } mysql$target ::: handler -* lock - done { self - > locks = self - > locks + timestamp - self - > lock_start ; } mysql$target ::: filesort - start { self - > filesort_start = timestamp ; } mysql$target ::: filesort - done { self - > filesort = timestamp - self - > filesort_start ; } ... Test logo
  • 17. Putting it all together Results # dtrace -qp ‘pgrep mysqld‘ -s ./query_snoop.d INSERT INTO order_line (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_delivery_d, ol_quantity, ol_amount, ol_dist_info) VALUES (3302, 3, 8, 4, 32055, 8, NULL, 5, 106.500000, ’anYwJuccgMvV *** Total: 595us Locks: 63us Engine: 378us Network: 101us Filesort: 0us SELECT i_price, i_name, i_data FROM item WHERE i_id = 28416 *** Total: 753us Locks: 106us Engine: 462us Network: 123us Filesort: 0us Test logo
  • 18. Hot tables: table reads D script table_reads.d mysql$target ::: index - read - row - start , mysql$target ::: read - row - start { @tables [ copyinstr ( arg0 ) , copyinstr ( arg1 )] = count (); } END { printa ( quot; % s .% s % @u n quot; , @tables ); } Probes used: read - row - start ( db , table , scan_flag ) index - read - row - start ( db , table ) Test logo
  • 19. Hot tables: table reads Results # dtrace -qp ‘pgrep mysqld‘ -s ./table_reads.d ^C dbt2w10.orders 15490 dbt2w10.warehouse 15990 dbt2w10.district 33152 dbt2w10.item 57559 dbt2w10.customer 78256 dbt2w10.order_line 219413 dbt2w10.stock 277777 dbt2w10.new_order 4421952 Test logo
  • 20. Hot tables: table updates D script table_updates.d mysql$target ::: insert - row - start , mysql$target ::: update - row - start , mysql$target ::: delete - row - start { @tables [ copyinstr ( arg0 ) , copyinstr ( arg1 )] = count (); } END { printa ( quot; % s .% s % @u n quot; , @tables ); } Probes used: insert - row - start ( db , table ) update - row - start ( db , table ) delete - row - start ( db , table ) Test logo
  • 21. Hot tables: table updates Results # dtrace -qp ‘pgrep mysqld‘ -s ./table_updates.d ^C dbt2w10.orders 12247 dbt2w10.warehouse 12676 dbt2w10.district 26291 dbt2w10.item 45762 dbt2w10.customer 60011 dbt2w10.order_line 159498 dbt2w10.stock 211085 dbt2w10.new_order 3479681 Test logo
  • 22. Queries accessing a particular table D script table_snoop.d mysql$target ::: query - exec - start { self - > query = copyinstr ( arg0 ); self - > used = 0; } mysql$target ::: handler -* lock - start / copyinstr ( arg0 ) == $$1 && copyinstr ( arg1 ) == $$2 / { self - > used = 1; } mysql$target ::: query - exec - done / self - > query != 0 && self - > used == 1 / { printf ( quot; % s ; n quot; , self - > query ); self - > query = 0; self - > used = 0; } Probes used query - exec - start ( query , connid , db_name , user , host , exec_type ) query - exec - done ( status ) handler - rdlock - start ( db , table ) handler - wrlock - start ( db , table ) handler - unlock - start ( db , table ) Test logo
  • 23. Queries accessing a particular table Results # dtrace -qp ‘pgrep mysqld‘ -s ./table_snoop.d dbt2w10 new_order SELECT no_o_id FROM new_order WHERE no_w_id = 9 AND no_d_id = 10; DELETE FROM new_order WHERE no_o_id = 2197 AND no_w_id = 9 AND no_d_id = 10; INSERT INTO new_order (no_o_id, no_w_id, no_d_id) VALUES (3251, 2, 2); ... Test logo
  • 24. Stored procedures tracing Need to find slow/ineffective queries within a store routine Slow query log only shows the CALL statement for the stored procedure, not the individual queries D script sp_trace.d mysql$target ::: query - exec - start / arg5 == 3 / { self - > query_start = timestamp ; self - > query = copyinstr ( arg0 ); } mysql$target ::: query - exec - done / self - > query != 0 / { printf ( quot; % uus % s n quot; , ( timestamp - self - > query_start ) / 1000 , self - > query ); self - > query = 0; } Probes used query - exec - start ( query , connid , db_name , user , host , exec_type ) /* exec_type = 3 for stored routines queries */ query - exec - done ( status ) Test logo
  • 25. Stored procedures tracing Results: # dtrace -qp ‘pgrep mysqld‘ -s ./sp_trace.d 523us SELECT no_o_id INTO tmp_o_id FROM new_order WHERE no_w_id = NAME_CONST(’in_w_id’,1) AND no_d_id = NAME_CONST(’tmp_d_id’,1) limit 1 77us DELETE FROM new_order WHERE no_o_id = NAME_CONST(’tmp_o_id’,2381) AND no_w_id = NAME_CONST(’in_w_id’,1) AND no_d_id = NAME_CONST(’tmp_d_id’,1) ... Test logo
  • 26. What’s next? more engine-specific probes I/O probes (syscall and io are too limited with background I/O threads) optimizer replication Test logo
  • 27. Links Section in the Reference Manual: “5.7. Tracing mysqld Using DTrace”. http://dev.mysql.com/doc/refman/6.0/en/dba-dtrace-server.htm DTrace documentation in Wiki: http://wikis.sun.com/display/DTrace/ Feature preview tree: bzr branch lp:~akopytov/mysql-server/mysql-6.0-dtrace Alexey.Kopytov@Sun.com Test logo
  • 28. Thank you! Test logo