# Benchmarks for the H48 optimal solver and comparison with vcube This page contains some benchmarks for some of the possible configurations of the H48 optimal solver. For comparison we also include similar measurements for two other optimal solvers: * Andrew Skalski's [vcube](https://github.com/Voltara/vcube) (commit 9f5bc2c), which is a truly impressive implementation of Tomas Rokicki's [nxopt](https://github.com/rokicki/cube20src/blob/master/nxopt.md) that has been taken as a reference throughout the development of H48. This solver also uses an A* search, but the search is supported by different pruning tables. * Arhan Chaudhary's [egg-solver](https://github.com/ArhanChaudhary/egg-solver) (commit ed726e2), which is an AI-generated implementation of the H48 method with highly-optimized microthreading. Similar benchmarks can be found: * In Chen Shuang's [dedicated github page](https://github.com/cs0x7f/cube_solver_test/wiki), which includes many more solvers. At the time of writing, the version of H48 used for these benchmarks is a rather old one. Note that cube48opt is a re-implementation of the H48 solver by Chen Shuang. * In Enrico Tenuti's [thesis](https://github.com/enricotenuti/h48thesis), also using an old implementation of H48, but including more data and nice plots. * In [the documentation page](https://egg-solver.arhan.sh/docs/index.html) for egg-solver. ## Setting *All movecounts are in Half Turn Metric* For the benchmarks we used some sets of random positions that can be found in `benchmarks/scrambles`. We divide them by optimal solution length, because the time to solve a scramble grows exponentially on the number of moves, so mixing up positions with long and short solutions is going to make the shorter solution almost irrelevant. Even within the same solution length the time to solve a random position can vary significantly, so we have used sets of 25 scrambles and taken the average of those, except for the [Superflip](https://en.wikipedia.org/wiki/Superflip), which is a single scramble. For short solutions, the very low numbers we get with the largest solver may be particularly inaccurate, because writing the solution (together with some log messages) to standard output may take a significant portion of the time, depending on the terminal emulator used and other factors. All benchmark tests were done on the following configuration: * CPU: AMD Ryzen 7 7700 (8 cores, 16 virtual threads) * Memory: 2x Corsair Vengeance 32GB 5600MHz * Motherboard: Gigabyte B650M K * Operating system: Debian 13 (Linux kernel 6.12) * Compilers: GCC 14.2.0 for H48, Chhang 19.1.7 for vcube and cargo 1.99.1 for egg-solver ## Benchmark results ### Single solution, single thread The first test we performed was finding a single optimal solution, and we compared the results with vcube. This test was run in a single-thread configuration, because the three solvers use very different strategies for multithreading: vcube can only parallelize by solving one cube per thread, while H48 and egg-solver can take advantage of multiple threads even when solving a single cube. Therefore we prefer to compare their single-threaded performance only. Since the size of the pruning table used by the solver is of utmost importance, we include two statistics: time per cube and time per cube *adjusted by table size*. The adjustment we took simply consists in multiplying the time per cube by the size of the table. Empirically this leads to more even results across the board, although the speed of the solvers of the same family does not scale exactly linearly with the size of the pruning table.
Results: Single solution, single thread Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 0.11| 0.75| 3.43| 27.28| 19.30| |egg h11 |58.0 GiB| 0.01| 0.06| 0.24| 2.13| 0.14| |H48 h11 |56.5 GiB| 0.08| 0.41| 1.80| 11.96| 15.28| |vcube 404 |31.8 GiB| 0.23| 1.24| 6.10| 59.33| 268.26| |egg h10 |29.0 GiB| 0.02| 0.10| 0.45| 3.96| 0.24| |H48 h10 |28.3 GiB| 0.12| 0.69| 3.31| 24.85| 38.18| |vcube 308 |21.2 GiB| 0.17| 1.02| 6.20| 58.70| 604.35| |egg h9 |14.5 GiB| 0.03| 0.18| 0.87| | | |H48 h9 |14.1 GiB| 0.22| 1.43| 6.53| | | |vcube 208 | 7.3 GiB| 0.56| 4.36| 20.58| | | |egg h8 | 7.2 GiB| 0.06| 0.36| 1.64| | | |H48 h8 | 7.1 GiB| 0.46| 3.41| 14.23| | | |egg h7 | 3.6 GiB| 0.10| 0.74| 4.00| | | |H48 h7 | 3.5 GiB| 0.63| 4.87| 23.39| | | |vcube 112 | 2.4 GiB| 0.96| 9.29| 40.52| | | |egg h6 | 1.8 GiB| 0.18| 1.40| 7.69| | | |H48 h6 | 1.8 GiB| 1.26| 9.47| 46.81| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 6.43| 43.80| 199.38| 1587.43| 1122.73| |egg h11 |58.0 GiB| 0.55| 3.30| 14.11| 123.79| 7.94| |H48 h11 |56.5 GiB| 4.31| 23.34| 101.61| 675.65| 863.48| |vcube 404 |31.8 GiB| 7.40| 39.47| 194.01| 1887.94| 8535.87| |egg h10 |29.0 GiB| 0.49| 2.84| 12.91| 114.83| 6.92| |H48 h10 |28.3 GiB| 3.50| 19.36| 93.65| 702.04| 1078.64| |vcube 308 |21.2 GiB| 3.51| 21.71| 131.50| 1245.26| 12819.94| |egg h9 |14.5 GiB| 0.46| 2.64| 12.61| | | |H48 h9 |14.1 GiB| 3.10| 20.21| 92.31| | | |vcube 208 | 7.3 GiB| 4.08| 31.74| 149.68| | | |egg h8 | 7.2 GiB| 0.44| 2.62| 11.88| | | |H48 h8 | 7.1 GiB| 3.22| 24.11| 100.55| | | |egg h7 | 3.6 GiB| 0.36| 2.69| 14.48| | | |H48 h7 | 3.5 GiB| 2.23| 17.22| 82.63| | | |vcube 112 | 2.4 GiB| 2.33| 22.53| 98.23| | | |egg h6 | 1.8 GiB| 0.33| 2.54| 13.94| | | |H48 h6 | 1.8 GiB| 2.23| 16.75| 82.75| | |
As we can see, egg-solver is the clear winner, consistently beating H48 by factors of 5x-9x for all sets of scrambles, comparing tables of similar size. Moreover, egg-solver is more than 100 times faster when solving the superflip configuration, likely due to better expoitation of symmetries, including inverse positions. Adjusting for table size, H48 is generally faster than vcube. The gap between the two solvers is larger for scrambles with longer optimal solutions. ### Single solution, multiple threads The same benchmark as before is repeated using 4 and 16 threads (recall that the CPU used for these tests has 8 physical cores and 16 virtual threads). For the reasons mentioned above, in this section we will only compare H48 and egg-solver; for the latter with enable per-cube parallelization using the `-c 1` option.
Results: Single solution, 4 threads Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.00| 0.02| 0.06| 0.55| 0.03| |H48 h11 |56.5 GiB| 0.03| 0.12| 0.48| 3.15| 4.15| |egg h10 |29.0 GiB| 0.00| 0.02| 0.12| 1.02| 0.09| |H48 h10 |28.3 GiB| 0.04| 0.17| 0.89| 6.14| 9.81| |egg h9 |14.5 GiB| 0.01| 0.05| 0.23| | | |H48 h9 |14.1 GiB| 0.07| 0.39| 1.71| 12.55| 18.81| |egg h8 | 7.2 GiB| 0.02| 0.09| 0.43| | | |H48 h8 | 7.1 GiB| 0.13| 0.90| 3.72| | | |egg h7 | 3.6 GiB| 0.03| 0.19| 1.09| | | |H48 h7 | 3.5 GiB| 0.17| 1.28| 6.13| | | |egg h6 | 1.8 GiB| 0.05| 0.36| 2.01| | | |H48 h6 | 1.8 GiB| 0.34| 2.48| 12.25| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 3.47| 3.78| 3.90| 3.88| 5.40| |H48 h11 |56.5 GiB| 2.44| 3.40| 3.72| 3.79| 3.69| |egg h10 |29.0 GiB| 3.68| 4.04| 3.78| 3.90| 2.72| |H48 h10 |28.3 GiB| 2.80| 4.00| 3.72| 4.05| 3.89| |egg h9 |14.5 GiB| 3.78| 3.95| 3.75| | | |H48 h9 |14.1 GiB| 3.17| 3.70| 3.82| | | |egg h8 | 7.2 GiB| 3.66| 3.97| 3.78| | | |H48 h8 | 7.1 GiB| 3.52| 3.80| 3.83| | | |egg h7 | 3.6 GiB| 3.78| 3.86| 3.68| | | |H48 h7 | 3.5 GiB| 3.61| 3.82| 3.82| | | |egg h6 | 1.8 GiB| 3.83| 3.92| 3.82| | | |H48 h6 | 1.8 GiB| 3.74| 3.82| 3.82| | |
Results: Single solution, 16 threads Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.00| 0.01| 0.03| 0.26| 0.02| |H48 h11 |56.5 GiB| 0.02| 0.05| 0.19| 1.13| 1.87| |egg h10 |29.0 GiB| 0.00| 0.01| 0.06| 0.48| 0.05| |H48 h10 |28.3 GiB| 0.02| 0.07| 0.33| 2.21| 4.17| |egg h9 |14.5 GiB| 0.00| 0.02| 0.11| | | |H48 h9 |14.1 GiB| 0.03| 0.14| 0.63| 4.39| 8.01| |egg h8 | 7.2 GiB| 0.01| 0.04| 0.20| | | |H48 h8 | 7.1 GiB| 0.06| 0.29| 1.36| | | |egg h7 | 3.6 GiB| 0.01| 0.09| 0.52| | | |H48 h7 | 3.5 GiB| 0.07| 0.40| 2.18| | | |egg h6 | 1.8 GiB| 0.02| 0.16| 0.94| | | |H48 h6 | 1.8 GiB| 0.13| 0.76| 4.33| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 6.70| 7.77| 8.08| 8.10| 9.07| |H48 h11 |56.5 GiB| 3.72| 7.58| 9.52| 10.55| 8.19| |egg h10 |29.0 GiB| 7.33| 8.53| 8.04| 8.27| 5.14| |H48 h10 |28.3 GiB| 5.01| 9.25| 10.09| 11.22| 9.15| |egg h9 |14.5 GiB| 7.65| 8.33| 7.96| | | |H48 h9 |14.1 GiB| 6.48| 10.56| 10.37| | | |egg h8 | 7.2 GiB| 7.78| 8.48| 8.04| | | |H48 h8 | 7.1 GiB| 8.02| 11.69| 10.49| | | |egg h7 | 3.6 GiB| 7.90| 8.22| 7.70| | | |H48 h7 | 3.5 GiB| 8.78| 12.24| 10.73| | | |egg h6 | 1.8 GiB| 8.16| 8.55| 8.21| | | |H48 h6 | 1.8 GiB| 9.75| 12.48| 10.80| | |
We can see that both egg-solver and H48 scale pretty well with 4 threads, getting close to the 4x theoretical maximum speedup in slower cases (small table or long solutions). egg-solver managed to beat the 4x speedup for the superflip, likely due to single-scramble variance, i.e. the thread that found the solution stopped earlier. The 16 threads benchmark shows that, although the virtual threads help push H48 beyond the 8x theoretical speedup that would be provided by the 8 cores, it is nowhere near a 16x speedup. Moreover, egg-solver does not seem to take advantage of the CPU's hyperthreading, likely because its own custom micro-threading is based on the same principle and it saturates any possible speedup that hyperthreading could provide. ### All solutions Finally, we ran a test on finding *all* optimal solutions which, as far as I know, is a use case only supported by H48 and egg-solver. For convenience, this test is only run on 16 threads.
Results: All solutions, 16 threads Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.00| 0.04| 0.41| 3.91| 0.30| |H48 h11 |56.5 GiB| 0.03| 0.22| 1.89| 16.01| 17.02| |egg h10 |29.0 GiB| 0.01| 0.07| 0.74| 7.08| 0.60| |H48 h10 |28.3 GiB| 0.05| 0.38| 3.60| 30.97| 36.41| |egg h9 |14.5 GiB| 0.01| 0.13| 1.43| | | |H48 h9 |14.1 GiB| 0.07| 0.71| 7.14| | | |egg h8 | 7.2 GiB| 0.02| 0.25| 2.78| | | |H48 h8 | 7.1 GiB| 0.14| 1.52| 15.20| | | |egg h7 | 3.6 GiB| 0.04| 0.49| 5.83| | | |H48 h7 | 3.5 GiB| 0.21| 2.33| 26.16| | | |egg h6 | 1.8 GiB| 0.07| 0.91| 10.96| | | |H48 h6 | 1.8 GiB| 0.39| 4.60| 52.07| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.20| 2.21| 23.79| 226.71| 17.30| |H48 h11 |56.5 GiB| 1.81| 12.50| 107.05| 904.39| 961.58| |egg h10 |29.0 GiB| 0.17| 1.94| 21.32| 205.40| 17.50| |H48 h10 |28.3 GiB| 1.29| 10.85| 101.62| 874.93| 1028.73| |egg h9 |14.5 GiB| 0.15| 1.83| 20.75| | | |H48 h9 |14.1 GiB| 1.04| 10.03| 100.84| | | |egg h8 | 7.2 GiB| 0.15| 1.78| 20.16| | | |H48 h8 | 7.1 GiB| 1.01| 10.77| 107.38| | | |egg h7 | 3.6 GiB| 0.14| 1.78| 21.14| | | |H48 h7 | 3.5 GiB| 0.73| 8.25| 92.42| | | |egg h6 | 1.8 GiB| 0.13| 1.66| 19.86| | | |H48 h6 | 1.8 GiB| 0.69| 8.13| 92.04| | |
## Other notes * To repeat the benchmarks for H48, use `./benchmarks/run-h48-benchmarks.sh`. Similar scripts for vcube and egg-solver can be found in the `benchmarks` folder. * All the measurements above exclude the time needed to load the pruning tables into memory, which can be quite significant for large tables. * The measurements also excluded the one-off computation of the pruning tables which, for reasons related to the cube coordinates used, is significantly slower for H48 compared to vcube. * H48's and vcube's approach to multithreading are extremely different: H48 parallelize the search for each cube individually, vcube solves multiple cubes in parallel by dedicating a single thread to each of them. Both apporaches have pros and cons: vcube's approch has less overhead in coordination between the threads, but often some threads may be left without work when there are no more cubes left to solve. egg-solver supports both modes via the `-c` option. * Per-cube parallelization means that H48 will always be faster than vcube when solving a single cube. * vcube only supports x86 processors (Intel, AMD), while H48 runs on any architecture, including e.g. ARM (Macbook M series, android phones) and can be compiled to WebAssembly as well. * For H48, both GCC and Clang have been tried, with the same options; the resulting executable was about 10% faster with GCC compared to Clang. vcube only supports compiling with Clang.