241 karma · joined Apr 6, 2015 (11y ago) · 94 submissions
comment 4mo ago · link · parent
I've spent 8 years working on RISC-V VMs for blockchains, recently also contributing to ZK VMs. Modern blockchain VMs are drastically more powerful, and I'm curious how far we can push them. I started porting real game logic to blockchain VMs, running game loop, physics simulation, collision detection, etc., on blockchain VMs. So far I have:
* Teeworlds to CKB-VM: https://xuejie.space/2026_06_16_teeworlds_on_ckb/
* One Hour One Life to CKB-VM: https://xuejie.space/2026_06_29_porting_one_hour_one_life_ga...
* A small ray tracer to Jolt ZK VM: https://xuejie.space/2026_07_10_cpp_ray_tracer_on_jolt_zk_vm...
Source is available for 2 of the 3, I need to clean up the OHOL one.
Some context: CKB-VM [1] is a RISC-V virtual machine I designed for Nervos starting in 2018. Jolt ZK VM [2] is a zero-knowledge virtual machine developed by a16z. Both execute RISC-V code, but due to different design, Jolt ZK VM is a much faster CPU than CKB-VM.
Technically this is a fun challenge. Many techniques I used resemble game development tricks from the 90s on game consoles: fixed point math, banked memory in ROMs, aggressively inlining tricks, etc. I want to push to see where the ceiling is. Right now I'm trying to get a Godot [3] + JoltPhysics [4] game loop running on Jolt ZK VM.
Happy to answer questions about the VM internals, the porting process, or anything in general.
[1] https://github.com/nervosnetwork/ckb-vm
comment 2y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
That being said, I've been recently employing comby (https://comby.dev/) in my workflow, which solves similar problem, but understands certain languages to simplify the usage.
comment 5y ago · link · parent
comment 6y ago · link · parent
* A fanless Chromebook with decent screen for travel use
* An Intel NUC that is hooked to a big monitor, which is also the device I'm typing this on
* A beefy Ryzen desktop that sits in the corner of my balcony, which I usually connect via ssh and perform all the heavy tasks
To me I'm getting all the benefits of each computer, and the combined cost is still less than a so-called macbook pro :)
comment 6y ago · link · parent
Aren't macros, especially proc macros these days in Rust having the same effect? Personally I feel like this is a tradeoff every language has to play with: you either limit to a special way of writing, or adding some sort of ad-hoc system that enables rewriting syntax and even to a degree, semantics.
comment 6y ago · link · parent
> Idris 1 is implemented in Haskell, but that has little (if anything) to do with the difference.
But latter they also go on to say:
> Idris 2 benefits from a robust, well-engineered and optimised run time system, by compiling to Chez Scheme.
I must say I'm slightly confused here. Yes a rewrite might also enable to avoid all the legacy part that might slow down the code, but what is also possible, is that a new language and a new runtime could enable new optimizations that are not possible before. The author did mention Chez's profiling tools help a lot in the rewrite. So I was curious: is it really true, that we cannot attribute some part of the speedup to language differences?
Also I was interested in the rationale behind using Scheme to replace Haskell, but I failed to find some reasoning behind this, anyone can shed some light on this?
comment 6y ago · link · parent
Disclaimer: I'm never a Rust zealot, I do understand Rust has its tradeoffs, and it's not the panacea for every problem. In fact I do have side projects which are perfectly suited and written in Go. I'm just saying Rust's design turns out to be suitable for such a deterministic testing structure, and Rust's target for system programming, can also benefit A LOT from this style of testing.
And also a shameless plug: I do have some initial work exploring this area: https://github.com/xxuejie/diviner. It's still quite rough and a lot of work is needed but I do believe this is something that is worth exploring.
comment 6y ago · link · parent
comment 6y ago · link · parent
I understand we might get there one day but I'm afraid this is taking far too long.
comment 6y ago · link · parent
Some shits I see these days are that when code speed is measured, people compare that with JS but not native code, when portability is talked about, the comparison is then made against native code, not JS.
comment 6y ago · link · parent
And actually the argument is: all of v8, Firefox/Cranelift and LLVM used in wasmer requires non-trivial work to make WASM fast, which shouldn't be needed given a different model.
[1] https://github.com/wasmerio/wasmer/tree/master/lib/llvm-back... [2] https://github.com/WAVM/WAVM
comment 6y ago · link · parent
And of course JIT can make WASM fast but if you look around, building a performant WASM JIT still remains terribly hard, some implementation even needs LLVM to perform optimizations. I'd say if this is the case, we must've chosen the wrong model.
comment 6y ago · link · parent
The problem with WASM here, is that it really is a bloated model like JVM in its early days, huge amount of work is needed to make it closer to native speed, which is contradictory to the original slogan. What's more, people are still planning to add tons of new features to it: https://webassembly.org/docs/future-features/. Before you tell me those are opt-in features, the question I want to raise is: for an abstraction of general platform, you would definitely want to have a widely accepted standard so people know what features will be expected, one example is that people know SSE will be available for 64-bit x86 code.
With all those opt-in features, I doubt if we can have a proper layer that adapts well to different implementations with different supported features. We might end up with the situation like Rust, where you can claim a secondary compiler could exist, but in practice people are all using the same compiler/implementation.
comment 7y ago · link · parent
Also, when you are promoting something, it might not a good idea to compare against Python when it comes to speed, but when talking maintainability, only C is talking as a target here.
comment 7y ago · link · parent
And taking from the other side of the view, even when you consider high performance data flow programming, there're great people pointing out going functional might not be a very good idea: https://www.freelists.org/post/luajit/Ramblings-on-languages...
comment 7y ago · link · parent
I think this is exactly into parent thread's point: yes the performance can be great but you need to tail the code for the hardware, which is niche and the beautiful abstraction might never hold anymore