-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use a SmallVector<T> as parts container #508
base: dev
Are you sure you want to change the base?
Conversation
Will comment more soon. |
WalkthroughWalkthroughThe recent updates in the FairMQ project primarily focus on integrating the Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (8)
Files not summarized due to errors (1)
Files not reviewed due to errors (3)
Additional comments not posted (10)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 3
Outside diff range and nitpick comments (3)
fairmq/SmallVector.h (3)
443-449
: Review the growth strategy ingrow
.The growth strategy doubles the capacity, which is common for dynamic arrays. However, consider if a different growth factor might be more appropriate based on typical usage patterns or performance metrics in your specific application context.
1172-1178
: Validate the static assertion condition forsizeof(T)
.The static assertion ensures that
T
is not excessively large, which is important for performance reasons. However, the chosen limit of 256 might be arbitrary. Consider if there's a more scientifically or empirically determined value that could be used here based on typical use cases or performance testing.
1201-1204
: Consider exception safety for theSmallVector
operations.The documentation notes that the implementation does not attempt to be exception safe. Depending on the use case, this might be acceptable, or it might be a significant risk. Consider whether adding exception safety mechanisms could improve robustness, especially in environments where exceptions are used heavily.
SmallVectorBase() = delete; | ||
SmallVectorBase(void *FirstEl, size_t TotalCapacity) | ||
: BeginX(FirstEl), Capacity(static_cast<Size_T>(TotalCapacity)) {} |
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.
Consider providing a default constructor for SmallVectorBase
.
Currently, the default constructor is deleted. If there's a valid use case where an uninitialized SmallVectorBase
could be useful or required by the system design, providing a default constructor might be beneficial. If the current design strictly requires initialization parameters, this approach is fine.
/// Put this vector in a state of being small. | ||
void resetToSmall() { | ||
this->BeginX = getFirstEl(); | ||
this->Size = this->Capacity = 0; // FIXME: Setting Capacity to 0 is suspect. |
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.
Reconsider setting Capacity
to 0 in resetToSmall
.
Setting Capacity
to 0 in resetToSmall
might lead to issues if the vector is used after being reset without proper reinitialization. This could potentially lead to segmentation faults or other memory errors. It might be safer to set Capacity
to the initial capacity or handle this scenario explicitly.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor