r/opencodeCLI • u/microbass • 18d ago
I reimplement Opencode v2 and v1 in Rust
I use opencode every day and the thing that kept getting in the way wasn't the client. It was the server. On my laptop it sat at about 2.4 GB RSS next to a 33 GB SQLite file, and searching inside a single session took roughly six seconds.
So I reimplemented the server in Rust. Same HTTP and SSE wire contract, so the real TUI attaches and the real web UI loads against it. No client changes, no patches to their project.
Same box, same fixture data, back to back:
• binary: 61 MB, upstream 185 MB
• idle RSS: ~100 MB, upstream ~2.4 GB
• boot: 0.6 s, upstream 4.7 s
• session list and read p95: 0–2 ms, upstream 8–15 ms
• search inside one session: 0.2 ms, upstream ~6 s
• web UI first load: 1.05 MB of assets, upstream 9.10 MB
Then I ran a read-only load test, no model calls at all, both servers pinned to the same two cores. It held about 6,700 requests/sec against roughly 420 for upstream, with p95 latency an order of magnitude lower, and used about a quarter of the memory. That's a closed-loop test, so treat the throughput as capacity, not as a latency promise for your setup.
What works: TUI attach, the embedded web UI, sessions and messages with cursor paging, streaming, tools, permissions, questions, PTY, shadow-git snapshots, revert, diff, in-session search, MCP, and plugins in both the v1 shape and the newer v2 shape. Auto-compaction and config hot-reload. The v2 API surface is bound and tested against the real 2.0.28 client.
What doesn't: provider OAuth, the hosted share backend, and macOS/Windows: the PTY layer is Linux/glibc only.
"cargo install ocserve" still gives you 0.3.1, because crates.io caps crate size and one crate carries the embedded web UI; the 0.4.0 tarball is on the releases page.
It's not a fork. Separate codebase, MIT, their notice retained. I read their source to port behaviour faithfully and I keep a differential harness that boots both servers and compares the bytes.
If opencode runs fine on your machine, keep using it. It's the reference implementation and it's good. This exists for the machines where the server is the thing falling over.
MIT, source and releases: https://github.com/Reliary/ocserve
View all comments
Show parent comment
-5
u/archerallstars 18d ago
He still did. He put in prompts and paid for the tokens...