Archive for November, 2007

KVM: the state of the game

November 16th, 2007

KVM is one of those things I've kept an eye open for ever since I heard about it. First of all, I should mention that there is currently a great deal happening on the virtualization front, here's a list of virtual machines to look over. What is more, it is not so much a wealth of competing products, because it seems that everyone has their own little twist on the matter, and none of these are completely equivalent solutions. There is a host of different terms to describe these techniques to boot.

I've known about VMware for 5-6 years, and that is how I originally started out playing around with linux in a safe and easy environment. Since then there have been many linux centric projects that have made waves at some time or another, not all of which I've tried. I think User Mode Linux was the first one I heard about. It ran a modified host kernel and could host multiple guest machines that would also be running a modified kernel. You could use it to host Virtual Private Servers, which has been common now for a while, but wasn't all that common back then. You could also set up honeypots with them. There was also a VMware competitor called Win4Lin (for Win9x) which was like a poor man's VMware. It would run fairly well, but it was far from being equally polished and feature complete. It also had the advantage of being strictly an application, no kernel hooks. A couple of years later there was a new project that was very loud, namely Xen. Xen is one of those odd projects that had a lot of potential and broad support, and yet didn't quite have the kind of adoption one would expect. It was quite a complicated piece of code that required a lot of setting up and so on, but Fedora shipped it by default (I'm not sure if they still do) and it worked out of the box. Again it was a modified host kernel, but the guests could run completely unmodified. I'm not sure how recent this is, but nowadays Xen also runs various operating systems, although in some cases they need to be modified. Then there was CoLinux, which approached the issue from the opposite side of the table: Linux as guest. I never got around to trying it as I never had to use Windows for long stretches of time, but a lot of people (those poor souls trapped on Windows) were very enthusiastic about it.

So what about KVM? Well, KVM is interesting because of how "close to the metal" it is. Obviously, any kind of virtualization adds some overhead due to the unavoidable indirection. But KVM actually does not position itself above the kernel, as most virtual machines do, but uses kernel primitives to host guests (in fact it sets up a whole new kernel execution mode guest for this). It also uses cpu virtualization extensions (current Intel and AMD chips) to gain speed. All of this is fairly recent stuff, KVM was merged into the kernel for 2.6.20. So, of course, the major advantage of KVM is that it's well supported and well tested in kernel mainline.

However, KVM is not a virtual machine in itself, in the sense of being a complete application. It's more like an access layer which exposes a /dev/kvm interface. The way to run KVM is through QEMU, which is actually an emulator. I haven't mentioned emulators so far, but they are in a sense the second type of virtualizer/emulator software. The difference is that a virtualizer creates a virtual machines with virtual hardware (eg. network adapter) for the guest operating system to run on, but the cpu is still that of the host. An emulator instead emulated the guest cpu, and therefore has to translate every machine instruction into a different one. This means that you can run say a powerpc guest on an x86 host. It sounds very cool, but it's orders of magnitude slower, so it's not as much of a hot topic.

But back to KVM. As I said, the application is still QEMU, but it's accelerated through KVM. I had been looking forward to taking it for a spin, especially now that I also have an Intel chip with the virtualizing extensions. On Ubuntu it's all ready to go, just install the userland applications from the repo (qemu and kvm) and you're set. Qemu is quite nice and simple to use, but the combo is temperamental and unforgiving. You can set up your guest machine in 2 minutes, but with Windows I had quite a number of fatal crashes (Exception 13) that aren't that obvious to figure out. Furthermore, it seems that even linux distros aren't trivial to run on KVM/QEMU. In terms of a complete machine virtualization it leaves something to be desired. Notably, the video flickers quite visibly while running on a vesa driver. That isn't to say that other virtual machines cannot or will not use KVM as part of their solution.

But for the time being VirtualBox (something of a lightweight VMware, which is also free software) is more convenient.

Disclaimer: This entry is something of a historical account of my exposure to virtual machines. I did not do any fact checking here, and the statements only reflect what I recall about the particular products.

two types of laughers

November 14th, 2007

Laughter is a delicate mechanism. It's hard to determine what makes us laugh and what makes us laugh more or less, depending on the particular context. In other words, if you take some group of strangers, it's hard to predict if they are going to laugh, and if so "how much". Not only because every person has a different sensibility, but also because laughter has a strong social influence.

When you react to something funny, you are affected by the reactions of people around you. Some people will burst out laughing even if they are the only person who thought it was funny. But a lot of people are a bit reluctant to be that exposed, so even if they are overcome they try to tone it down as much as possible.

Of course, when you are the recipient of something funny, you can't predict how it will affect you, there's no way to prepare yourself. It's like someone were to say "I want to try something on you, close your eyes". And you don't know what's coming.

But if *you* are the one making the utterance, with the expectation that it's going to be funny, it's like a controlled experiment. You can sort of plan it, what to say, how to say it, in what tone, in what expression etc. And when I say controlled experiment, what I mean is that you can examine how people's responses to your utterance affect you. For instance, if you say something that makes people laugh (intentionally), it often makes you laugh also, doesn't it? Or even if you were already laughing about it, it makes you laugh more. I'm surprised that it even works in cases where you wouldn't necessarily expect it to work. Like say if I send an email that is supposed to be funny, and hence the communication isn't continuous in time, I might get a response after 3 minutes, at which point I've moved on to something else, and getting a positive response to the joke makes me laugh again. Knowing that someone was laughing without even seeing or hearing it still triggers that reaction.

But back to saying funny things. People have different styles for this. Usually the funniest people are the ones who don't laugh (at least not initially) at their own jokes. They just say it, and sort of "put it out there", they *offer* the joke to anyone who will take it. And if it's obvious that it was a joke, and no one laughs, then it's awkward. But otherwise it could just be dismissed as an off the cuff remark. In fact, trying to disguise a joke so that either it's funny or it's not figured out as a bad joke is quite a skill in itself, some people do it really well.

Have you ever seen people who can't even get through the joke because they start laughing while telling it? I would still include them in this category, because if you can't help laughing you can't help it, plain and simple. So before you can even express what makes you laugh you're already laughing. Of course, if you do this then someone can't really determine whether you meant to laugh or not, if you hadn't been overcome, so it's a bit sketchy.

But then there's the other category of people, who utter something, pause and then start laughing hysterically. This is pretty strange, because you made it through telling it before it made you laugh, but then it seemed to have kicked in. So either you are saying something not (yet) realizing the joke in it, or you are purposely delaying your laughter to afterwards. Of course, the former can happen from time to time, but for people who always do this it makes me wonder what is happening. The thing is, if you laugh hysterically at your own jokes, and no one else does, this makes you look like a mental patient. This is why it's a lot more important for these people that you laugh with them, because they've already committed themselves with respect to the joke.

Typically, it's the people who laugh at their own jokes who put pressure on you to laugh also. This can give different results depending mostly on who the person is. If it's a person you are *used to* laughing with, it's almost like you laugh anyway even though this particular case isn't actually all that funny. However, if it's a person who is either never funny or just someone you don't know, most likely you won't laugh and you either make yourself laugh (which feels so uncomfortable and phony), or you stand your ground and don't laugh. At which point certain conceited people will accuse you of not having a sense of humor, to which you can respond "I do have one, and you just killed it."

However, there is also another angle to the self-laugher. Some people laugh very outwardly, like they care that other people should laugh too, this is important to them. There are also those who laugh more discretely. I would say semi-discretely, in the sense that they are not actually suppressing, but they are nevertheless laughing to themselves and not laying claims on other people's laughter. But I think that when they laugh in response to their own jokes, this is actually because they only then realize the joke in what they said, so this would place them closer to the first category, those who laugh because they can't help it, except the reaction comes late.

I was asleep before my head hit the pillow

November 11th, 2007

Have you heard people say this? It's a pretty popular expression. I find it a bit unlikely (or at the very least unsettling) myself.

The first thing to take into account is that falling asleep generally isn't instantaneous. So depending on the person it takes something like a few minutes to half an hour (or maybe more) to fall asleep from the moment you go to bed. Now, suppose you are exceptionally tired, then perhaps the time is shortened. But instantaneous? That seems unlikely.

Secondly there's a safety concern in play. Depending on the elevation of your fall, and the material the pillow is made from, you could have a concussion. If you were actually standing up at the time and you just literally *fell asleep* then let's hope it was a clean landing.

But the most striking omission here is that people never mention how aggravated they felt by being woken up less than a second after falling asleep! The first period of sleep, much like the last, is not deep sleep, it's not coma material. It's sensitive sleep, and if someone were to wake you up right after you fell asleep you would easily wake up. So a fall would definitely wake you up. How frustrating that must have been for you.

let's make Bill Gates happy

November 11th, 2007

In the annals of computing we find his Open Letter to Hobbyists, which attempted to appeal to our morals so that we stop pirating software.

The problem, of course, is that software is just not worth paying for. If we didn't run pirated software, we just wouldn't use software. That's the reality of it, pure and simple.

If you're a seasoned Windows user, somewhere in your house you have a cd/dvd kit. Or a dedicated partition on your disk. And what you have there is a full suite of install programs for all the software you run. Windows is unstable and insecure, and since it's also impossible to backup fully, the only solution is to keep copies of all software in installers, so that you can restore your system when the need arises (and if you've used Windows for a few years, you've done this several times already, or you have "a geeky friend" that you call and he does it).

This is the reality of Windows, you need all these crappy little programs like WinZip (who the hell is gonna pay for that?), because otherwise your system is unusable. Windows by itself is unusable, the first thing you have to do is install all these little "helper" applications that help you get anything done.

the doctrine of systematic work

November 8th, 2007

It seems to me that many (perhaps most) teachers look favorably on methods that do not require of them any creative output. One of the favorite methods in an average teacher's repertoire is the principle of systematic work.

Systematic work is based on the old adage of practice makes perfect. This is what you say to little kids who want to be in the Olympics: you work hard and you can get there. And there is no reason to doubt that. The fact is that to be successful in sports requires an enormous amount of systematic work. However, there is one caveat that they don't mention - it only works if there is a limited amount of people doing this. If we all started working systematically, no matter how good we'd be, the Olympics wouldn't have space for 7 billion of us anyway. But I digress.

But if you look at it from a structural point of view, systematic work means brute force. So basically you work at it for as long as it takes, until it cracks. And sometimes this works. But it assumes that your understanding of the problem has some sort of linear behavior, so the more you work on it the more you understand. And that is by no means a law of nature.

It's much worse when the behavior is asymptotic. You can work on it forever and you still won't get it. To illustrate this, imagine there is a tree in your yard that is blocking your otherwise excellent view. You want that tree out of there. So you grab a rope and tie it to the tree. You take the other end and tie it to your bike. Now if the tree is a certain size, you can try all you want to pull it out of the ground, and the tree won't budge. Apparently, this simple fact is lost on some teachers. (For more on this read The Truth About Homework.)

Brute force often works, but it's the last resort and it's not the smartest way of solving a problem. To be able to work systematically in any sort of productive way you need to know more than just to work systematically, which is basically a synonym to the word repeat. If you find yourself in the middle of a lake, in a rowing boat, systematic work is no doubt your best strategy. But even then you have to set a course first. This is a question some teachers don't have an answer to. If they explain something and you don't understand it, then there must be something wrong with you and you need to "work harder". Since everything can be solved through systematic work, well there you go. You just need to help yourself.

What is worse is that sometimes you need to deliver creative solutions, either because the problem cannot be solved otherwise, or because that is the only way you can score a high grade. Now, creativity is the opposite of systematic work. I can easily imagine that systematic work originates from an earlier time when schools thought "teaching discipline" was an integral part of their business, and therefore if you're very disciplined you're going to be working systematically, it fits like a glove.

Now try combining that with creativity. Here I am working at something systematically and all of a sudden I have an idea "what if I tried to... no! I will not allow myself to be distracted, I have self discipline!" But it is interesting that teachers expect creativity when they themselves have no obligation to muster any. It's precisely those cases where something is hard to explain that you so desperately need the ability to think creatively and come up with a different description of the same thing. The best teacher I've ever had (high school, English) was also the most creative one I've seen.