-
Notifications
You must be signed in to change notification settings - Fork 844
Introduce LocalBuffer #6528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce LocalBuffer #6528
Conversation
include/tscpp/util/LocalBuffer.h
Outdated
| limitations under the License. | ||
| */ | ||
|
|
||
| template <std::size_t EstSizeBound = 1024> class LocalBuffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @ywkaras said, this 1024 comes from the default arena block size.
1fb143b to
4953523
Compare
|
Is this redundant with #6536 ? |
|
I'd like to keep these commits and PRs separated. #6536 is the first use case, but this could be used anywhere. |
|
Seems a reasonable starting point. I have been working on something similar, but a bit more general. The first is the MemArena class in libswoc++. That's not quite the same - it's based on the internal The other is We might also consider bringing back the MemSpan class which is designed to help with passing back buffer descriptions. Overall, though this seems a reasonable step at this point, since my other projects are still not ready for production. |
A template class for temporally buffer. When requested buffer size is small, a buffer on stuck is used. Co-authored-by: Walt Karas <wkaras@verizonmedia.com>
4953523 to
5508aa3
Compare
|
Pushed new commit address @SolidWallOfCode's comment. Also, I made the type of buffer generic. |
|
[approve ci autest] |
A temporal buffer is needed in some cases. With this
LocalBuffer, when the requested buffer size is smaller than the threshold (1024 in default), we can avoid allocating memory on the heap. Which brings us performance improvements.@ywkaras pointed out this could be an alternative of Arena on
#6495 (comment)
Co-authored-by: Walt Karas wkaras@verizonmedia.com