feat: cross-platform uSockets support and route cache optimization

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
This commit is contained in:
meiseayoung
2026-01-02 21:44:07 +08:00
parent 9aefe5714d
commit 05bb2d6c95
13 changed files with 1574 additions and 294 deletions
+44
View File
@@ -0,0 +1,44 @@
// uSockets 简化测试服务器 - 与外层 main.v 配置一致
module main
import hono
import net.http
import x.json2
// JSON 响应结构体
struct JsonResponse {
message string
}
struct UserResponse {
user_id string
}
fn main() {
mut app := hono.Hono.new()
// 与外层 main.v 完全一致的路由配置(无中间件)
app.get('/', fn (mut c hono.Context) http.Response {
return c.text('Hello, World!')
})
app.get('/json', fn (mut c hono.Context) http.Response {
data := JsonResponse{message: 'Hello, JSON!'}
json_str := json2.encode(data)
return c.json(json_str)
})
app.get('/users/:id', fn (mut c hono.Context) http.Response {
user_id := c.params['id'] or { 'unknown' }
data := UserResponse{user_id: user_id}
json_str := json2.encode(data)
return c.json(json_str)
})
app.get('/health', fn (mut c hono.Context) http.Response {
return c.text('OK')
})
println('[usockets-simple] Starting on port 9999 (uSockets)...')
app.listen_usockets(9999)
}