Skip to main content
gamedev.net
🔒 Locked

Optimisation by search

Started by Nice Coder 1 reply 450+ views
Original Post
Nice Coder
Nice Coder
Basically, your looking for that one non-obvious bithack that would save your game heaps of time (something that gets called heaps, maybe?), so you want to optimise it to bits. How? You define a function which defines how well it if. (from 0-2^32. So as it gets more accurite, its score goes up, as it gets faster its score goes up). You then generate each possible opticode, for eg. if you have maybe 12 instructions (very risc), then you could search up to about 7 opticodes. (39,089,245 instructions needed. If your looking for all programs 1 opticode long, then 2, then 3, ect.) Once you have your 39 billion instructions, you execute the program and you find out how well it does. (using your function). If it does better, then the one you last seen, then you dump the one you last seen, and you add this one. The whole thing might take a few hours -> a day to finish tho. (then again, this is very parellelisable, so you could have a group of 12 comps and get a free opticode extra that you can search. Or you could 'sign up' a few thousand computers to help with the optimisation ). How does this one fair? From, Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Nemesis2k2
Nemesis2k2
Optimizers these days are pretty good. They can shuffle around opcodes far better than most mere mortals. The commercial packages that are currently available are probably going to be better at optimizing than anything anyone else could put together. I also don't think the "brute force" method is nessicary. Processors aren't random, they work on logic. If you have well defined rules, your optimizer should know what will be more efficient without testing it. A lot of those really fine detailes are processor specific too, so finding the "best case" isn't always that simple. Something might be a lot faster on a P4, but a lot slower on an Athlon, so a regular optimizer picks another option which lies in the middle ground.

Usually, you can get much bigger performance gains by modifying your algorithms on a higher level. Rather than worrying about what exact opcodes are used, and in what order they come, you're better off looking at if you really need to perform those operations at all. There are many different algorithms to perform the exact same task, some much more efficient than others. Sometimes, you can do with the data being in a different form too, such as dealing with squared values, rather than calculating the square root. Your time is far better spent on high-level optimizations.

There are a few noted exceptions to this rule. If you know you can make use of SIMD instructions, you'll have to code with them in mind. Also, eliminate branching inside loops where possible. The conditonal operator in C does give major performance bonuses if you're going to be executing that segment of code often.
Nice Coder
Nice Coder
Just something to look at:
The best log2 function we have is 5 clocks.

I'm pretty sure you could make an exhaustive search of that rather quickly.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.