Kristian's web log

March 31, 2009

Varnish, Munin, RRDTool and RPN – Yaaai

Filed under: /dev/random, Varnish — Tags: , , , — kristian @ 22:06

I’ve spent a couple of days working on a new munin-plugin for Varnish, and it’s been interesting. First of all, there are several existing Varnish plugins, all slightly different with their own quirks. This new one will replace the plugin in the varnish subversion repo and hopefully enter the list of official munin plugins.

Spent monday setting up the basic plugin, and all day (tuesday) trying to figure out how the heck to display hitrates sanely. The statistics varnish delivers are ever increasing, which munin handles exceptionally well (well, rrdtool does). The only way to display it relatively (in percentages) is to either store history on the node (which is out of the question) or fix it up with a CDEF.

As it turns out, there’s a slight bug in Munin trunk with regards to the CDEF-solution, in addition to a lack of working examples of how to do this. Nicolai helped me track down the Munin-issue (patch comming), so then it was only the RPN-insanity…

'cdef' => 'client_req,0,EQ,0,cache_miss,client_req,/,100,*,IF'

This little beauty is obviously the equivalent of

if (client_req == 0) {
0
} else {
(cache_miss / client_req) * 100
}

That is, if I actually got that right. So in this case, it defaults to 0 cache misses if there are no requests in the relevant period.

Right now I’m at the point where the graphs _draw_ correctly but the numbers just don’t add up. This only applies to the percentage-based graphs, which so far is only the hit_rate graph. I guess that’s a problem for tomorrow.

At any rate, I’ll see if I can’t get some real-life data later this week, in the meanwhile, here’s the four first graphs with random httperf-generated data…

Request rate Threads
Backend traffic Hit rate in percent

March 28, 2009

VDPAU – 1080p with CPU cycles to spare

Filed under: /dev/random — Tags: , , , — kristian @ 20:00

I just went from Ubuntu 8.04 to 9.04 (through 8.10). For two reasons:

1. EXT4

2. VDPAU

In Ubuntu 9.04, the 180-series of drivers from nVidia is included. Doesn’t matter much? Well, it does have VDPAU. That means GPU-assisted decoding of h264. I’m currently playing a 1080p video on my Core 2 Duo 2.4GHz on battery power and it’s smooth. Very smooth.


kristian@kjeks:~$ while sleep 1; do cat /proc/cpuinfo | grep MHz; done
cpu MHz : 2000.000
cpu MHz : 800.000
cpu MHz : 2400.000
cpu MHz : 800.000
cpu MHz : 1600.000
cpu MHz : 800.000
cpu MHz : 1600.000
cpu MHz : 800.000
cpu MHz : 2000.000
cpu MHz : 800.000
cpu MHz : 2000.000
cpu MHz : 800.000

That’s my cpu clocking down to conserve battery and because the decoding isn’t taking place on the CPU any more. Mind you, the CPU usage is still pretty high, but the difference between 70-90% of CPU usage and 100% is the difference with decoding just in time and decoding just a bit too late.

One side note is that VDPAU doesn’t work while running Compiz. Yet.

To get this madness to work, nVidia has made a nice little script and patch to compile mplayer with the required support. Available from ftp://download.nvidia.com/XFree86/vdpau/, it’s surprisingly clean. These things have a nasty habit of doing Bad Stuff, but this really is as clean as it gets. It’s essentially just a few svn checkouts followed by patch -p0, ./configure and make. Not even make install. Oh yeah, if you’re doing this you obviously need patch, subversion and the ability to build mplayer.

After that, all you do is grab your favorite h264 1080p video and play it with mplayer -vo vdpau.

Powered by WordPress