Tuning The Kernel With A Genetic Algorithm 251
fsck! writes "Jake Moilanen provided a series of four patches against the 2.6.9 Linux kernel that introduce a simple genetic algorithm used for automatic tuning. The patches update the anticipatory IO scheduler and the zaphod CPU scheduler to both use the new in-kernel library, theoretically allowing them to automatically tune themselves for the best possible performance for any given workload. Jake says, 'using these patches, there are small gains (1-3%) in Unixbench & SpecJBB. I am hoping a scheduler guru will able to rework them to give higher gains.'"
Innovation and open source (Score:4, Insightful)
I mean, common. Just look at this. Amazing.
And even if it turns out to be not that good, it was still a good read
CPU's and compilers (Score:2)
I think a hardware design that does more logic controls would be best...
Re:Innovation and open source (Score:2)
> A common criticism of Open Source is the accusation that it lacks innovation.
> I mean, common. Just look at this. Amazing.
Well, not to denigrate the efforts of the people working on the Linux kernel, but Java has had Hotspot and other Just in Time compiling tricks since 2001, and I'm sure there are others before it.
Java Hotspot does not use the same technology of c
Re:Innovation and open source (Score:2)
Innovative != invention
This is very, very, innovative. It's easily the most innovative thing to hit a kernel since the 70's.
Re:Innovation and open source (Score:2)
Just repeating a lie over and over doesn't make it true.
Cut/Copy/Paste works just ducky, and has for years. In fact, both methods of cut/paste work just ducky -- highlight/middle-click and highlight/shift-ctrl-x/shift-ctrl-v. And copy with highlight/shift-ctrl-c.
Re:Innovation and open source (Score:4, Insightful)
Re:Innovation and open source (Score:3, Informative)
Oh, and X supports many formats on the clipboard [jwz.org]
Re:Moderators on drugs? (Score:2, Informative)
Proof [fitzsimmons.ca]
Complexity? (Score:5, Insightful)
Re:Complexity? (Score:3, Insightful)
Re:Complexity? (Score:3, Interesting)
Re:Complexity? (Score:3, Interesting)
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
now days?
Re:Complexity? (Score:2)
While I have to admit that none of them is anything as scary as some of the stuff that happened to 2.4 around 2.4.7-2.4.13 when the VM got changed, it is not right.
The supposedly ready and released kernel 2.6 by now from min
Re:Complexity? (Score:3, Insightful)
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
2.6 is still beta.
BSD looks alot better.
Re:Complexity? (Score:2)
If 2.6 was production ready the debian folks would include it.
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
Re:Complexity? (Score:2)
Not that I agree with the grandparent, but it ticks me off that there's no 2.7 branch, and i mean like awful. I'm all for developing the stable branch, but to your average user (like me!), you'd rather know your kernel is going to work.
How about instead of 2.7 being the groundwork for 2.8, why don't we put changes into 2.7, let the early adopters and kernel hackers use it, and when we find bugs like the Cd-burning problem, we can fix them befo
Re:Complexity? (Score:2, Insightful)
IMHO, if GA implementation can be made really reliable it could maybe replace other code which may be (I don't know) even more complicated.
Re:Complexity? (Score:5, Informative)
I'm a machine learning researcher, and I'll second this. Also, the code for it will be quite self-contained (if done right), and shouldn't affect any parts of the kernel except where it's called to run an iteration.
They also work quite well. That's why they are so popular.
Sure they do. For a lot of problems, though, they're not so hot compared to other optimization methods like hill climbing and empirical gradient descent - they tend to run slowly - and I would like to ask Mr. Moilanen why he didn't use one. GAs are especially good with nominal parameters (discrete, unordered). But I would expect tuning parameters to be either discrete or continuous.
GAs are theoretically capable of finding global optima, except that's kind of a red herring. The only reason you can prove that is that, theoretically, no matter how small the probability, you'll eventually get exactly the right sequence of mutations to produce a global optimum. In practice, they tend to produce local optima like most other optimization algorithms - especially as Moilanen describes it:
All of the tunings are then ordered from best performance to worst, and the worst half of the performers are replaced with new possible tunings derived from the best half of the performers.
You generally have to be a little less selective (more random) than this.
Re:Complexity? (Score:2)
Re:Complexity? (Score:2, Insightful)
good luck with that (Score:5, Insightful)
In other words, non-competitive genetic algorithms are only as smart as the fitness function you give them. If your fitness criteria aren't smart enough to cover all the bases, your solutions will have unpredictable deficiencies.
GA + Hill Climbing... (Score:4, Interesting)
As an alternative, perhaps using some form of pseduo-GA that tries to find pre-tuned parameters that most closely match your operating environment and then letting a Hill-Climbing algorithm hit it would be a better solution.
Hill climbing can also be used in a GA type manner by letting the GA determine witch parameters to climb and in what order. The climbing itself is pretty straightforward, allow vectors to interact with individual parameters. If the result is worse, reverse the vectors or switch to new parameters. Rinse, repeat.
Yes, GA can produce odd bugs and potholes. Yes, it is the fitness test that determines if that will be true. But a good GA will generally find solutions that are as good or better than hand tuning for search spaces that are very complex. Overall, this is a good idea but is probably more complex than advertised.
Re:GA + Hill Climbing... (Score:5, Insightful)
If you have the resources to exhastively search the space... you don't need a GA.
A GA is generally used when the search space is hopelessly huge and you need to chart a course from A to(wards) B but you don't know the way.
And in finding this solution, which is "grown", not engineered, it's much easier for unintended wierdnesses to creep in. A GA might solve problem X by ruining performance on problem Y, something that you, as a software engineer, would never even consider viable, and hence you forgot to force the fitness function to check problem Y along with problem X.
Re:GA + Hill Climbing... (Score:2)
Ahh, semantics. "Allow the GA to exhaustively search vs. The GA searches exhaustively"
Of course the GA will not do an exhaustive search, but it must have the ability to do so (e.g. explore all the really bad solutions as well as the good ones - the solution space should not be artificially constrained by eliminating random solutions from testing).
It is pretty obvious that I was trying to say this if you actually look
Re:GA + Hill Climbing... (Score:2)
Re:GA + Hill Climbing... (Score:2)
GA's, IMHO, are designed for problems in which the amount of computational firepower is practically insignificant in comparison to the size of the domain.
I think you'd do better finding a different term than "exhaustive" for what you are trying to say.
Re:GA + Hill Climbing... (Score:2)
Re:GA + Hill Climbing... (Score:2)
If the GA is not able to reach the entire space or if it is biased in such a way as to make portions of the space hard to reach, then it is not an effective GA. If I wanted to
Re:GA + Hill Climbing... (Score:2)
Re:GA + Hill Climbing... (Score:2)
Thank you. We agree. That was exactly my point - the implications are that in a scenario like this, if you allow the search to progress as it should, you will constantly be testing very sub-optimal solutions which will result in negative side-effects to system performance. For that reason, it would be necessary to place h
Re:GA + Hill Climbing... (Score:2)
I agree. However, we have a problem: Running a GA on an operational system will (MUST) test more highly sub-optimal solutions than it will near-optimal solutions. The performance penalty for searching the space will overwhelm the performance gains f
Re:GA + Hill Climbing... (Score:2)
Yes, you are right about that. I suppose I am imagining that this would be most useful in a data-center rather than the desktop. The desktop scenario is
Re:GA + Hill Climbing... (Score:2, Interesting)
Granted it was a user level app and stored it's data in an sql db, but roughly half
Re:GA + Hill Climbing... (Score:2)
Actually, that is precisely what I am talking about. The fitness test that pro
Re:GA + Hill Climbing... (Score:2)
I don't think that's true. What do you consider effective? I consider the algorithm to be effective if it finds a better solution, which this does.
Effective: Sure, any gain is welcome. That is correct. But for the GA to be effective at what it does, it needs to be able to search the search-space. If the GA starts with 20 predetermined tuning parameter sets and mates and mutates those, then all we have is a fancy hi
Re:GA + Hill Climbing... (Score:3, Insightful)
Mutation in Genetic Algorithms are supposed to act as hill-climbers *most of the time*. Mutations are not supposed to make drastic changes - that is the job of random individulas inserted into populations and recombination (mating). Mutation (of the bit flipping variety) is mostly there to provi
Parent is overrated FUD ! (Score:2)
First of all, the possible parameters that the genetic scheduler can affect can all be changed safely. The genetic scheduler does not try to invent new scheduling algorithms; rather, it tests different parameter sets and existing algorithms to find which works best with the current workload.
Yo
Re:Parent is overrated FUD ! (Score:2)
There's just this sense among lay people though that GA's are some kind of magical cure-all, and I think it's because this type of search is a bit of a black box. Put something in, turn the crank, and wait for a solu
not a panacea (Score:3, Interesting)
They might converge on a point of attraction that is not the highest possible.
Sure the only way is to exhaustively search the "chromosome" space for every possibile combination, and computers are good at brute force!
Simulated Annealing (Score:3, Interesting)
Re:not a panacea (Score:2, Insightful)
Mutation helps with convergence issues.
Sure the only way is to exhaustively search the "chromosome" space for every possibile combination, and computers are good at brute force!
Um, I don't even know how many parameters are involved to be adjusted, but it does not take that many to make exhaustive search useless, even for a computer.
Re: not a panacea (Score:2)
> Sure the only way is to exhaustively search the "chromosome" space for every possibile combination, and computers are good at brute force!
Problem is, the search space grows exponentially with the size of the chromosome. No problem if you have a short chromosome, but brute force is intractable for long chromosomes.
For example, if you are trying to optimize a set of 100 binary parameters for some problem, brute force requires you to evaluate 2^100 combinations.
Re:not a panacea (Score:2)
It might even mean that no local maxima are *ever* found
Other kernel parameters? (Score:5, Interesting)
If this package could be extended to the other parameters, it would save my customers a *lot* of time and money.
If nothing else, this could be a deciding factor for some of our clients to use linux instead of windows.
Re:Other kernel parameters? (Score:3, Interesting)
Re:Other kernel parameters? (Score:3, Interesting)
What about adding hooks for applications to to send/recieve performance changes after tweaks? Services, daemons, etc, need to communicate how the GA's latest tweak adjusted performance, right?
So.... (Score:2, Funny)
Re:So.... (Score:2, Funny)
Not worth it... (Score:2, Insightful)
Re:Not worth it... (Score:5, Insightful)
What is "on the borders of statistical error" depends on how many times the test was run, and how much variation there had been in his results before. I think it's pretty safe to assume that if he knows how to implement a genetic algorithm into the linux kernel, he knows how to handle statistics properly.
Re:Not worth it... (Score:2)
Re:Not worth it... (Score:2)
being mostly just a proof of concept at this stage.
Re:Not worth it... (Score:3, Insightful)
Re:Not worth it... (Score:3, Interesting)
Pragmatism and statistics are _not_ a good mix.
Note that, for example, many hosting providers host hundreds of web sites per system. Adding a couple of percent in performance then adds a couple of percent to the bottom line of the cost picture for those companies. The same is true for supercomputer clusters used by many c
This has been done before (Score:2, Funny)
"Daystrom felt that such an act was an offense against the laws of God and man, and the computer that carried his engrams also believed it."
--Kirk
One question remains: (Score:3, Funny)
Genetic packet scheduler (Score:3, Interesting)
The problem: Determining Performance (Score:4, Insightful)
What is the system using to decide if a new parameter set is better than a previous? What is the fitness test?
Some applications are disk-bound, others are CPU-bound, others are network bound. The performance dance is often non-obvious (e.g. some applications will achieve generally higher performance by allowing I/O higher priority than context switching, while others that appear to perform in a similar manner will achive higher performance by reversing that order).
The kernel does not have any mechanism to determine if a particular application is performing better or worse, it can only really get a guage of throughput and load. While this MAY be enough to get small systemwide performance gains, in order to really acheive significant application-specific performance gains, I think that applications would need to explicitly add support for adaptive tuning by logging relevant performance metrics for the kernel to tune around.
Thoughts?
Re:The problem: Determining Performance (Score:2)
I thought long how the "fittness" part of that GA might work. Ultimately the only "fittness" the kernel can with high precision measure is "load" isn't it?
Any better ideas?
angel'o'sphere
Re:The problem: Determining Performance (Score:2)
Any better ideas? I suppose the only way would be to have some "tuning" hooks that applications could use to announce their own performance metrics. The GA could optimize around load when these metrics are not available and take them into account if they are.
Re:Also: why tune a startup routine? (Score:2)
Oh no! (Score:2, Funny)
Monte Carlo w Bayesian Stats (Score:2)
GAs aren't rocket science (Score:5, Insightful)
In reality, the basic GA framework is "just" another efficient search algorithm, no cooler or more complex than, say, a hash table or a binary search tree; at its simplest, a GA is a way to find an optimal configuration of components without looking at all possible (potentially explosively exponential) combinations; instead, you look at just some permutations, and as you iterate through generations, applying breeding and mutation, you arrive at a generation which is statistically close to optimal.
GAs are also in no way new or unproven technology; a nice example of mainstream use is PostgreSQL [postgresql.org]'s query planner, which uses GAs to optimize query plans.
Re:GAs aren't rocket science (Score:2)
quote:
When to Use GAs
GAs treat the optimization problem as a black box, and are therefore very flexible. Because GAs use very little problem structure they will inevitably perform poorly relative to an algorithm which is is designed for a specific problem type. GAs are therefore best suited to messy problems which do n
Re:GAs aren't rocket science (Score:2)
But in the case of simple parameter-fitting problems (ie this one) , you're right.
practical applications (Score:2, Interesting)
this is a really interesting idea.
Moving the genetic algorithm processing to another machine may be warranted. If you had a good idea of what you were going to be doing (heavy database work for instance), a dedicated machine could be used to find an optimal scheduling solution and then that could be implemented on the production machine.
or maintain a list
Re:practical applications (Score:2)
Ahh.. interesting idea..
If I am running in a cluster environment, I could dedicate one or more machines in the cluster to evolve tuning parameters. That machine could publish "discoveries" to the oth
Re:practical applications (Score:2)
The implementation is horribly useful and needs improvement on the scheduler end as is said. The schedulers that it can u
Re:practical applications (Score:2)
The two machines are different (even if their specs are theoretically the same). Minor differences in characteristics can result in highly sub-optimal results if you move the determined parameters from one machine to another.
To obtain *useful* parameter sets, you will need to do it on the machine in question. Your second option points towards this.
Shouldn't this be done in userspace? (Score:2)
Tweaking the algorithm or using other ones? (Score:2)
Does anyone use this one? (Score:2, Interesting)
But it is getting much better now, I don't know how much generations there will be needed to get things right. It feels pretty much the same as with the vanilla kernels, let's see where this leads
Anyone else with experiences? AFAIK this thingy can only be tweaked by editing the code and
Re:Futurology (Score:2, Interesting)
It's pretty funny considering he is talking in his grave and totally serious robo-voice...
Re:Futurology (Score:4, Funny)
It's pretty funny considering he is talking in his grave and totally serious robo-voice...
You mean there is another voice?
Re:Futurology (Score:2)
If one of Linus' kids takes over from his father then that could be considered a kind of tuning of the kernel using genetic algorithms!
EricWhy the Vioxx recall reduced spam (well, maybe temporarily) [ericgiguere.com] (see also my William Shatner All-Bran humor [ericgiguere.com]
Re:Dear Kernel Coders (Score:3, Insightful)
In other words: if you have someone who's good at writing Genetic Algorithms, but not so good at searching
Re:Dear Kernel Coders (Score:3, Informative)
Re:Dear Kernel Coders (Score:5, Informative)
Patches for 2.4 can be found in this changeset [bkbits.net].
Patches for 2.6 can be found in this changeset [bkbits.net].
Click on the little "diff -Nur style" link for a an actual usable patch.
In the course of a few hours, you have the fixes already. Yay for open source.
Btw, nice troll
Re:Dear Kernel Coders (Score:2)
Re:Dear Kernel Coders (Score:2)
Please take time to read next time.
Re:Dear Kernel Coders (Score:2)
Re:Oh, Oh (Score:2)
kudos to SpanKY, who found the right words for this poor soul
Re:Oh, Oh (Score:2)
I think you are allowed to just say USE="*"
If you want the binaries to be slower than RPMs...
Re:Oh, Oh (Score:2)
No kidding? (Score:2)
Wow, I never would have guessed...
That is sarcasm, btw. I, too, am using gentoo and love it.
Re:Oh, Oh (Score:2)
Re:Oh, Oh (Score:2)
Mine are somewhat conservative:
CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer -pipe -ftracer -mmmx -msse -msse2 -mfpmath=sse"
I don't use O3 and some people claim it can make things slower. For some systems any O* will turn on -fomit-frame-pointer even though every how-to recommends it.
I do use gcc-3.4.3 which isn't marked stable in portage for x86, but I haven't noticed any trouble with it and th
Re:Oh, Oh (Score:2)
To see what flags are set 'behind the scenes' you can run 'gcc -Q -v -O3 -march=pentium4 helloworld.c' on a 'hello world' file. Here's an example:
#gcc -Q -v -O3 -march=pentium4 helloworld.c
options enabled: -feliminate-unused-debug-types -fdefer-pop
-foptimize-sibling-calls -funit-at-a-time -fcse-follow-jumps
-fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
-fstrength-reduce -fu
Re:ooooh man (Score:2)
Intelegent people consider a GA (Score:2)
Anyone who has ever created a logging interface understands that a log will slow down a system.
And so, even if one were to run the GA and have it show things, it will still mean that later that GA should be removed or swithced off. Otherwise the workings of the GA and its requisite log will slow down the system.
So, use a GA,and then intellegently remove it a
Re:as someone who knows about GA (Score:2)