Skip to content

feat(benchmark): add TCP receive dispatch benchmark (std::span vs std::vector)#325

Merged
kcenon merged 2 commits into
mainfrom
feat/tcp-receive-dispatch-benchmark
Dec 19, 2025
Merged

feat(benchmark): add TCP receive dispatch benchmark (std::span vs std::vector)#325
kcenon merged 2 commits into
mainfrom
feat/tcp-receive-dispatch-benchmark

Conversation

@kcenon

@kcenon kcenon commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Summary

  • Add focused benchmarks to quantify the overhead difference between span-based and vector-based receive dispatch paths
  • Update benchmark documentation (README.md and README_KO.md)

Benchmarks Added

Benchmark Description
BM_TcpReceive_Dispatch_Span Zero-allocation span-based dispatch
BM_TcpReceive_Dispatch_VectorFallback Per-iteration vector allocation
BM_TcpReceive_Dispatch_Span_MultiCallback Multi-handler span sharing
BM_TcpReceive_Dispatch_Vector_MultiCallback Multi-handler with copies
BM_TcpReceive_Subspan_Operations Efficient protocol header/payload parsing
BM_TcpReceive_VectorSlice_Operations Legacy vector slicing overhead

Local Benchmark Results

Results show span path is 10-46x faster than vector fallback:

Payload Span Vector Speedup
64B 0.4 ns 18.4 ns ~46x
1KB 3.2 ns 50.8 ns ~16x
64KB 207 ns 2139 ns ~10x

Test plan

  • Benchmarks compile under -DNETWORK_BUILD_BENCHMARKS=ON
  • Benchmark binary includes the new TCP receive dispatch benchmarks
  • Results clearly show span path outperforming vector fallback
cmake -B build -S . -DNETWORK_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --target network_benchmarks
./build/benchmarks/network_benchmarks --benchmark_filter=TcpReceive

Closes #320

…::vector)

Add focused benchmarks to quantify overhead difference between span-based
and vector-based receive dispatch paths.

Benchmarks included:
- BM_TcpReceive_Dispatch_Span: zero-allocation span-based dispatch
- BM_TcpReceive_Dispatch_VectorFallback: per-iteration vector allocation
- BM_TcpReceive_Dispatch_Span_MultiCallback: multi-handler span sharing
- BM_TcpReceive_Dispatch_Vector_MultiCallback: multi-handler with copies
- BM_TcpReceive_Subspan_Operations: efficient protocol header/payload parsing
- BM_TcpReceive_VectorSlice_Operations: legacy vector slicing overhead

Results show span path is ~10-46x faster than vector fallback depending
on payload size.

Closes #320
Update README.md and README_KO.md to include:
- TCP receive dispatch benchmark in overview
- Filter command for TcpReceive benchmarks
- Detailed benchmark category section with target metrics
@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison

Base Branch Results

No base results

PR Branch Results

No PR results

@kcenon kcenon merged commit 216c382 into main Dec 19, 2025
50 checks passed
@kcenon kcenon deleted the feat/tcp-receive-dispatch-benchmark branch December 19, 2025 02:57
kcenon added a commit that referenced this pull request Apr 13, 2026
…::vector) (#325)

* feat(benchmark): add TCP receive dispatch benchmark (std::span vs std::vector)

Add focused benchmarks to quantify overhead difference between span-based
and vector-based receive dispatch paths.

Benchmarks included:
- BM_TcpReceive_Dispatch_Span: zero-allocation span-based dispatch
- BM_TcpReceive_Dispatch_VectorFallback: per-iteration vector allocation
- BM_TcpReceive_Dispatch_Span_MultiCallback: multi-handler span sharing
- BM_TcpReceive_Dispatch_Vector_MultiCallback: multi-handler with copies
- BM_TcpReceive_Subspan_Operations: efficient protocol header/payload parsing
- BM_TcpReceive_VectorSlice_Operations: legacy vector slicing overhead

Results show span path is ~10-46x faster than vector fallback depending
on payload size.

Closes #320

* docs(benchmark): add TCP receive dispatch benchmark documentation

Update README.md and README_KO.md to include:
- TCP receive dispatch benchmark in overview
- Filter command for TcpReceive benchmarks
- Detailed benchmark category section with target metrics
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.

feat(benchmark): add TCP receive dispatch benchmark (std::span vs std::vector)

1 participant