HaloLog: A Go Logger with 23.9 ns/op Claim and Fairness Testing
说明与用途
HaloLog 是一个 Go 结构化日志记录器,声称 23.9 ns/op。作者添加了严格的输出合同和精度测试,使声明可重复且可验证。
问题
High‑performance telemetry claims must be reproducible, falsifiable, and include a full output contract.
结果
The updated benchmark harness now includes explicit work unit definition, output contract verification, and separate reporting for different Zap configurations, making the 23.9 ns/op claim reproducible and falsifiable.
工作流
- Define the operation: emit one newline‑terminated JSON record with timestamp, level, message, and dynamic fields to io.Discard.
- Set up logger constructors and dynamic fields outside the timed loop.
- Run the timed loop for each logger, measuring encode+dispatch time.
- Add a semantic contract test: verify one record, JSON validity, required fields, and field types.
- Add a byte‑level test with a fixed clock and golden records to detect timestamp representation differences.
- Report two Zap configurations separately to avoid silent substitution.
- Publish the updated benchmark suite with the same sample count on Linux and Windows.
- Document the findings and limitations (e.g., clock freshness, concurrency).
证据
The benchmark writes to io.Discard; it does not measure disk, network, batching, backpressure, or a production log collector.
The first new test exercises the same constructors as the benchmark. For each logger it captures a representative one‑field operation and verifies: exactly one newline‑terminated record was emitted; the record is valid JSON; timestamp and level are present; the expected message is present; the field value is a JSON number, not an accidentally quoted string.
- 记录日期: 2026-09-07T00:53:12.042Z