Chuks v0.0.5 — Production Hardening
Chuks v0.0.5 is about reliability. This release fixes fundamental concurrency issues, adds graceful shutdown, and publishes the first official performance benchmarks.
Graceful Shutdown
Section titled “Graceful Shutdown”HTTP servers now handle SIGINT and SIGTERM correctly:
import { createServer } from "std/http"
function main() { var app = createServer()
app.get("/", (req, res) => { res.json({ status: "ok" }) })
app.listen(8080) // Ctrl+C → graceful stop, no zombie processes}When you press Ctrl+C or send a termination signal:
- The server stops accepting new connections
- In-flight requests complete
- The HTTP engine shuts down cleanly
- No zombie processes, no leaked tasks
Required Port Argument
Section titled “Required Port Argument”app.listen() now requires an explicit port — no more implicit default of 3000. If the port is already in use, you get a helpful error message with an lsof hint to find the conflicting process.
Concurrency Fixes
Section titled “Concurrency Fixes”Two critical concurrency issues were identified and fixed:
Thread-Safe Task Map
Section titled “Thread-Safe Task Map”The global task map used for tracking async tasks was not thread-safe. Under high concurrency, this caused data races and unpredictable behavior.
Fix: Replaced the global map with a concurrent map, keyed by task ID. Each concurrent execution context now has isolated task tracking — no shared mutable state.
Context Propagation
Section titled “Context Propagation”Async functions and spawn tasks weren’t inheriting the parent context correctly. This meant cancellation signals didn’t propagate to child tasks, and HTTP request contexts weren’t available inside async handler code.
Fix: Both the VM and AOT paths now derive child contexts from the parent task, ensuring cancellation cascades correctly through the entire task tree.
Benchmark Results
Section titled “Benchmark Results”The first official CPU benchmarks are in:
| Benchmark | Chuks AOT | Node.js | Python |
|---|---|---|---|
| Fibonacci (35) | 52ms | 78ms | 2,410ms |
| N-Body (500K) | 68ms | 92ms | 8,120ms |
| Quicksort (1M) | 112ms | 145ms | 3,890ms |
| Binary Trees (15) | 89ms | 105ms | 1,250ms |
| Prime Sieve (1M) | 156ms | 168ms | 4,670ms |
Chuks AOT matches or beats Node.js across all benchmarks. For typed scalar workloads (fibonacci, n-body, quicksort), it’s within striking distance of native compiled languages. Array-heavy benchmarks (binary trees, prime sieve) have a performance gap due to dynamic dispatch — a known ceiling we’re working to reduce.
New Language Features
Section titled “New Language Features”Short-Circuit Evaluation
Section titled “Short-Circuit Evaluation”&& and || now properly short-circuit:
var result = false && expensiveCall() // expensiveCall() is never executedBitwise Operators
Section titled “Bitwise Operators”Full support for &, |, ^, ~, <<, >> — in both VM and AOT:
var flags = 0b1010 | 0b0101 // 0b1111var masked = flags & 0xFFvar shifted = 1 << 8 // 256String Escape Sequences
Section titled “String Escape Sequences”\n, \t, \r, \\, \", \0, \x41 (hex), \u0041 (unicode) — all standard escapes work.
Null-Safe Index Access
Section titled “Null-Safe Index Access”Indexing a null value now returns null instead of a fatal runtime error:
var arr = nullprintln(arr[0]) // null (no crash)Map Dot-Notation Access
Section titled “Map Dot-Notation Access”Maps support dot-notation for reading and writing keys, and missing keys return null:
var config = { "host": "localhost", "port": 6379 }println(config.host) // "localhost"println(config.password) // null (missing key)
config.host = "127.0.0.1"crypto.sha1 Builtin
Section titled “crypto.sha1 Builtin”New SHA-1 hash function in the crypto standard library:
import { crypto } from "std/crypto"var hash = crypto.sha1("hello world")println(hash) // "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"Try/Catch/Finally Fixes
Section titled “Try/Catch/Finally Fixes”try/catch now properly catches runtime errors. finally blocks with return work correctly. Error objects support code and data fields:
try { throw new Error("validation failed", "VALIDATION_ERROR", "email field")} catch (e) { println(e.message) // "validation failed" println(e.code) // "VALIDATION_ERROR" println(e.data) // "email field"} finally { println("cleanup ran")}Two-Tier Builtin System
Section titled “Two-Tier Builtin System”Built-in functions now have a deprecation mechanism. Old names continue to work with a warning, while new names follow consistent conventions.
Build Progress Spinner
Section titled “Build Progress Spinner”chuks build now shows a visual spinner with phase messages during AOT compilation, giving feedback on each compilation stage.
HTTP Benchmarks
Section titled “HTTP Benchmarks”The first official HTTP benchmarks are in:
wrk (4 threads, 100 connections, 10s)
Section titled “wrk (4 threads, 100 connections, 10s)”| Runtime | Req/s |
|---|---|
| Chuks AOT | 182,000 |
| Go (gnet) | 176,000 |
| Bun | 173,000 |
| Node.js | 115,000 |
| Java (Javalin) | 111,000 |
| Go (net/http) | 84,000 |
| Python (Flask) | 5,000 |
hey (100K requests, 200 concurrency)
Section titled “hey (100K requests, 200 concurrency)”| Runtime | Req/s |
|---|---|
| Chuks AOT | 143,000 |
| Go (gnet) | 142,000 |
| Bun | 106,000 |
| Java (Javalin) | 92,000 |
| Node.js | 89,000 |
| Python (Flask) | 4,000 |
Numbers
Section titled “Numbers”| Metric | Count |
|---|---|
| Golden tests (VM + AOT) | 135 |
| HTTP integration tests | 60 |
| Async bridge tests | 24 |
| Shutdown tests | 12 |
| Concurrency bugs fixed | 2 critical |