222 sats \ 0 replies \ @orthzar 3 Apr 2023 \ on: Daily discussion thread
A while ago, I was reading this paper and I realized that it might be possible to write a Monero mining program in Common Lisp that would be faster than the default mining code.
Monero's mining algorithm uses a bytecode VM to calculate a randomized set of equations that change periodically. It is designed to be efficient only on CPUs. [0] But if you could compile the set of calculations quickly enough, the resulting machine code would necesarily be faster than Monero's bytecode VM. As it turns out, several Common Lisp implementations (notably SBCL) specialize in quickly compiling code on-the-fly. So when the set of calculations changes, this mining program would compile the new set of calculations and continue mining.
I have no idea how much faster this mining program would be compared to Monero's current bytecode VM. But compiled code is almost always faster than bytecode VMs, s there should be at least some speed-up. For this program to be worth it, the resulting machine code would have to be fast enough to overcome the delay of the compilation step.
A natural question is: what about adding a JIT compiler to Monero's curent bytecode VM? Personally, I wouldn't do that unless you have a firm grasp of how to write JIT compilers. Plus, it would be far easier to just write the program in Common Lisp; SBCL already provides an AOT compiler.
I should say that I don't care about Monero per se. I just view this as an interesting puzzle.
[0] - I have an idea on how to mine Monero using a bunch of FPGAs, but that would require a Common Lisp compiler that targets FPGAs, which would be a huge project all on it's own.