1
0
mirror of https://github.com/Zygo/bees.git synced 2025-07-01 16:22:27 +02:00

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 <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell
2025-06-16 07:30:05 -04:00
parent a844024395
commit 8331f70db7

View 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_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 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); const string start_stamp = strf_localtime(this_state.m_started);
string eta_stamp = "-"; string eta_stamp = "-";
string eta_pretty = "-"; string eta_pretty = "-";
@ -1333,9 +1334,10 @@ BeesScanModeExtent::next_transid()
// eta_stamp = "idle"; // eta_stamp = "idle";
} else if (time_so_far > 10 && bytenr_offset > 1024 * 1024 * 1024) { } 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_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_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 = mes.m_map.at(subvol);
const auto mma_ratio = mes_sample_size_ok ? (mma.m_bytes / double(mes.m_total)) : 1.0; const auto mma_ratio = mes_sample_size_ok ? (mma.m_bytes / double(mes.m_total)) : 1.0;