diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-19 16:31:58 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-19 16:31:58 +0200 |
| commit | da31fbb09fec50c127bd16a99fca81bdd013c40d (patch) | |
| tree | ff9dddc5f6af5859fcb9ac3304a8adaf0ce951c7 /benchmarks/benchmarks.md | |
| parent | 39e736f68c0d92b47bd124357a33c02d2bd2fdc5 (diff) | |
| download | nissy-core-da31fbb09fec50c127bd16a99fca81bdd013c40d.tar.gz nissy-core-da31fbb09fec50c127bd16a99fca81bdd013c40d.zip | |
Add benchmark results
Diffstat (limited to '')
| -rw-r--r-- | benchmarks/benchmarks.md | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/benchmarks/benchmarks.md b/benchmarks/benchmarks.md new file mode 100644 index 0000000..abecc85 --- /dev/null +++ b/benchmarks/benchmarks.md | |||
| @@ -0,0 +1,275 @@ | |||
| 1 | # Benchmarks for the H48 optimal solver and comparison with vcube | ||
| 2 | |||
| 3 | This page contains some benchmarks for some of the possible | ||
| 4 | configurations of the H48 optimal solver. For comparison we also | ||
| 5 | include similar measurements for Andrew Skalski's impressive optimal | ||
| 6 | solver [vcube](https://github.com/Voltara/vcube), which has been taken | ||
| 7 | as a benchmark reference throughout the development of H48. The two | ||
| 8 | solvers differ both in method (although they both use an A* search) | ||
| 9 | and implementation. | ||
| 10 | |||
| 11 | Similar benchmarks can be found: | ||
| 12 | |||
| 13 | * In Chen Shuang's | ||
| 14 | [dedicated github page](https://github.com/cs0x7f/cube_solver_test/wiki), | ||
| 15 | which includes many more solvers. At the time of writing, the version | ||
| 16 | of H48 used for these benchmarks is a rather old one. Note that | ||
| 17 | cube48opt is a re-implementation of the H48 solver by Chen Shuang. | ||
| 18 | * In Enrico Tenuti's [thesis](https://github.com/enricotenuti/h48thesis), | ||
| 19 | also using an old implementation of H48, but including more data and | ||
| 20 | nice plots. | ||
| 21 | |||
| 22 | ## Setting | ||
| 23 | |||
| 24 | *All movecounts are in Half Turn Metric* | ||
| 25 | |||
| 26 | For the benchmarks we used some sets of random positions that can be found | ||
| 27 | in `benchmarks/scrambles`. We divide them by optimal solution length, | ||
| 28 | because the time to solve a scramble grows exponentially on the number of | ||
| 29 | moves, so mixing up positions with long and short solutions is going to | ||
| 30 | make the shorter solution almost irrelevant. Even within the same solution | ||
| 31 | length the time to solve a random position can vary significantly, | ||
| 32 | so we have used sets of 25 scrambles and taken the average of those, | ||
| 33 | except for the [Superflip](https://en.wikipedia.org/wiki/Superflip), | ||
| 34 | which is a single scramble. | ||
| 35 | |||
| 36 | For short solutions, the very low numbers we get with the largest solver | ||
| 37 | may be particularly inaccurate, because writing the solution (together | ||
| 38 | with some log messages) to standard output may take a significant portion | ||
| 39 | of the time, depending on the terminal emulator used and other factors. | ||
| 40 | |||
| 41 | We ran two different tests: finding a single optimal solution and finding | ||
| 42 | *all* optimal solution. Both problems involve an exhaustive search at | ||
| 43 | depth `n-1`, but the second also involves and exhaustive search at depth | ||
| 44 | `n`. Comparisons with vcube are only done in the first case, because | ||
| 45 | vcube's current configuration does not allow for finding multiple | ||
| 46 | solutions, as far as I am aware. | ||
| 47 | |||
| 48 | Since the size of the pruning table used by the solver is of utmost | ||
| 49 | importance, we include two statistics: time per cube and time per cube | ||
| 50 | *adjusted by table size*. The adjustment we took simply consists in | ||
| 51 | multiplying the time per cube by the size of the table. Empirically | ||
| 52 | this leads to more even results across the board, as the speed of the | ||
| 53 | solvers of the same family seems to scale linearly with the size of the | ||
| 54 | pruning table. | ||
| 55 | |||
| 56 | All benchmark tests were done on the following configuration: | ||
| 57 | |||
| 58 | * CPU: AMD Ryzen 7 7700 (8 cores, 16 virtual threads) | ||
| 59 | * Memory: 2x Corsair Vengeance 32GB 5600MHz | ||
| 60 | * Motherboard: Gigabyte B650M K | ||
| 61 | * Operating system: Debian 12 (Linux kernel 6.1.0) | ||
| 62 | * Compiler: GCC 12.2.0 for H48 and Clang 14.0.6 for vcube | ||
| 63 | |||
| 64 | ## Single solution | ||
| 65 | |||
| 66 | Average time for finding a single optimal solution. | ||
| 67 | |||
| 68 | ### Single thread | ||
| 69 | |||
| 70 | Time per cube (in seconds, lower is better). | ||
| 71 | |||
| 72 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 73 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 74 | |H48 h11 k2|56.1GiB | 0.23 | 1.15 | 5.08 | 31.30 | 278.47 | | ||
| 75 | |vcube 404 |31.8GiB | 0.30 | 1.25 | 6.87 | 57.49 | 291.31 | | ||
| 76 | |H48 h10 k2|28.1GiB | 0.34 | 1.80 | 7.77 | | | | ||
| 77 | |vcube 308 |21.2GiB | 0.20 | 1.11 | 6.92 | | | | ||
| 78 | |H48 h9 k2 |14.1GiB | 0.42 | 2.84 | 12.86 | | | | ||
| 79 | |vcube 208 | 7.3GiB | 0.57 | 4.41 | 20.75 | | | | ||
| 80 | |H48 h8 k2 | 7.1GiB | 0.86 | 6.66 | 27.40 | | | | ||
| 81 | |H48 h7 k2 | 3.6GiB | 1.47 | 8.90 | 42.46 | | | | ||
| 82 | |vcube 112 | 2.4GiB | 1.01 | 9.39 | | | | | ||
| 83 | |H48 h6 k2 | 1.8GiB | 2.28 | 16.89 | | | | | ||
| 84 | |||
| 85 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 86 | |||
| 87 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 88 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 89 | |H48 h11 k2|56.1GiB | 12.90 | 64.51 | 284.99 |1755.93 |15622.17 | | ||
| 90 | |vcube 404 |31.8GiB | 9.54 | 39.75 | 218.47 |1828.18 | 9263.66 | | ||
| 91 | |H48 h10 k2|28.1GiB | 9.55 | 50.58 | 218.34 | | | | ||
| 92 | |vcube 308 |21.2GiB | 4.24 | 23.53 | 146.70 | | | | ||
| 93 | |H48 h9 k2 |14.1GiB | 5.92 | 40.04 | 181.33 | | | | ||
| 94 | |vcube 208 | 7.3GiB | 4.16 | 32.19 | 151.48 | | | | ||
| 95 | |H48 h8 k2 | 7.1GiB | 6.11 | 47.29 | 194.54 | | | | ||
| 96 | |H48 h7 k2 | 3.6GiB | 5.29 | 32.04 | 152.86 | | | | ||
| 97 | |vcube 112 | 2.4GiB | 2.42 | 22.53 | | | | | ||
| 98 | |H48 h6 k2 | 1.8GiB | 4.10 | 30.40 | | | | | ||
| 99 | |||
| 100 | ### Multithread (4 threads) | ||
| 101 | |||
| 102 | Time per cube (in seconds, lower is better). | ||
| 103 | |||
| 104 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 105 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 106 | |H48 h11 k2|56.1GiB | 0.06 | 0.31 | 1.31 | 7.96 | 77.81 | | ||
| 107 | |vcube 404 |31.8GiB | 0.10 | 0.38 | 1.88 | 16.98 | (a) | | ||
| 108 | |H48 h10 k2|28.1GiB | 0.10 | 0.47 | 2.00 | 13.54 | 114.35 | | ||
| 109 | |vcube 308 |21.2GiB | 0.06 | 0.42 | 1.95 | 17.73 | (a) | | ||
| 110 | |H48 h9 k2 |14.1GiB | 0.14 | 0.83 | 3.82 | 25.98 | 162.72 | | ||
| 111 | |vcube 208 | 7.3GiB | 0.17 | 1.49 | 5.88 | | (a) | | ||
| 112 | |H48 h8 k2 | 7.1GiB | 0.27 | 2.02 | 7.94 | | | | ||
| 113 | |H48 h7 k2 | 3.6GiB | 0.35 | 2.59 | 12.41 | | | | ||
| 114 | |vcube 112 | 2.4GiB | 0.29 | 3.15 | 12.06 | | (a) | | ||
| 115 | |H48 h6 k2 | 1.8GiB | 0.65 | 4.79 | 23.91 | | | | ||
| 116 | |||
| 117 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 118 | |||
| 119 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 120 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 121 | |H48 h11 k2|56.1GiB | 3.37 | 17.39 | 73.49 | 446.56 | 4365.92 | | ||
| 122 | |vcube 404 |31.8GiB | 3.80 | 12.08 | 59.78 | 539.96 | (a) | | ||
| 123 | |H48 h10 k2|28.1GiB | 2.81 | 13.21 | 56.20 | 380.47 | 3213.24 | | ||
| 124 | |vcube 308 |21.2GiB | 1.27 | 8.90 | 41.34 | 375.88 | (a) | | ||
| 125 | |H48 h9 k2 |14.1GiB | 1.97 | 11.70 | 53.86 | 366.32 | 2294.35 | | ||
| 126 | |vcube 208 | 7.3GiB | 1.24 | 10.88 | 42.92 | | (a) | | ||
| 127 | |H48 h8 k2 | 7.1GiB | 1.92 | 14.34 | 56.37 | | | | ||
| 128 | |H48 h7 k2 | 3.6GiB | 1.26 | 9.32 | 44.68 | | | | ||
| 129 | |vcube 112 | 2.4GiB | 0.70 | 7.56 | 28.94 | | (a) | | ||
| 130 | |H48 h6 k2 | 1.8GiB | 1.17 | 8.62 | 43.04 | | | | ||
| 131 | |||
| 132 | (a) vcube cannot parallelize on a single scramble, the results for the | ||
| 133 | Superflip are going to be the same as in the single thread case. | ||
| 134 | |||
| 135 | ### Multithread (16 threads) | ||
| 136 | |||
| 137 | Time per cube (in seconds, lower is better). | ||
| 138 | |||
| 139 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 140 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 141 | |H48 h11 k2|56.1GiB | 0.02 | 0.10 | 0.43 | 2.48 | 26.29 | | ||
| 142 | |vcube 404 |31.8GiB | 0.03 | 0.16 | 0.67 | 6.36 | (a) | | ||
| 143 | |H48 h10 k2|28.1GiB | 0.03 | 0.16 | 0.74 | 4.43 | | | ||
| 144 | |vcube 308 |21.2GiB | 0.04 | 0.22 | 0.89 | 9.53 | (a) | | ||
| 145 | |H48 h9 k2 |14.1GiB | 0.04 | 0.26 | 1.18 | 8.31 | | | ||
| 146 | |vcube 208 | 7.3GiB | 0.08 | 0.80 | 2.38 | | (a) | | ||
| 147 | |H48 h8 k2 | 7.1GiB | 0.08 | 0.60 | 2.48 | | | | ||
| 148 | |H48 h7 k2 | 3.6GiB | 0.11 | 0.81 | 3.91 | | | | ||
| 149 | |vcube 112 | 2.4GiB | 0.15 | 1.66 | 5.18 | | (a) | | ||
| 150 | |H48 h6 k2 | 1.8GiB | 0.21 | 1.53 | 7.82 | | | | ||
| 151 | |||
| 152 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 153 | |||
| 154 | | Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip| | ||
| 155 | |:---------|:-------|-------:|-------:|-------:|-------:|--------:| | ||
| 156 | |H48 h11 k2|56.1GiB | 1.12 | 5.61 | 24.12 | 139.13 | 1474.87 | | ||
| 157 | |vcube 404 |31.8GiB | 1.08 | 5.09 | 21.31 | 202.25 | (a) | | ||
| 158 | |H48 h10 k2|28.1GiB | 0.84 | 4.50 | 20.79 | 124.48 | | | ||
| 159 | |vcube 308 |21.2GiB | 0.85 | 4.66 | 18.87 | 202.04 | (a) | | ||
| 160 | |H48 h9 k2 |14.1GiB | 0.56 | 3.67 | 16.64 | 117.17 | | | ||
| 161 | |vcube 208 | 7.3GiB | 0.58 | 5.84 | 17.37 | | (a) | | ||
| 162 | |H48 h8 k2 | 7.1GiB | 0.57 | 4.26 | 17.60 | | | | ||
| 163 | |H48 h7 k2 | 3.6GiB | 0.40 | 2.92 | 14.07 | | | | ||
| 164 | |vcube 112 | 2.4GiB | 0.36 | 3.98 | 12.43 | | (a) | | ||
| 165 | |H48 h6 k2 | 1.8GiB | 0.38 | 2.75 | 14.08 | | | | ||
| 166 | |||
| 167 | (a) vcube cannot parallelize on a single scramble, the results for the | ||
| 168 | Superflip are going to be the same as in the single thread case. | ||
| 169 | |||
| 170 | ## All optimal solutions (TODO) | ||
| 171 | |||
| 172 | Average time for finding all optimal solutions. | ||
| 173 | |||
| 174 | ### Single thread | ||
| 175 | |||
| 176 | Time per cube (in seconds, lower is better). | ||
| 177 | |||
| 178 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 179 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 180 | |H48 h11 k2|56.1GiB | | | | | | ||
| 181 | |H48 h10 k2|28.1GiB | | | | | | ||
| 182 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 183 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 184 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 185 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 186 | |||
| 187 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 188 | |||
| 189 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 190 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 191 | |H48 h11 k2|56.1GiB | | | | | | ||
| 192 | |H48 h10 k2|28.1GiB | | | | | | ||
| 193 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 194 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 195 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 196 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 197 | |||
| 198 | ### Multithread (4 threads) | ||
| 199 | |||
| 200 | Time per cube (in seconds, lower is better). | ||
| 201 | |||
| 202 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 203 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 204 | |H48 h11 k2|56.1GiB | | | | | | ||
| 205 | |H48 h10 k2|28.1GiB | | | | | | ||
| 206 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 207 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 208 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 209 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 210 | |||
| 211 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 212 | |||
| 213 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 214 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 215 | |H48 h11 k2|56.1GiB | | | | | | ||
| 216 | |H48 h10 k2|28.1GiB | | | | | | ||
| 217 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 218 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 219 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 220 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 221 | |||
| 222 | ### Multithread (16 threads) | ||
| 223 | |||
| 224 | Time per cube (in seconds, lower is better). | ||
| 225 | |||
| 226 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 227 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 228 | |H48 h11 k2|56.1GiB | | | | | | ||
| 229 | |H48 h10 k2|28.1GiB | | | | | | ||
| 230 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 231 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 232 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 233 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 234 | |||
| 235 | Time per cube adjusted for tables size (in seconds \* GiB, lower is better). | ||
| 236 | |||
| 237 | | Solver | Size |17 moves|18 moves|19 moves|20 moves| | ||
| 238 | |:---------|:-------|-------:|-------:|-------:|-------:| | ||
| 239 | |H48 h11 k2|56.1GiB | | | | | | ||
| 240 | |H48 h10 k2|28.1GiB | | | | | | ||
| 241 | |H48 h9 k2 |14.1GiB | | | | | | ||
| 242 | |H48 h8 k2 | 7.1GiB | | | | | | ||
| 243 | |H48 h7 k2 | 3.6GiB | | | | | | ||
| 244 | |H48 h6 k2 | 1.8GiB | | | | | | ||
| 245 | |||
| 246 | ## Other notes | ||
| 247 | |||
| 248 | * Missing values in the table mean that the test is very slow and I did | ||
| 249 | not want to wait for it to finish. I may add these values in the future. | ||
| 250 | * All the measurements above exclude the time needed to load the pruning | ||
| 251 | tables into memory, which can be quite significant for large tables. To | ||
| 252 | repeat these measurements, one can use the tool `301_solve_file`. For | ||
| 253 | example: | ||
| 254 | |||
| 255 | ``` | ||
| 256 | ./build tool solve_file h48h7k2 ./benchmarks/scrambles/scrambles-16.txt | ||
| 257 | ``` | ||
| 258 | |||
| 259 | To find all solutions, add something like `99999 0` at the end of the | ||
| 260 | command. This will tell the tool to find up to `99999` solutions that | ||
| 261 | are at most `0` moves longer than optimal. | ||
| 262 | * The measurements also excluded the one-off computation of the pruning | ||
| 263 | tables which, for reasons related to the cube coordinates used, is | ||
| 264 | significantly slower for H48 compared to vcube. | ||
| 265 | * H48's and vcube's approach to multithreading are extremely different: | ||
| 266 | H48 parallelize the search for each cube individually, vcube solves | ||
| 267 | multiple cubes in parallel by dedicating a single thread to each of | ||
| 268 | them. Both apporaches have pros and cons: vcube's approch has less | ||
| 269 | overhead in coordination between the threads, but often some threads | ||
| 270 | may be left without work when there are no more cubes left to solve. | ||
| 271 | * Per-cube parallelization means that H48 will always be faster than | ||
| 272 | vcube when solving a single cube. | ||
| 273 | * vcube only supports x86 processors (Intel, AMD), while H48 runs on any | ||
| 274 | architecture, including e.g. ARM (Macbook M series, android phones) | ||
| 275 | and can be compiled to WebAssembly as well. | ||
