On 12/4/06, Peter Drake <[EMAIL PROTECTED]> wrote:
The three most important things seem to be: 1) Run java in -server mode. This appears to double speed for no effort
I understand this is largely the old optimize for processing or optimize for interactivity trade off. It's almost as old as multitasking computers. Sun's Java out of the box is optimized for interaction. 2) As you say, avoid creating objects. For example, instead of
creating a new array each time a method is invoked, make the array a field and just clear it out when you need a "new" one. Similarly, instead of Foo x = y.clone(); do something like x.copyDataFrom(y); where of course you have to write copyDataFrom().
There are a related class of optimizations here. Object creation on the heap, as you've observed can be slow and has a delayed penalty for object destruction (which may or may not be reflected in profiling). You can avoid this by reusing objects, or by allowing the interpreter to allocate as many as possible objects on the stack. I haven't looked at this in at least two generations of Java compilers, but it used to be faster to allocate four ints on the stack called one, two, three and four than an array of four ints, and if you're worried about the memory footprint / cache efficiency, then the stack frame is already in memory. The code is necessarily more complex to write, but if you already have a known-working version, you can write / generate a comprehensive suite to confirm they perform identically. 3) Algorithmic improvements are always more important that fine-tuning. Indeed. cheers stuart
_______________________________________________ computer-go mailing list computer-go@computer-go.org http://www.computer-go.org/mailman/listinfo/computer-go/