Ouch

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Ouch

Post by stegemma »

brtzsnr wrote:For most chess engines doubling the speed only gives you 30-50 Elo. For example 4 CPU version is only 60-100 Elo stronger than the 1 CPU version for most engines. C / C++ / D are only 10-25% faster than Java / Golang on most CPU intensive tasks[...]
Maybe this % is not true, for chess engines but despite from that, the problem is not the language but the algorithms. If you have a good algorithm (s), your program is strong with any language. If you apply the same algorithm with a better and faster language then you'll get a faster and better engine.

You can't compare different programs written in different languages but you can compare the same program written in different languages. I think that a rewrite of a JAVA program from JAVA to C/C++ would give a great performance boost, not only 10-25%.

Of course this is just an hobby for the most of us, so anybody should use the language that looks more confortable and gives more satisfaction. If you use the same language for your chess engine and for your business works, then you'll get back a learning advantage in both fields.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
sandermvdb
Posts: 160
Joined: Sat Jan 28, 2017 1:29 pm
Location: The Netherlands

Re: Ouch

Post by sandermvdb »

stegemma wrote: You can't compare different programs written in different languages but you can compare the same program written in different languages. I think that a rewrite of a JAVA program from JAVA to C/C++ would give a great performance boost, not only 10-25%.
One thing you should keep in mind is that Java has so called intrinsic methods. For these methods, the JVM swaps Java code out and replaces it with hand-written code that is optimized to a particular architecture. Some examples which my engine calls millions of times:

Long.bitCount()
Long.numberOfTrailingZeros()

And some others which I use but not that often:

Math.max() and Math.min()
Arrays.fill()
System.arraycopy()

(an advantage of this concept is that you don't need to compile it ahead of time for a particular architecture)