The need for tunability and measurability
To program is human, to instrument is divine. Complex systems that will support a heavy workload will eventually have to be tuned for it. There are two prerequisites for tuning: tunability, and measurability.
Tunability generally means configuration settings. Adding configuration settings is a sign of a humble and wise programmer. It means that the programmer acknowledges “I don’t understand how this system will be used, what environment it will run in, or even what my code really does.” Sometimes things are hard-coded. InnoDB is notorious for this, although don’t take that to mean that I think Heikki Tuuri isn’t humble and wise — nobody’s perfect. Sometimes programmers set out to create systems that are self-tuning. I’m not aware of any success stories I can point to in this regard, but I can point to plenty of failures. Perhaps I can’t think of any successes because I don’t need to.
Measurability (instrumentation) is the next sign of a wise and humble programmer. If your system must be tuned, then it needs to be measured to enable wise decisions. There are at least two important kinds of metrics — a subject for another blog post. Most large systems I’ve worked with (primarily database systems, but operating systems too) are seriously lacking in measurability. A programmer who makes the system measurable acknowledges “I might be wrong, and if I am, it’s a good thing to enable people to prove it,” and realizes that “you cannot improve what you cannot measure.”
Complex, high-load systems get micro-optimized, making them even more opaque. By the time an I/O operation in InnoDB reaches the disk, it’s often impossible to blame it on a specific query. Not just because of lack of instrumentation — even with perfect instrumentation, I/O operations wouldn’t be assignable one-to-one with user actions. Optimization does that, because a lot of optimizations are about deferring, anticipating, or combining work. That makes instrumentation even more important.
This weekend, I heard conflicting stories about instrumentation in Postgres. Someone claimed to have offered patches with a detailed set of instrumentation (I’d also heard this story from someone else at the same company, six months ago in a different place). He told me that the maintainers had declined it on the basis of the added overhead. Someone else told me that no such offer had been made, at least not in public where the decision could be taken to the mailing lists. I don’t know what’s true. I do know that stock Postgres is virtually un-instrumented in ways that matter a lot. The same can be said of MySQL, although interestingly the Venn diagram of the ways these two projects are instrumented doesn’t overlap all that much.
The performance and maintenance cost of adding instrumentation to an application pales in comparison to the benefits. There’s a famous quote from Oracle guru Tom Kyte, who when asked about the cost of Oracle’s performance instrumentation, estimated it at negative ten percent. That is, without the ability to measure Oracle and thus improve it, it’d be at least ten percent slower. I think ten percent is a modest estimate for most systems I work with.



Hopefully we will see some improvement at least in MySQL with the performance_schema in the upcoming versions.
Having worked on Oracle, SQLserver and MySQL, the lack of basic and easy to use metrics is a pain in the proverbial when working with MySQL.
Have Fun
PaulM
28 Mar 10 at 10:06 pm
When I worked with SQL Server, I took the profiler for granted. Then I became a MySQL user, and I’ve been pining for good instrumentation ever since. Despite being an open-source fanatic, I am able to appreciate that SQL Server is a very well-built database server.
Xaprb
28 Mar 10 at 10:20 pm
I am also looking for statspack (Oracle) alternative in PostgreSQL and MySQL databases.
Denish Patel
29 Mar 10 at 10:53 am
“Someone claimed to have offered patches with a detailed set of instrumentation (I’d also heard this story from someone else at the same company, six months ago in a different place). He told me that the maintainers had declined it on the basis of the added overhead.”
This seems unlikely at best. Certainly people have posted instrumentation patches which have been rejected; but these have been rejected because:
a) They were poorly written, or
b) They only worked on one OS, or
c) They instrumented something which nobody else found useful to measure (at least not in the way presented), or
d) They had demonstrated *hefty* overhead (as in 2% for a single measurement), or
e) The method of instrumentation used did not integrate with anything in our existing instrumentation or any standards.
I’ve seen all these cases in proposed instrumentation patches; in some cases the author (esp. Greg Smith and Itagaki Takahiro) reworks the patch to make it acceptable, and in other cases potential contributors take their ball and go home. That’s OSS, and you can’t really control people’s motivations.
I don’t think there’s anyone in the community who wants less visibility into operation, resources and performance. It’s one of the most frequent demands of our user base. Doing it well is also hard and unsexy (to date, not ONE Summer of Code proposal has been about instrumentation), so it’s going to be slow going for the forseeable future.
Still, every PostgreSQL release since 8.0 has had a few more things you could monitor or query than the last release.
Josh Berkus
30 Mar 10 at 1:10 am
Josh, I suspected there were several versions of the story. I find that counters (number of rows read) are all but useless. You cannot do any meaningful performance analysis with them in the absence of timing information.
Xaprb
30 Mar 10 at 11:02 am
“I am also looking for statspack (Oracle) alternative in PostgreSQL and MySQL databases.”
For Postgres, have a look at pgstatspack – it is based on Oracle statspack
http://pgfoundry.org/projects/pgstatspack/
Brad
1 Apr 10 at 10:40 am
Baron,
Events with timing information are definitely better than simple counters. However, simple counters are better than nothing at all.
Josh Berkus
2 Apr 10 at 11:16 pm