Merge pull request #6192 from sfc-gh-tclinkenbeard/improve-commitbatcher-performance

Make `VectorRefPreserializer` move constructor noexcept
This commit is contained in:
Trevor Clinkenbeard 2022-01-31 09:52:51 -08:00 committed by GitHub
commit e6b02532a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -209,6 +209,8 @@ ACTOR Future<Void> commitBatcher(ProxyCommitData* commitData,
state Future<Void> timeout;
state std::vector<CommitTransactionRequest> batch;
state int batchBytes = 0;
// TODO: Enable this assertion (currently failing with gcc)
// static_assert(std::is_nothrow_move_constructible_v<CommitTransactionRequest>);
if (SERVER_KNOBS->MAX_COMMIT_BATCH_INTERVAL <= 0) {
timeout = Never();

View File

@ -845,10 +845,14 @@ enum class VecSerStrategy { FlatBuffers, String };
template <class T, VecSerStrategy>
struct VectorRefPreserializer {
VectorRefPreserializer() {}
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) { return *this; }
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::String>&) {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::String>&) { return *this; }
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) noexcept {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) noexcept {
return *this;
}
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::String>&) noexcept {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::String>&) noexcept {
return *this;
}
void invalidate() {}
void add(const T& item) {}
@ -862,14 +866,14 @@ struct VectorRefPreserializer<T, VecSerStrategy::String> {
string_serialized_traits<T> _string_traits;
VectorRefPreserializer() : _cached_size(0) {}
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::String>& other)
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::String>& other) noexcept
: _cached_size(other._cached_size) {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::String>& other) {
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::String>& other) noexcept {
_cached_size = other._cached_size;
return *this;
}
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) : _cached_size(-1) {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) {
VectorRefPreserializer(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) noexcept : _cached_size(-1) {}
VectorRefPreserializer& operator=(const VectorRefPreserializer<T, VecSerStrategy::FlatBuffers>&) noexcept {
_cached_size = -1;
return *this;
}