.NET ReadyToRun Compilation

Discussion of chess software programming and technical issues.

Moderator: Ras

JoAnnP38
Posts: 253
Joined: Mon Aug 26, 2019 4:34 pm
Location: Clearwater, Florida USA
Full name: JoAnn Peeler

.NET ReadyToRun Compilation

Post by JoAnnP38 »

Has anyone else experimented with the ReadyToRun (R2R) compilation option when deploying an executable? I have found that *not* selecting this option yields generally better performance for me. Here are two runs of the same perft executable, one compiled with R2R and the other without.

With R2R:

Code: Select all

Iteration #1:
1: Elapsed = 00:00:00.0000335, Mnps:   0.60, nodes = 20
2: Elapsed = 00:00:00.0001357, Mnps:   2.95, nodes = 400
3: Elapsed = 00:00:00.0018958, Mnps:   4.70, nodes = 8902
4: Elapsed = 00:00:00.0420720, Mnps:   4.69, nodes = 197281
5: Elapsed = 00:00:00.3205513, Mnps:  15.18, nodes = 4865609
6: Elapsed = 00:00:05.6758356, Mnps:  20.98, nodes = 119060324
7: Elapsed = 00:02:27.7284386, Mnps:  21.63, nodes = 3195901860

Iteration #2:
1: Elapsed = 00:00:00.0000048, Mnps:   4.17, nodes = 20
2: Elapsed = 00:00:00.0000344, Mnps:  11.63, nodes = 400
3: Elapsed = 00:00:00.0006678, Mnps:  13.33, nodes = 8902
4: Elapsed = 00:00:00.0097789, Mnps:  20.17, nodes = 197281
5: Elapsed = 00:00:00.2258040, Mnps:  21.55, nodes = 4865609
6: Elapsed = 00:00:05.7429003, Mnps:  20.73, nodes = 119060324
7: Elapsed = 00:02:27.7574297, Mnps:  21.63, nodes = 3195901860
Without R2R:

Code: Select all

Iteration #1:
1: Elapsed = 00:00:00.0001029, Mnps:   0.19, nodes = 20
2: Elapsed = 00:00:00.0002328, Mnps:   1.72, nodes = 400
3: Elapsed = 00:00:00.0035162, Mnps:   2.53, nodes = 8902
4: Elapsed = 00:00:00.0721988, Mnps:   2.73, nodes = 197281
5: Elapsed = 00:00:00.3456442, Mnps:  14.08, nodes = 4865609
6: Elapsed = 00:00:04.9307155, Mnps:  24.15, nodes = 119060324
7: Elapsed = 00:02:00.5594141, Mnps:  26.51, nodes = 3195901860

Iteration #2:
1: Elapsed = 00:00:00.0000029, Mnps:   6.90, nodes = 20
2: Elapsed = 00:00:00.0000277, Mnps:  14.44, nodes = 400
3: Elapsed = 00:00:00.0003944, Mnps:  22.57, nodes = 8902
4: Elapsed = 00:00:00.0081063, Mnps:  24.34, nodes = 197281
5: Elapsed = 00:00:00.1851946, Mnps:  26.27, nodes = 4865609
6: Elapsed = 00:00:04.9083432, Mnps:  24.26, nodes = 119060324
7: Elapsed = 00:02:00.1972151, Mnps:  26.59, nodes = 3195901860
Since the R2R executable is larger I think I'm going to stop using R2R for my chess engine. Has anyone else played around with this option?
User avatar
lithander
Posts: 915
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: .NET ReadyToRun Compilation

Post by lithander »

It's good to have the option now but ihmo ahead of time compilation isn't how C# was meant to be. A JITer can (in theory) compile code optimized for the hardware it's currently running on which could make the code run faster than a AOC-compiled "generic" binary.

Ahead of time compilation is a rather new feature and it doesn't create highly optimized machine code at the performance levels of C++ anyway. So my binaries that I release on github have never been Ready2Run but I like to include all the dependencies so that users don't have to worry about installing the correct .Net framework.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess