Don't queue all future messages in memory in LogReader
When we were dropping messages at the end of the log file without data,
we were doing that by reading to the end of the file. This actually
triggers all the rest of the nodes to queue up their data until that
point, which can cause a lot of memory to be used rather quickly.
Instead, just mark down that we shouldn't be sending and don't send.
This keeps things memory efficient.
Change-Id: I7417d4d5b720ab7986b5a55f9efba5612f962d58
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/events/logging/log_reader.h b/aos/events/logging/log_reader.h
index 57f29bb..e367f0c 100644
--- a/aos/events/logging/log_reader.h
+++ b/aos/events/logging/log_reader.h
@@ -450,6 +450,22 @@
timestamp_loggers_.clear();
}
+ void SetFoundLastMessage(bool val) {
+ found_last_message_ = val;
+ last_message_.resize(factory_channel_index_.size(), false);
+ }
+ bool found_last_message() const { return found_last_message_; }
+
+ void set_last_message(size_t channel_index) {
+ CHECK_LT(channel_index, last_message_.size());
+ last_message_[channel_index] = true;
+ }
+
+ bool last_message(size_t channel_index) {
+ CHECK_LT(channel_index, last_message_.size());
+ return last_message_[channel_index];
+ }
+
private:
// Log file.
std::unique_ptr<TimestampMapper> timestamp_mapper_;
@@ -526,6 +542,9 @@
bool stopped_ = false;
bool started_ = false;
+
+ bool found_last_message_ = false;
+ std::vector<bool> last_message_;
};
// Node index -> State.