Prefer monotonic clock for timestamp
in Sample
and all other FooMetrics
#469
Replies: 4 comments 4 replies
-
Converted to a discussion because this is not a trivial change, and would require a very careful consideration. Once we agree on a path, we can create an issue (or more) with the concrete actions we need to take. |
Beta Was this translation helpful? Give feedback.
-
I don't think using a monotonic clock is a viable option here, because this timestamp will be used for data science all over, and I guess they need concrete dates. Not sure if there is anything we can do for users that need a strong protection against time jumps. We had a discussion in the past about this, but I can't find where. Maybe it was in the internal chat. FYI @frequenz-floss/python-sdk-team @thomas-nicolai-frequenz @frequenz-floss/datasci-team |
Beta Was this translation helpful? Give feedback.
-
I am not sure I get the problem case to be honest. Are you saying a once created If so, that would be a problem, though I doubt that is the case.. As for sudden jumps when using It maybe worth creating a scenario where this happens to see possible problems, but otherwise, I am not yet completely understanding the problem :) |
Beta Was this translation helpful? Give feedback.
-
Not going to happen. |
Beta Was this translation helpful? Give feedback.
-
What's needed?
Hi,
while migrating to
BatteryPool
again, I noticed that data types likeSample
,CapacityMetrics
,PowerMetrics
,SoCMetrics
all feature atimestamp
member of typedatetime
. I think it should not be of typedatetime
(e.g. be initialized to the result of the calldatetime.now()
because that is subject to jump arbitrarily forth and back at the will of the system administrator (e.g.sudo date -s ...
, which potentially could break assumptions by a callee that is getting new metrics/samples being passed with the time jumping out of nowhere.Proposed solution
Prefer a strong data type to enforce monotonic time clock use
Use cases
Improved resillience against external clock changes (sysop setting time, or computer going to sleep for various reasons)
Alternatives and workarounds
No response
Additional context
to guard against time jumps, it's usually typical to always favor monotonic clocks. I am not sure how far Frequenz-SDK users actually rely on forward-ticking clocks or if these timestamp values matter at all (for resampling I think they might, and there we should actually prefer monotonic clock, IMHO)
Beta Was this translation helpful? Give feedback.
All reactions