-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Use buffer pool for logging #303
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
Conversation
Summary of ChangesHello @bnbajwa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a buffer pooling strategy for log messages to significantly reduce dynamic memory allocations, thereby improving logging performance and reducing memory fragmentation. By reusing pre-allocated message buffers, the system avoids the overhead of frequent Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a buffer pool for logging to eliminate dynamic memory allocations on the hot path. This is achieved by using a boost::lockfree::stack as a pool of log buffers. The Log class now attempts to acquire a buffer from this pool before falling back to dynamic allocation. Various logger implementations (NullLogger, StdLogger, SysLogger, AsyncLogger) are updated to return the buffers to the pool after use. The changes are correct and well-implemented. My review includes a couple of suggestions to replace magic numbers related to pool configuration with named constants to improve code readability and maintainability.
51f7af3 to
c41df3c
Compare
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.
Pull Request Overview
This PR implements a lock-free buffer pool for log message storage to reduce dynamic memory allocations during logging operations. The pool pre-allocates log buffers and reuses them across log operations.
- Introduces a global
LogBufPoolusingboost::lockfree::stackwith a capacity of 64 buffers - Updates all logger implementations to return buffers to the pool after use
- Modifies the
Logconstructor to attempt to acquire a buffer from the pool before allocating new storage
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| toolbox/sys/Logger.hpp | Adds LogBufPool type alias and log_buf_pool() function declaration; reorganizes includes |
| toolbox/sys/Logger.cpp | Implements the buffer pool with initialization, adds buffer return logic to all logger implementations |
| toolbox/sys/Log.ut.cpp | Updates test logger to return buffers to the pool |
| toolbox/sys/Log.hpp | Modifies Log constructor to attempt to acquire buffers from the pool before allocating |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Eliminates dynamic allocations SDB-10043
Eliminates dynamic allocations
The Log class now attempts to acquire a buffer from this pool before falling back to dynamic allocation. Various logger implementations (NullLogger, StdLogger, SysLogger, AsyncLogger) are updated to return the buffers to the pool after use.
SDB-10043