Optimize reaction memory without heap allocation#19
Draft
Conversation
This commit introduces Small Buffer Optimization (SBO) to the Reaction framework. SBO allows small, trivially destructible types to be stored directly within the reactive node, avoiding heap allocations and improving performance. Key changes include: - **`OptimizedResource<Type>`**: A new resource implementation that uses SBO for eligible types. - **`ResourceImpl<Type>`**: A type alias in `resource_selector.h` that conditionally uses `OptimizedResource` or the standard `Resource` based on the `REACTION_ENABLE_SBO` macro. - **SBO Criteria**: Defined by size (<= 32 bytes), trivial destructibility, and standard alignment. - **Benchmarks**: Added `bench_sbo.cpp` to compare performance of standard vs. SBO implementations. - **Unit Tests**: Added `test_sbo_optimization.cpp` to verify SBO functionality. - **Documentation**: Added `docs/SBO_OPTIMIZATION.md` and `SMALL_MEMORY_OPTIMIZATION_SUMMARY.md` to explain SBO. - **Example**: Added `example/sbo_example.cpp` to demonstrate SBO usage. SBO is disabled by default to ensure backward compatibility. It can be enabled by defining `REACTION_ENABLE_SBO` before including Reaction headers. Co-authored-by: 844727475lmy <844727475lmy@gmail.com>
|
Cursor Agent can help with this pull request. Just |
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.
Implement configurable Small Buffer Optimization (SBO) for
reactionframework resources to eliminate heap allocations for small reactive variables.