From 5564ddb1879c9ed371f3285871a59f069bd4abe5 Mon Sep 17 00:00:00 2001 From: yuval-io <105581454+Yuval-Ariel@users.noreply.github.com> Date: Sun, 18 Jun 2023 09:00:33 +0300 Subject: [PATCH] Windows compilation fix (#568) --- db/db_impl/db_spdb_impl_write.cc | 2 +- include/rocksdb/write_buffer_manager.h | 4 ++-- memtable/write_buffer_manager.cc | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/db_impl/db_spdb_impl_write.cc b/db/db_impl/db_spdb_impl_write.cc index 46ad41560b..9924f294c1 100644 --- a/db/db_impl/db_spdb_impl_write.cc +++ b/db/db_impl/db_spdb_impl_write.cc @@ -301,7 +301,7 @@ void SpdbWriteImpl::SwitchAndWriteBatchGroup(WritesBatchList* batch_group) { io_s = db_->SpdbWriteToWAL(wal_batch, 1, to_be_cached_state, batch_group->need_sync_, &offset, &size); } else { - uint64_t progress_batch_seq; + uint64_t progress_batch_seq = 0; size_t wal_writes = 0; WriteBatch* merged_batch = &tmp_batch_; for (const WriteBatch* batch : batch_group->wal_writes_) { diff --git a/include/rocksdb/write_buffer_manager.h b/include/rocksdb/write_buffer_manager.h index e5177809d2..5e5d9f10f7 100644 --- a/include/rocksdb/write_buffer_manager.h +++ b/include/rocksdb/write_buffer_manager.h @@ -308,11 +308,11 @@ class WriteBufferManager final { return ParseCodedUsageState(GetCodedUsageState()); } - void UpdateUsageState(size_t new_memory_used, ssize_t mem_changed_size, + void UpdateUsageState(size_t new_memory_used, int64_t mem_changed_size, size_t quota); uint64_t CalcNewCodedUsageState(size_t new_memory_used, - ssize_t memory_changed_size, size_t quota, + int64_t memory_changed_size, size_t quota, uint64_t old_coded_usage_state); uint64_t GetCodedUsageState() const { diff --git a/memtable/write_buffer_manager.cc b/memtable/write_buffer_manager.cc index 5828efe78c..b14f24ddfd 100644 --- a/memtable/write_buffer_manager.cc +++ b/memtable/write_buffer_manager.cc @@ -98,7 +98,7 @@ void WriteBufferManager::ReserveMem(size_t mem) { new_memory_used = old_memory_used + mem; } if (is_enabled) { - UpdateUsageState(new_memory_used, mem, buffer_size()); + UpdateUsageState(new_memory_used, static_cast(mem), buffer_size()); // Checking outside the locks is not reliable, but avoids locking // unnecessarily which is expensive if (UNLIKELY(ShouldInitiateAnotherFlushMemOnly(new_memory_used))) { @@ -172,7 +172,8 @@ void WriteBufferManager::FreeMem(size_t mem) { assert(curr_memory_inactive >= mem); assert(curr_memory_being_freed >= mem); - UpdateUsageState(new_memory_used, -mem, buffer_size()); + UpdateUsageState(new_memory_used, static_cast(-mem), + buffer_size()); } // Check if stall is active and can be ended. @@ -431,15 +432,14 @@ void WriteBufferManager::UpdateControllerDelayState() { } uint64_t WriteBufferManager::CalcNewCodedUsageState( - size_t new_memory_used, ssize_t memory_changed_size, size_t quota, + size_t new_memory_used, int64_t memory_changed_size, size_t quota, uint64_t old_coded_usage_state) { auto [old_usage_state, old_delay_factor] = ParseCodedUsageState(old_coded_usage_state); auto new_usage_state = old_usage_state; auto new_delay_factor = old_delay_factor; - size_t usage_start_delay_threshold = - (static_cast(start_delay_percent_) / 100) * quota; + size_t usage_start_delay_threshold = (start_delay_percent_ / 100.0) * quota; auto step_size = (quota - usage_start_delay_threshold) / kMaxDelayedWriteFactor; @@ -513,7 +513,7 @@ auto WriteBufferManager::ParseCodedUsageState(uint64_t coded_usage_state) } void WriteBufferManager::UpdateUsageState(size_t new_memory_used, - ssize_t memory_changed_size, + int64_t memory_changed_size, size_t quota) { assert(enabled()); if (allow_stall_.load(std::memory_order_relaxed) == false || @@ -540,7 +540,7 @@ void WriteBufferManager::UpdateUsageState(size_t new_memory_used, if (done == false) { // Retry. However, new_memory_used = memory_usage(); - memory_changed_size = 0U; + memory_changed_size = 0; } else { // WBM state has changed. need to update the WCs. UpdateControllerDelayState();