Author: Miguel A. Ballicora
Date: 07:57:30 12/10/01
Go up one level in this thread
On December 09, 2001 at 21:09:17, martin fierz wrote: >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. But you do not know that for sure without profiling. Maybe your hashtables accesses are the same but the different setup in memory causes to drop few % of efficiency in a bottleneck, somewhere else. Your evidence that you have a big performance problem in the hashing is too indirect. I do not think that any conclusion can be drawn without a profile. Regards, Miguel 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 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.