lp://staging/~stewart/drizzle/perf-events

Created by Stewart Smith and last modified
Get this branch:
bzr branch lp://staging/~stewart/drizzle/perf-events
Only Stewart Smith can upload to this branch. If you are Stewart Smith please log in for upload directions.

Branch merges

Related bugs

Related blueprints

Branch information

Owner:
Stewart Smith
Project:
Drizzle
Status:
Development

Recent revisions

1166. By Stewart Smith

A very basic, proof of concept perf_udf() that counts CPU instructions like the BENCHMARK() function does wall time.

It uses the very new (~linux 2.6.31, and at least .32 to get the headers)
perf_events interface to Linux to use the *hardware* Performance Management Unit
to monitor the CPU instructions spent. Since this has proper support in kernel,
and the abstraction is awesome, we actually get only the instructions spent executing
*this* thread - i.e. our connection to the database.

The end result is, much like you can use BENCHMARK() to see how fast MD5('pants')
is when run 1,000,000 times... we can find out how many CPU instructions are executed:

drizzle> select perf_udf(1, MD5('pants'));
+---------------------------+
| perf_udf(1, MD5('pants')) |
+---------------------------+
| 43540 |
+---------------------------+
1 row in set (0 sec)

drizzle> select perf_udf(100, MD5('pants')), perf_udf(10000, MD5('pants')), perf_udf(100000, MD5('pants'));
+-----------------------------+-------------------------------+--------------------------------+
| perf_udf(100, MD5('pants')) | perf_udf(10000, MD5('pants')) | perf_udf(100000, MD5('pants')) |
+-----------------------------+-------------------------------+--------------------------------+
| 702098 | 69246981 | 682496729 |
+-----------------------------+-------------------------------+--------------------------------+
1 row in set (0.38 sec)

and it does have sensible ratios too, so we can tell that 1000 times as much
work does really take about 1000 times as long:

drizzle> select perf_udf(1000000, MD5('pants')) /perf_udf(1000, MD5('pants'));
+---------------------------------------------------------------+
| perf_udf(1000000, MD5('pants')) /perf_udf(1000, MD5('pants')) |
+---------------------------------------------------------------+
| 1001.58248635599 |
+---------------------------------------------------------------+
1 row in set (3.5 sec)

Currently this code is a bit crude, only 1 measurement only on 1 cpu (so if
your hardware doesn't aggregate across cores, the data will be wrong if your
connection migrates)

1165. By Brian Aker <brian@gaz>

SE cleanup interface.

1164. By Brian Aker <brian@gaz>

Small cleanup.

1163. By Brian Aker <brian@gaz>

Merge Stewart.

1162. By Brian Aker <brian@gaz>

Merge Stewart

1161. By Brian Aker <brian@gaz>

NULL commit

1160. By Brian Aker <brian@gaz>

Merge Stewart.

1159. By Brian Aker <brian@gaz>

Merge Monty

1158. By Brian Aker <brian@gaz>

Merge of Padraig

1157. By Brian Aker <brian@gaz>

Fix for OS-X

Branch metadata

Branch format:
Branch format 7
Repository format:
Bazaar RepositoryFormatKnitPack6 (bzr 1.9)
Stacked on:
lp://staging/~drizzle-trunk/drizzle/development
This branch contains Public information 
Everyone can see this information.

Subscribers