Click-V: A RISC-V emulator built with ClickHouse SQL

https://news.ycombinator.com/rss Hits: 4
Summary

A RISC-V emulator built with ClickHouse SQL. This emulator makes ClickHouse truly Turing complete. We are one step closer to running ClickHouse in ClickHouse. This project/repository isn't dev-friendly yet, I'm just uploading it here as a backup in case my PC catches fire. How it works The system will react to the following insert command: INSERT INTO clickv . clock (_) VALUES () This command will trigger a large set of branched materialized views and Null tables that filter out the program's instructions to simulate reading/writing from registers and memory. External host machine access works via a single UDF with a custom binary format that gets read/written as an Array(UInt8) . The program is able to perform any logic. Printing to a console table and drawing are built-in. It can also open/close/read/write/seek files and sockets via the ClickOS UDF. For more details, see the architecture section. Performance I tried to use every optimization trick in the book to get this to run fast, unfortunately there is a MAJOR bottleneck to the performance of this emulator due to a bug in ClickHouse KVStorage logic. Because ClickHouse doesn't have an internal KV-type storage engine, I use Redis for registers/memory. But there is a bug with allow_experimental_analyzer=1 where instead of doing a single MGET , it will SCAN all keys and then MGET multiple times. I haven't submitted a bug report yet, but I did investigate it. More notes are commented in the file /sql/click-v.sql:11 . As it is now, the CPU runs at around 17hz , but during early development this was significantly higher. It can perform better, but when every almost every instruction depends on a register read, it kills performance quickly. It gets worse with more memory allocated in the emulator. How to run Steps: Set up a ClickHouse v24 image Set up a Redis-like server for registers/memory access (plain redis works fine, dragonfly was slower, there's also a built-in server in /system/mem ) ) Run all SQL statements i...

First seen: 2025-06-04 13:45

Last seen: 2025-06-04 16:46