perf(tcp_socket): add std::span receive callback to remove per-read allocations#321
Merged
Merged
Conversation
…llocations - Add set_receive_callback_view() for zero-copy receive path - Implement lock-free callback storage using shared_ptr + atomic operations - Update do_read() to prefer span callback when set (no vector allocation) - Keep legacy vector callback for backward compatibility - Add unit tests for new functionality Closes #316
- Add performance section for TCP socket zero-allocation receive path - Document new set_receive_callback_view API and lock-free callback storage - Update both English and Korean changelog files
Contributor
Performance ComparisonBase Branch ResultsNo base results PR Branch ResultsNo PR results |
5 tasks
kcenon
added a commit
that referenced
this pull request
Apr 13, 2026
…llocations (#321) * perf(tcp_socket): add std::span receive callback to remove per-read allocations - Add set_receive_callback_view() for zero-copy receive path - Implement lock-free callback storage using shared_ptr + atomic operations - Update do_read() to prefer span callback when set (no vector allocation) - Keep legacy vector callback for backward compatibility - Add unit tests for new functionality Closes #316 * docs: update changelog with tcp_socket span callback feature - Add performance section for TCP socket zero-allocation receive path - Document new set_receive_callback_view API and lock-free callback storage - Update both English and Korean changelog files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
set_receive_callback_view(std::span<const uint8_t>)API for zero-copy receive pathshared_ptr+atomic_load/storedo_read()to prefer span callback (no vector allocation) when setChanges
New API
tcp_socket::set_receive_callback_view(std::function<void(std::span<const uint8_t>)>)Performance Improvements
std::vectorallocation/copy when using span callbackFiles Changed
src/internal/tcp_socket.h- Add span callback API and lock-free storagesrc/internal/tcp_socket.cpp- Implement new functionalityinclude/kcenon/network/internal/tcp_socket.h- Public header synctests/CMakeLists.txt- Add tcp_socket_test targettests/unit/tcp_socket_test.cpp- Comprehensive unit testsdocs/CHANGELOG.md,docs/CHANGELOG_KO.md- DocumentationTest Plan
Run tests:
Closes #316
Part of Epic #315