How wg/wrk works
wrk is a multithreaded HTTP load generator. The user supplies a target URL, connection/thread/duration options, and optionally a Lua script; wrk runs concurrent requests, processes responses, and reports throughput, errors, and latency. The graph captures the documented Lua request/response/reporting capabilities and the sampled orchestration, event, socket, and statistics layers. Some runtime callback wiring is not visible in the excerpts, so those links are omitted or marked unverified.
Main entry points: wrk.c CLI and runner · ae.c Event loop · script.c Lua script runtime · net.c Socket operations
Components 16
Benchmark runtime
- CLI and runner
src/wrk.c - Worker threads
src/wrk.c - Event loop
src/ae.c - Epoll backend
src/ae_epoll.c - Kqueue backend
src/ae_kqueue.c - Event ports backend
src/ae_evport.c - Select backend
src/ae_select.c - Memory allocation
src/zmalloc.c
Network and HTTP
- Socket operations
src/net.c - TLS transport
src/ssl.c - HTTP parser
src/http_parser.c
Lua scripting
- Lua script runtime
src/script.c
Metrics and output
- Statistics collection
src/stats.c - Units formatting
src/units.c
Other components
- Benchmark user
- HTTP target
Connections 21
- Benchmark user → CLI and runner: configures
README.md - CLI and runner → Worker threads: starts
src/wrk.c - CLI and runner → Lua script runtime: initializes scripts
src/wrk.c - CLI and runner → Statistics collection: allocates statistics
src/wrk.c - Worker threads → Socket operations: connects and writes
src/wrk.c - Worker threads → Event loop: registers events
- Event loop → Epoll backend: selects backend
src/ae.c - Event loop → Kqueue backend: selects backend
src/ae.c - Event loop → Event ports backend: selects backend
src/ae.c - Event loop → Select backend: selects backend
src/ae.c - Socket operations → HTTP target: sends requests
- Socket operations → TLS transport: uses secure transport
- Worker threads → HTTP parser: parses responses
- Worker threads → Lua script runtime: generates requests
src/wrk.c - Lua script runtime → HTTP parser: validates requests
src/script.c - Lua script runtime → Benchmark user: runs optional hooks
README.md - CLI and runner → Statistics collection: aggregates results
src/wrk.c - CLI and runner → Units formatting: formats output
- CLI and runner → Benchmark user: prints report
src/wrk.c - Event loop → Memory allocation: allocates loop state
src/ae.c - Lua script runtime → Memory allocation: allocates buffers
src/script.c