I recently attended a talk where a kernel hacker told about debugging techniques when the Linux kernel is having problems. One of the things he mentioned was that kernel oops messages can sometimes be so long they won't fit on a screen. When users submit them, e.g. by photographing the screen, they don't show enough information to be useful.

It struck me that it might be possible to encode the message in various ways to make them use less space so they don't scroll off the screen. My first idea was a 2D bar graph, but those can be difficult in a text-only situation. A second idea is to use gzip and base64 encoding, and a refinement of that is to use base85 encoding.

This has probably been thought of before, but I thought it'd be fun to prototype it anyway. I used a free ascii85 library for Python:


import zlib, bz2, base64, sys, tempfile, os, ascii85

msg = sys.stdin.read()
print "msg:", len(msg)
compressed = zlib.compress(msg, 9)
print "compressed:", len(compressed)
fd, compressed_name = tempfile.mkstemp()
os.write(fd, compressed)
compressed_f = file(compressed_name)
ascii85.encode(compressed_f, sys.stdout)

The output looks like this:

msg: 1634
compressed: 875

Gzip seems to compress things to about half the original size, and ascii85 inflates that by about 25%. However, the result is then all mashed up on long lines, so use of vertical space if fairly small. Thus, this might be acceptable, perhaps as an optional feature.

Decoding that using OCR from a digital photograph should be possible, and is left as an excercise for the reader, as is an implementation of the encoder that is actually suitable for the kernel. (Read: not in Python.)

It might be possible to write a custom compressor: oops messages seem fairly regular in shape, after all.

There you are. If this is useful for anyone, at any time, please do use the idea.