]> git.hungrycats.org Git - bees/commitdiff
progress: fix ETA calculations
authorZygo Blaxell <bees@furryterror.org>
Mon, 16 Jun 2025 11:30:05 +0000 (07:30 -0400)
committerZygo Blaxell <bees@furryterror.org>
Thu, 19 Jun 2025 01:17:48 +0000 (21:17 -0400)
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 <bees@furryterror.org>
src/bees-roots.cc

index c4b2381c6e1166439f3637efdb043b01beba0bc5..4607670f60eec73839c9e2b3006a37fb6e0c2911 100644 (file)
@@ -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;