Skip to content

feat(xpp/bench): echo server benchmark harness + Go comparison - #89

Merged
mivinci merged 1 commit into
mainfrom
codebuddy/bench-echo-server
Aug 26, 2026
Merged

mivinci merged 1 commit into
mainfrom
codebuddy/bench-echo-server

Conversation

@mivinci

@mivinci mivinci commented Aug 26, 2026

Copy link
Copy Markdown
Owner

背景

补一个 xpp::http::Server 的端到端压测入口(wrk 驱动),并放一个 Go net/http
同路由对照版,量化单核效率与封装开销。

改动

  • libxpp/bench/http/echo_server.cpp:xpp echo server(GET /ping、
    GET /echo?size=N、POST /echo),X_BUILD_BENCHMARKS 门控
    (libxpp/CMakeLists.txt 加 add_subdirectory(bench))。
  • libxpp/bench/http/echo_server.go:Go 对照版(route-for-route)。
  • libxpp/bench/http/README.md:基准存档——完整数据表 + 结论。

压测结论(macOS M3,wrk 4.2.0)

并发 xpp(1 核) Go 单核 Go 多核(12 核)
c100 77.9k 71.2k 72.9k(CPU 240%)
c500 70.8k 68.4k 69.4k
c1000 70.3k 65.9k 68.8k
c2000 68.5k 64.5k 63.2k

附带的 todo(压测暴露的优化方向)

  • todos/http-server-per-request-allocations.md:xpp server 每请求 ~7 次堆分配
  • todos/router-o-n-match-to-trie.md:Router 查找 O(n) 线性扫描 → segment 前缀树

Add libxpp/bench with a wrk-driven echo server harness:

- http/echo_server.cpp — xpp::http::Server echo server (/ping, /echo?size=N,
  POST /echo) for wrk, built under X_BUILD_BENCHMARKS.
- http/echo_server.go — route-for-route Go net/http counterpart for
  direct comparison.
- http/README.md — benchmark baseline: xpp single-core beats Go
  multi-core (77.9k vs 72.9k QPS at ~1/2.4 the CPU), Go gains nothing
  from extra cores in keep-alive small-request workloads, xpp is the
  only impl with zero socket errors at 2000 connections.

Record the two follow-up optimizations surfaced by the harness as
todos: per-request allocation reduction in the HTTP server, and the
O(n) linear router match → segment trie.
@mivinci
mivinci merged commit 9c9fa76 into main Aug 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant