mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Equi-X supports optionally allocating its solver memory using huge pages, to reduce the virtual memory subsystem overhead required to make the entire solver buffer live. Tor doesn't use this feature, since it seems to have no noticeable performance benefit at this time, but we still included code for it at compile time. To improve portability, this patch disables huge page support by default and enables it only in the cmake build system used for equix benchmarks. With this patch equix-bench still supports huge pages. Verified using strace that we're making the hugepage allocation. There's no fallback for huge pages, so Equi-X initialization will fail if they are requested and we don't support them for any runtime or compile-time reason. Addresses #40843 (NetBSD) but also prevents future porting issues related to huge pages.
Equi-X
Equi-X is a CPU-friendly client puzzle with fast verification and small solution size (16 bytes). It is based on Equihash(60,3) with two major changes:
- Blake2b hash function is replaced with HashX.
- XOR is replaced with modular addition.
An Equi-X solution for nonce X is a set of eight 16-bit indices i0, ..., i7 such that:
HX(i0) + HX(i1) + HX(i2) + HX(i3) + HX(i4) + HX(i5) + HX(i6) + HX(i7) = 0 (mod 260)
where HX is a HashX function generated for nonce X. Equi-X is therefore a variant of the subset sum problem. Each nonce value provides 2 solutions on average.
Equi-X also has additional requirements that prove that the solution was found using the Wagner's algorithm. See the Equihash paper for details.
Example solution
H(0x6c31) = 0xcfa5375c0a7f5d7 \
(+) = 0xa73d9777f110000 \
H(0x8803) = 0xd798601be690a29 / |
(+) = 0xefdaadb00000000 \
H(0x80c2) = 0xcabd8974bbee8d5 \ | |
(+) = 0x489d16380ef0000 / |
H(0xa1db) = 0x7ddf8cc3530172b / |
(+) = 0
H(0x6592) = 0x348a96fd685dcba \ |
(+) = 0x357120e8ffb8000 \ |
H(0x76b7) = 0x00e689eb975a346 / | |
(+) = 0x102552500000000 /
H(0x74a6) = 0xacccc4ad2d06bcd \ |
(+) = 0xdab431670048000 /
H(0xe259) = 0x2de76cb9d341433 /
Performance
| Algorithm | n | k | memory | solution size | verification 1 | CPU perf. 2 | GPU perf. 3 |
|---|---|---|---|---|---|---|---|
| Equi-X | 60 | 3 | 1.8 MiB | 16 bytes | ~50 μs | 2400 Sol/s | ? |
| Zcash | 200 | 9 | 144 MiB | 1344 bytes | >150 μs | 30 Sol/s | ~400 Sol/s 4 |
| BTG | 144 | 5 | 2.5 GiB | 100 bytes | ~10 μs | 1 Sol/s | ~45 Sol/s 5 |
- Using AMD Ryzen 1700 with 1 thread.
- Using AMD Ryzen 1700 with 16 threads.
- Using NVIDIA GTX 1660 Ti.
- Estimated from http://www.zcashbenchmarks.info/ (GTX 1070)
- Estimated from https://miniz.ch/features/
Build
git clone --recursive https://github.com/tevador/equix.git
cd equix
mkdir build
cd build
cmake ..
make
./equix-tests
./equix-bench --help
Design notes
See devlog.md
Donations
You can support the development of Equi-X by sending XMR to this address:
85GkKXSD8EQ22EMC2ZKF64S6L6Lcm8Gr23VbAKB1zg6FUW81sUEmrvvRPoM3GCpUZSC9azCLdeityW2N3CVsV4CAC3p1evV