lp://staging/~stewart/drizzle/perf-events
- Get this branch:
- bzr branch lp://staging/~stewart/drizzle/perf-events
Branch merges
Branch information
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)
Branch metadata
- Branch format:
- Branch format 7
- Repository format:
- Bazaar RepositoryFormatKnitPack6 (bzr 1.9)
- Stacked on:
- lp://staging/~drizzle-trunk/drizzle/development