Author: Robert Hyatt
Date: 15:14:25 12/02/02
Go up one level in this thread
On December 02, 2002 at 17:34:24, Russell Reagan wrote: >I've never been able to get a clear answer on this. How much time does it take >to allocate memory dynamically, with a call to malloc or new? Are we talking 10 >cycles, 100 cycles, 1000 cycles, or more? It can vary all over that range. To _really_ allocate memory can be a time-consuming task, the first time a new page is actually allocated. After that, it might not be so bad but if you are doing malloc/free regularly, then things get fragmented and some sort of garbage collection will be used that will again add to the time. I would not do this _inside_ the search, ever... > >I ask because I'm considering playing with some object-oriented ideas, but if >it's 1000 cycles to allocate (say) one move object, I could have completely >generated many (or all) of the moves for the position by the time allocation was >complete, and that's no good. If I could find out this information, I could >potentially save myself a lot of work only to find out my performance went into >the toilet. > >I think there are some interesting issues here, such as using a dynamically >growing array (like std::vector) and not having to worry about making sure I'm >not "too deep" or going to cause a stack overflow, or working with different >sub-classes for different move types. If allocation is 100 cycles, clearly >that's no good for allocating a new move object _every_ time you generate a >move, but it may not be so bad when using an std::vector, since it only >allocates occasionally. A dynamic array is bad from the get-go, for performance. OK for designing things of course. But for chess, inside the engine, no... > >Basically, I like the idea of not having to worry about the details of things >like making sure you're within the bounds of an array, and it may be worth a >small performance hit, but I have no idea what the magnitude of the performance >hit is. > >Russell
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.