Skip to content

[Perf 1.13.0] HTTP/1.1 零分配查询参数读取 #125

Done

Description

@Antruly

背景

官方 baseline libuvcpp 1,802,593 vs hical 3,202,325;每请求 CPU 34.9 vs 19.6 µs-core。pipelined 差距更大(8.25 vs 3.61)。issue #26 已确认用户态是大头,doc/benchmark.md 记录 h1 热路约 17,952 指令/请求,top-40 仅占约 45%。

具体可动点:

  • /baseline11 的 handler 调 req.query_params(),返回 vector<pair<string,string>>;hical 用 queryParam("a") / queryParam("b")。
  • http_header 是两个 std::string,llhttp 回调落表时每头构造/拷贝。
  • 路由 split_path / match_pattern / params、uvcpp_web_app context / inflight / sync_meta() 仍是每请求固定成本。

要做的改动

先做一个可独立验收的零分配查询读取口,不重写整个解析器:

  • 为 uvcpp_web_request 增加 C++11 形状的查询参数视图/回调接口;无 %/+ 时直接引用 query_string_,不构造 vector、不为键值各建 std::string。
  • 有百分号/加号时回落到现有解码路径,语义保持一致(空段、裸键、重复键、空值)。
  • /baseline11 这类固定参数形状能走新路径;不改变现有 query_params() 的公开行为。
  • 头表视图/响应体复用作为后续独立项,不在本 PR 一次做完。

验收

  • 新增 functional 测试覆盖:?a=13&b=42、无查询串、空查询串、%20/+、裸键、空段、重复键;旧 query_params() 结果与新视图逐项一致。
  • 逐字节响应不变;现有 web/webapp 用例全绿。
  • 50 核 baseline/pipelined 与 1.12.1 做 3 次交错 A/B;报告 CPU/请求与 RPS。若收益落在噪声内,记录负结果,不合并。
  • 不新增 C ABI;公开头文件保持 C++11,非 ASCII 头文件按仓库规则加 UTF-8 BOM。

明确不做

  • 不在本项替换 llhttp 为 picohttpparser。
  • 不改路由表结构、不动 uvcpp_web_context 复用;这些留给后续有独立读数的 PR。

Activity

  1. added
    enhancement
    on Nov 28, 2026
  2. Antruly commented on Nov 29, 2026

    @Antruly
    OwnerAuthor

    Shipped in v1.13.0: https://github.com/Antruly/libuvcpp/releases/tag/v1.13.0. The release package passed the documentation snippet gate (122/122) and the six platform assets are published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions