Instrumentation

Doug's Oracle Blog

  • Home
  • Papers
  • Books
  • C.V.
  • Fun
  • Oracle Blog
  • Personal Blog

Jul 8: Instrumentation

At first this post might seem off-topic, but it's a post that I've been planning to write for a long time because, even if it might seem a bit of fluffy fun, it reinforces one of the most important tools at your disposal.

Instrumentation in your code is pure gold when it comes to analysing performance.

Without instrumentation you're flying blind and, although most people in the Oracle community are familiar with the importance of instrumentation via the Wait Interface, 10046 trace files, ASH data, the PL/SQL Profiler and so on, I wanted to discuss a very early example of my own experience with instrumentation to illustrate that this stuff has been around for a long time!

I learnt this lesson when I was around 17 years old (which means, erm 29 years ago or so). When I first started developing commercial games for the ZX Spectrum, some of the most important questions I had to ask where things like ...

"Which part of the code is taking the most time". (i.e. I needed an activity profile to focus my tuning efforts in the right places.)

"When I'm re-drawing this object on the screen, is the refresh raster running across that area of the TV screen at the same time?" (i.e. Are objects going to flicker?)

The objective was to have as much of the screen refresh code run in the period between when the raster hit the bottom of the TV screen (which triggured the interrupt that we'd hook into via an interrupt service handler) and when it hit the top of the area that the Spectrum actually used for display*. When things happened and how long they took was absolutely critical to the speed and smoothness of the game experience.

Answering these questions might be a bit trickier than you think though! If you're writing Z80 machine code, your entire application might run in less than 1/100 of a second. I know that, because one of mine did. So any instrumentation you add to your code had better :-

1) Have a very small overhead.
2) Be non-intrusive.
3) Give you just the information that you need and no more.

As with many things in the assembly language world, the solution turned out to be an extremely primitive but effective one. As a strong clue, take a look at this video AFTER MUTING YOUR SOUND (unless you want your ears to bleed). Old Spectrum users will recognise those yellow and blue alternating lines as the Spectrum loads data. It turns out that they are really easy to produce by using an OUT instruction to port FE, using the lowest 3 bits to set the border colour. (There are a lot more technical details buried in this FAQ!)

So, by using a single lightweight instruction to change the border colour at key points in the application, you could see a visual profile of how long different bits of your application were taking to run and when they stopped and started, relative to when the Spectrum was redrawing the TV display. With 8 colours available, it was just about possible to work out a high level activity profile of your application. The profile would change as the application had to perform more work on certain screen refreshes so you could see when you were running close to those dreaded flickering graphics!

Simple, cool, elegant and extremely useful. A response time profile updated 50 times a second for the cost of a few Z80 OUT instructions ;-)

That's why I'll always be respectful of the challenges that the authors of the Wait Interface, ASH, DTrace and the like have overcome. Low-level instrumentation has to be effective and lightweight.

Instrumentation - you know it makes sense!

* When you have this knowledge, it makes you see Spectrum games in a new light. That's why programmers liked big information and score areas at the *top* of the screen - because it gave them more time to draw objects before the raster on the TV screen reached them!
Posted by Doug Burns Comments: (0) Trackback: (1)

Trackbacks
Trackback specific URI for this entry

PingBack
Weblog: www.pythian.com
Tracked: Jul 14, 05:18

Comments
Display comments as (Linear | Threaded)

No comments


Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
BBCode format allowed
 
 

Statistics on Partitioned Tables

Contents

Part 1 - Default options - GLOBAL AND PARTITION
Part 2 - Estimated Global Stats
Part 3 - Stats Aggregation Problems I
Part 4 - Stats Aggregation Problems II
Part 5 - Minimal Stats Aggregation
Part 6a - COPY_TABLE_STATS - Intro
Part 6b - COPY_TABLE_STATS - Mistakes
Part 6c - COPY_TABLE_STATS - Bugs and Patches
Part 6d - COPY_TABLE_STATS - A Light-bulb Moment
Part 6e - COPY_TABLE_STATS - Bug 10268597

Comments

Doug Burns about 10053 Trace Files - Different Plan in Different Environments
Tue, 02.04.2013 08:57
You're welcome. Now I just nee d to pull my finger out and ac tually come up [...]
Howard Rogers about 10053 Trace Files - Different Plan in Different Environments
Mon, 01.04.2013 23:08
Makes a big difference, so tha nks for that! With two brow ser windows, o [...]
stelioscharalambides.com about 10053 Trace Files
Sat, 30.03.2013 16:28

Upcoming Presentations

Bookmark

Open All | Close All

Syndicate This Blog

  • XML RSS 2.0 feed
  • ATOM/XML ATOM 1.0 feed
  • XML RSS 2.0 Comments
  • Feedburner Feed

Powered by

Serendipity PHP Weblog

Show tagged entries

xml 11g
xml ACE
xml adaptive thresholds
xml ASH
xml Audit Vault
xml AWR
xml Blogging
xml conferences
xml Cuddly Toys
xml Database Refresh
xml DBMS_STATS
xml Direct Path Reads
xml Fun
xml grid control
xml hotsos 2010
xml listener
xml Locking
xml oow
xml oow2009
xml optimiser
xml OTN
xml Parallel
xml Partitions
xml Patching
xml swingbench
xml The Reality Gap
xml time matters
xml ukoug
xml ukoug2009
xml Unix/Shell
xml Useful Links

Disclaimer

For the avoidance of any doubt, all views expressed here are my own and not those of past or current employers, clients, friends, Oracle Corporation, my Mum or, indeed, Flatcat. If you want to sue someone, I suggest you pick on Tigger, but I hope you have a good lawyer. Frankly, I doubt any of the former agree with my views or would want to be associated with them in any way.

Design by Andreas Viklund | Conversion to s9y by Carl