Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
这个 PR 引入了两个新的 bpf 程序来加速 WAN TCP。
总体来说,原本的 WAN TCP 劫持路径的数据平面如下图:
这个 PR 把上述路径优化为:
优化成果见 Benchmark。
实现细节
需要联合使用两个 bpf:
routing_tuples_map
来判断一个 socket 是否是 WAN 代理的 socket,如果是的话就用bpf_sock_hash_update
把 socket 加入 sockmap。bpf_msg_redirect_hash
实现 TCP segment 的直接投递。注意 TCP 握手和挥手依然走内核栈,这部分是不加速的,只有建立连接后才可以
Benchmark
使用 sockperf 测试 latency
dae-0.4.0 结果是
这个 PR 的结果是
TCP latency 提升 6%
但 latency 只是性能的一部分,如果是 iperf 跑 tcp rr (round-trip) 在我虚拟机上会直接把内存跑炸
在实际场景中,比如 redis-server 和 redis-benchmark 中的表现往往能达到 10%+ 的 p99 提升。
Checklist
Full Changelogs
Issue Reference
Closes #[issue number]
Test Result