From 8331f70db70439adcf9f619cfb1f6691be13d1b6 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 16 Jun 2025 07:30:05 -0400 Subject: [PATCH] progress: fix ETA calculations The "tm_left" field was the estimated _total_ duration of the crawl, not the amount of time remaining. The ETA timestamp was then calculated based on the estimated time to run the crawl if it started _now_, not at the start timestamp. Fix the duration and ETA calculations. Signed-off-by: Zygo Blaxell --- src/bees-roots.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bees-roots.cc b/src/bees-roots.cc index c4b2381..4607670 100644 --- a/src/bees-roots.cc +++ b/src/bees-roots.cc @@ -1323,7 +1323,8 @@ BeesScanModeExtent::next_transid() } const auto bytenr_offset = min(bi_last_bytenr, max(bytenr, bi.first_bytenr)) - bi.first_bytenr + bi.first_total; const auto bytenr_norm = bytenr_offset / double(fs_size); - const auto time_so_far = now - min(now, this_state.m_started); + const auto eta_start = min(now, this_state.m_started); + const auto time_so_far = now - eta_start; const string start_stamp = strf_localtime(this_state.m_started); string eta_stamp = "-"; string eta_pretty = "-"; @@ -1333,9 +1334,10 @@ BeesScanModeExtent::next_transid() // eta_stamp = "idle"; } else if (time_so_far > 10 && bytenr_offset > 1024 * 1024 * 1024) { const time_t eta_duration = time_so_far / bytenr_norm; - const time_t eta_time = eta_duration + now; + const time_t eta_time = eta_duration + eta_start; + const time_t eta_remain = eta_time - now; eta_stamp = strf_localtime(eta_time); - eta_pretty = pretty_seconds(eta_duration); + eta_pretty = pretty_seconds(eta_remain); } const auto &mma = mes.m_map.at(subvol); const auto mma_ratio = mes_sample_size_ok ? (mma.m_bytes / double(mes.m_total)) : 1.0;