-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
Affects Version/s: None
-
Component/s: Replication
-
None
-
Query Execution
-
Fully Compatible
-
QE 2025-02-17
-
None
-
None
-
None
-
None
-
None
-
None
-
None
In oplog.cpp we currently create a vector of {{std::string}}s for every command that is applied.
While the strings are short and can likely benefit from the short value optimization that are present in std::string implementations, creating them and allocating a new instance of std::vector to hold these strings in every invocation of the function seems to be unnecessary work.
Additionally, we only need these strings if the oplog application mode is kInitialSync
Furthermore, if the oplog application mode is kInitialSync , we currently implicit convert the oplog command name into an std::string only to compare it with the entries in the vector here.
To improve this, we could move the vector outside of the function, so it is created only once. Even better would be to make it an std::array to avoid the heap memory of a vector altogether. Finally, we can change it from a container of {{std::string}}s to a container of {{StringData}}s.