From 01bd86ad356a69ab54783aaaa198b6faa5684fb1 Mon Sep 17 00:00:00 2001 From: leipeng Date: Sun, 31 Oct 2021 23:10:53 -0700 Subject: [PATCH] InternalStats::DumpCFMapStat: fix sum.w_amp (#9065) Summary: sum `w_amp` will be a very large number`(bytes_written + bytes_written_blob)` when there is no any flush and ingest. This PR set sum `w_amp` to zero if there is no any flush and ingest, this is conform to per-level `w_amp` computation. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9065 Reviewed By: ajkr Differential Revision: D31943994 Pulled By: riversand963 fbshipit-source-id: acbef5e331debebfad09e0e0d8d0885ebbc00609 --- db/internal_stats.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/internal_stats.cc b/db/internal_stats.cc index dd618983f..7db16ba9a 100644 --- a/db/internal_stats.cc +++ b/db/internal_stats.cc @@ -1519,9 +1519,11 @@ void InternalStats::DumpCFMapStats( } } // Cumulative summary - double w_amp = (compaction_stats_sum->bytes_written + - compaction_stats_sum->bytes_written_blob) / - static_cast(curr_ingest + 1); + double w_amp = (0 == curr_ingest) + ? 0.0 + : (compaction_stats_sum->bytes_written + + compaction_stats_sum->bytes_written_blob) / + static_cast(curr_ingest); // Stats summary across levels std::map sum_stats; PrepareLevelStats(&sum_stats, total_files, total_files_being_compacted,