1. Cross-platform uSockets configuration - Use @VMODROOT for portable library paths - Support macOS (arm64/x86_64), Windows, and Linux - Auto-detect Homebrew paths for libuv on macOS 2. Route cache optimization (3x performance boost) - Replace LRU cache with FastRouteCache for dynamic routes - Zero-overhead cache lookup (no TTL check, no LRU reordering) - Dynamic route performance: 30k -> 97k RPS 3. New test files - Go-based integration tests for picoev and uSockets - FastCache optimization validation tests - Benchmark comparison tools
uSockets Backend for V-Hono
High-performance server backend using uSockets library.
Performance
Based on benchmark tests (200 connections, 100K requests):
| Backend | RPS | Avg Latency | P95 | P99 |
|---|---|---|---|---|
| uSockets | ~22,000 | 8.75ms | 16.66ms | 25.73ms |
| picoev | ~15,000 | 13.36ms | 18.89ms | 31.66ms |
uSockets provides ~50% higher throughput under high concurrency.
Usage
import hono
fn main() {
mut app := hono.Hono.new()
app.get('/', fn (mut c hono.Context) http.Response {
return c.text('Hello from uSockets!')
})
// Use uSockets backend
app.listen_usockets(3000)
}
Build Command
v -enable-globals -cc gcc -ldflags "-ldbghelp" your_app.v -o app.exe
Required flags:
-enable-globals- Required for uSockets global state-cc gcc- Use GCC compiler (MinGW-w64 on Windows)-ldflags "-ldbghelp"- Fix Windows linking (Windows only)
Prerequisites (Windows)
-
GCC (MinGW-w64)
scoop install mingw # or choco install mingw -
V Compiler (0.4.x or later)
scoop install vlang
Directory Structure
usockets/
├── include/ # Header files
│ ├── libusockets.h # uSockets API
│ ├── uv.h # libuv API
│ └── uv/ # libuv headers
├── lib/ # Pre-compiled libraries
│ ├── libusockets_full.a # uSockets + libuv (main)
│ ├── libuv.a # libuv static lib
│ └── ...
└── usockets.v # V bindings
Configuration
// Custom configuration
app.listen_usockets_with_config(hono.UsocketsConfig{
port: 8080
host: '0.0.0.0'
keepalive_timeout: 30
max_keepalive_req: 10000
})
Notes
- On Windows, uSockets and picoev have similar performance
- On Linux, uSockets may have greater advantages due to epoll optimization
- uSockets excels under high concurrency (200+ connections)