Author: martin fierz
Date: 18:09:17 12/09/01
aloha, i have written a checkers interface and a checkers engine, and recently i made a change so that the user can set the hashtable size in the interface and it is communicated to the engine. up to now, my code looked like this: // global variables struct hashentry hashtable[BIGNUMBER]; now it looks like this: // global variables struct hashentry *hashtable; // initialization hashtable = malloc(BIGNUMBER*sizeof(struct hashentry)); later in the code i access the hashtable just as before with hashtable[i]. i would have expected these two approaches to be equivalent, but the new one drops a few % of speed overall. that's a lot, because the whole hashing stuff only takes up a few % of my work, so it looks like that part is something like half as fast as earlier. i know that small changes can make a big difference because of caching. i'm asking here, because ed gilbert who also wrote an engine for my interface made a similar change and observed a similar effect. are we doing anything wrong? suggestions for improvements? another question i have is about malloc - under windows you have different memory allocation functions like VirtualAlloc and HeapAlloc. HeapAlloc will not allow allocations > 256MB, at least not on win98. i usually use malloc in C, because i do not want to break the portability of my code. my windows book says i should use VirtualAlloc for "large objects" (= more than 1MB), and HeapAlloc for smaller objects. is malloc in C (MSVC 6.0) translated into a HeapAlloc? could this be the reason that the program is slow, should i be using VirtualAlloc? mahalo martin
This page took 0.02 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.