Handle large, single direction timestamp outages when estimating time
Brian Smartt had the clever idea of taking the max of both directions.
This essentially warps any long stretches of time such that they always
stay above the other direction with more fresh timestamps. Because the
lines then don't cross, we can solve like we used to.
We only really need to introduce this concept into FindTimestamps.
Everything else works off a valid timestamp pair so it stays the same.
Add a test to reproduce this behavior (it happens occasionally in the
wild) and then fix it.
Change-Id: I999280fc1db1f178835092a8d024a9862144d7cb
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/logging/boot_timestamp.h b/aos/events/logging/boot_timestamp.h
index 7eead2e..d0fde73 100644
--- a/aos/events/logging/boot_timestamp.h
+++ b/aos/events/logging/boot_timestamp.h
@@ -19,6 +19,11 @@
return {boot, duration + d};
}
+ BootDuration operator-() const { return {boot, -duration}; }
+ BootDuration operator-(monotonic_clock::duration d) const {
+ return {boot, duration - d};
+ }
+
bool operator==(const BootDuration &m2) const {
return boot == m2.boot && duration == m2.duration;
}