Memory question

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Memory question

Post by Kempelen »

Is there any programmatly way to get the max amount of memory without using swap file? I mean, I would like to be able my engine could calculate and use the max amount of available "fast" memory. If using swap I think then it could be counterproductive, as it could cause the program to be slower.
thanks
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Memory question

Post by hgm »

I think specifying how much memory a program can use should be left to the user. If a user specifies more memory than the system can handle, it is his own fault, or perhaps he has a reason for it. Giving the program any say in this is just asking for trouble. Even if it knows how much memory exists, it cannot know with how many programs you intend it to share. Other memory-intensive applications could be started later.

If you want to assist noob users in this, it would be better to let the engine print a warning when it detects excessively slow hash acess. (E.g. if the nps is a factor 100 below normal, and reading out the entire hash table takes more than a reasonable amount of time.)
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: Memory question

Post by diep »

Kempelen wrote:Is there any programmatly way to get the max amount of memory without using swap file? I mean, I would like to be able my engine could calculate and use the max amount of available "fast" memory. If using swap I think then it could be counterproductive, as it could cause the program to be slower.
thanks
Yes there is - however do you want it multithreaded, multiprocessing or single threaded?
User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 4:31 pm
Location: Atlanta, Georgia

Re: Memory question

Post by Dan Honeycutt »

hgm wrote:I think specifying how much memory a program can use should be left to the user.
Yes and no. The user should set the max but the program should have the option to use less. If the user says use 32 mb hash table and program sees physical memory will only accommodate 16 it should be able to set 16.

Best
Dan H.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Memory question

Post by hgm »

I don't agree. For one, it is unreasonable to burden all engines with this. If you want this sort of thing, it should be a GUI task. And it is also pretty pointless. Because when the user makes an allocation error it will in almost all cases be a small one (like a factor 2), because he happens to play more engines at once than he happened to do on the last occasion (e.g. an engine-engine game rather than human-engine. Or two games simultaneously rather than one). And the engine would then happily find the requested size to be smaller than the amount of physical memory, and would not complain.

In addition, when some engines would correct for 'over-asking', and others don't, you might not immediately notice when you over-ask in a tourney (when the engines in the first game silently reduced their memory usage), and discover at the end that all other games have been crap. It would be much better for the user if he would have seen immediately that the hard disk goes berserk with swapping, and no depth was reached.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: Memory question

Post by syzygy »

We're not talking about "all engines".

Fermin simply wants his engine to do something, and his question is simply if anyone can give him a hint on how to achieve this. This has little to do with what others think that engines "should" do. Fermin is not writing a protocol, and he is not laying out rules for others to follow in any other way.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Memory question

Post by hgm »

One should never shy of the attempt to convince people of their erroneous ways...

This is a very counter-productive idea, that will almost never do any good to Fermin's engine, and will cause a lot of harm to those using it.
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Memory question

Post by Edmund »

hgm wrote:One should never shy of the attempt to convince people of their erroneous ways...

This is a very counter-productive idea, that will almost never do any good to Fermin's engine, and will cause a lot of harm to those using it.
The optimal TT size is not uniform across all engines for a given time control. As such it should be left to the engines to adjust this size. Rather implement standardized ways for an engine to report hash-table useage (a) allocated space in % of total provided space (b) filled space in % of allocated space. These can be used as indicators and triggers for warnings within the GUI.
User avatar
Dan Honeycutt
Posts: 5258
Joined: Mon Feb 27, 2006 4:31 pm
Location: Atlanta, Georgia

Re: Memory question

Post by Dan Honeycutt »

hgm wrote:I don't agree. For one, it is unreasonable to burden all engines with this. If you want this sort of thing, it should be a GUI task. And it is also pretty pointless. Because when the user makes an allocation error it will in almost all cases be a small one (like a factor 2), because he happens to play more engines at once than he happened to do on the last occasion (e.g. an engine-engine game rather than human-engine. Or two games simultaneously rather than one). And the engine would then happily find the requested size to be smaller than the amount of physical memory, and would not complain.

In addition, when some engines would correct for 'over-asking', and others don't, you might not immediately notice when you over-ask in a tourney (when the engines in the first game silently reduced their memory usage), and discover at the end that all other games have been crap. It would be much better for the user if he would have seen immediately that the hard disk goes berserk with swapping, and no depth was reached.
It's not a burden. As Ron said, it's not mandatory, its an option the engine can exercise if it chooses.

Do you warn your children that the stove is hot or do you let them find out for themselves. I do concede that the latter can be advantageous as far as teaching the lesson.

Best
Dan H.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Memory question

Post by hgm »

I have no children, but if I had, I would warn them that the stove is hot. Of course I expect them to touch it anyway, and that will teach them to take my warnings seriously. A priceless lesson...