Author: Robert Hyatt
Date: 09:39:45 07/24/98
Go up one level in this thread
On July 24, 1998 at 11:54:48, Roberto Waldteufel wrote: > >On July 24, 1998 at 09:28:26, Robert Hyatt wrote: > >>On July 24, 1998 at 08:06:59, Tom Kerrigan wrote: >> >>>On July 23, 1998 at 19:39:40, Roberto Waldteufel wrote: >>> >>>>the graphics overhead of Windows. When there are no other applications open, it >>>>seems strange to me that Windows does not automatically allocate RAM instead of >>>>slow-access disc space. I could understand it if I were multitasking other >>> >>>No, you missed the point. >>> >>>Windows does not allocate RAM. It allocates memory space. It probably does some >>>work to make sure that a lot of the memory allocated is already in RAM, but when >>>you allocate 40MB and you only have 64MB RAM, that's a very hard thing to do. >>>That's why you see so much swapping. >>> >>>Cheers, >>>Tom >> >> >>however, if the memory management is done *right* then active programs page in, >>inactive programs page out, and the paging stops, assuming (a) the active >>program can actually fit into real memory and (b) that there are not more active >>programs than can actually fit into real memory. Playing chess should have one >>compute-bound process and the rest should slowly "go away" to disk. >> >>in any case, the "paging" should be a flurry as most people see when they ask >>"Why does crafty take 10 secs to make the first book move, and then 0 seconds >>for the next 20 on my win95 machine, while on your linux box it can make the >>first 20 moves in 0 seconds?" >> >>Unix (linux) has to page in every page of executable code one time, as it is >>referenced by the program during execution. For non-initialized data, there is >>no paging I/O at all... it just allocates pages *as they are referenced and not >>before* and gives them to the program via the memory management hardware map. > >Hi Bob, > >If I understand you correctly, Unix/Linux OS allocates program memory in RAM, >but Windows95 only allocates virtual memory that is on disc and is not swapped >into RAM until it is used? That would seem to be a big advantage over the >Windows method for a chess program. > >When Crafty runs under unix or linux, the hash table is allocated in RAM >straight away, but what is the exact sequence of events under Windows95? Do you >do anything in your program code to make Crafty pause on the first book move >while the swapping takes place, or does Windows handle that by itself? I found >that no swapping was happenning at all while the user was prompted to choose >which colour pieces he wants, but it starts with a vengence as soon as the >search engine gets going, which doesn't happen until a real search is underway, >by which time it is too late. > >I have recently implemented a rather clumsy work-around which seems to help. >Before prompting the user for colour of pieces, I store zero in all the hash >table records. This is of course completely unnecessary for the program >algorithm, since the arrays are automatically initialised to zero without any >program code, but at least it gets the swapping in done before the game begins. >I don't like this approach - do you know of a better way? > >Best wishes >Roberto I honestly don't know how windows works, but the guys at Microsoft are not stupid, and I assume they have read the classic operating systems textbooks. I think there might be two problems: 1. win95 can steal lots of memory for file(disk) caching. When you ask for memory, those have to be freed, and might still be queued up for writing which means you have to wait for the writes to complete before you can allocate the pages, before you can make any progress in the program. 2. most operating systems don't allocate memory for the process, load it into memory, then start it. They typically set the program counter up, set the memory management hardware to say "no pages are present" and let the program page-fault pages in from the executable file on disk. This can take time. If you request a big hash table (crafty for example) when crafty first malloc()'s the thing, it *must* clear it completely, not knowing what kind of garbage is in there. That means it touches every page of memory, which means that maybe win95 has to flush some other stuff *out* of memory so it can allocate pages to Crafty. My linux box is big enough that this is never a problem, and when I ask for 128M of memory or whatever, I get it *instantly*...
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.