]> git.hungrycats.org Git - bees/commitdiff
progress: put the progress table in the stats and status files
authorZygo Blaxell <bees@furryterror.org>
Wed, 27 Nov 2024 20:58:06 +0000 (15:58 -0500)
committerZygo Blaxell <bees@furryterror.org>
Sun, 1 Dec 2024 05:17:51 +0000 (00:17 -0500)
Make the progress information more accessible, without having to
enable full debug log and fish it out of the stream with grep.

Also increase the progress log level to INFO.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-context.cc
src/bees-hash.cc
src/bees-roots.cc
src/bees.h

index d4c533ea3133213888819daf722e4c7760a840e3..dd46c7cfbe031acfb28d450748bf920cfca0d6d5 100644 (file)
@@ -98,6 +98,8 @@ BeesContext::dump_status()
                TaskMaster::print_queue(ofs);
 #endif
 
+               ofs << get_progress();
+
                ofs.close();
 
                BEESNOTE("renaming status file '" << status_file << "'");
@@ -112,6 +114,20 @@ BeesContext::dump_status()
        }
 }
 
+void
+BeesContext::set_progress(const string &str)
+{
+       unique_lock<mutex> lock(m_progress_mtx);
+       m_progress_str = str;
+}
+
+string
+BeesContext::get_progress()
+{
+       unique_lock<mutex> lock(m_progress_mtx);
+       return m_progress_str;
+}
+
 void
 BeesContext::show_progress()
 {
@@ -159,6 +175,8 @@ BeesContext::show_progress()
                        BEESLOGINFO("\ttid " << t.first << ": " << t.second);
                }
 
+               // No need to log progress here, it is logged when set
+
                lastStats = thisStats;
        }
 }
index 0ec092abe0653b134b031430eb40b799dad17ed1..60e60e70c31634a182ae41cca3c8a1425ee2893b 100644 (file)
@@ -356,6 +356,8 @@ BeesHashTable::prefetch_loop()
                auto avg_rates = thisStats / m_ctx->total_timer().age();
                graph_blob << "\t" << avg_rates << "\n";
 
+               graph_blob << m_ctx->get_progress();
+
                BEESLOGINFO(graph_blob.str());
                catch_all([&]() {
                        m_stats_file.write(graph_blob.str());
index 9d597ed68d61c7224af9d97c94c5957bc402d296..c2f0e3c9fbb7a4072193d6f1d0e0e442ad22b739 100644 (file)
@@ -1069,10 +1069,6 @@ BeesScanModeExtent::next_transid(const CrawlMap &crawl_map_unused)
                });
                BEESCOUNT(progress_ok);
        }
-       ostringstream oss;
-       eta.left("PROGRESS: ");
-       eta.mid(" ");
-       eta.right("");
        eta.insert_row(0, vector<Table::Content> {
                Table::Text("done"),
                Table::Text(pretty(fs_size)),
@@ -1087,8 +1083,24 @@ BeesScanModeExtent::next_transid(const CrawlMap &crawl_map_unused)
        });
        const auto dash_fill = Table::Fill('-');
        eta.insert_row(1, vector<Table::Content>(eta.cols().size(), dash_fill));
-       oss << eta;
-       BEESLOGDEBUG(oss.str());
+       eta.left("");
+       eta.mid(" ");
+       eta.right("");
+
+       // One for publication through beesstats.txt and $BEESSTATUS
+       {
+               ostringstream progress_oss;
+               progress_oss << eta;
+               m_ctx->set_progress(progress_oss.str());
+       }
+
+       // One for the debug log
+       {
+               eta.left("PROGRESS: ");
+               ostringstream log_oss;
+               log_oss << eta;
+               BEESLOGINFO(log_oss.str());
+       }
 }
 
 void
index da68b66e11d447697536fd81dc07afe2b3399953..870e2be059dcb69ef9d6e76bebd1cec0f4371029 100644 (file)
@@ -749,6 +749,9 @@ class BeesContext : public enable_shared_from_this<BeesContext> {
        shared_ptr<BeesThread>                          m_progress_thread;
        shared_ptr<BeesThread>                          m_status_thread;
 
+       mutex                                           m_progress_mtx;
+       string                                          m_progress_str;
+
        void set_root_fd(Fd fd);
 
        BeesResolveAddrResult resolve_addr_uncached(BeesAddress addr);
@@ -784,6 +787,8 @@ public:
 
        void dump_status();
        void show_progress();
+       void set_progress(const string &str);
+       string get_progress();
 
        void start();
        void stop();