File tree 1 file changed +13
-3
lines changed 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,19 @@ struct KillState {
149
149
150
150
impl KillState {
151
151
fn new ( ) -> Self {
152
- let long_ago = Duration :: from_secs ( 60 ) ;
153
- let now = Instant :: now ( ) ;
154
- let before = now. checked_sub ( long_ago) . unwrap_or ( now) ;
152
+ // Set before to an instant long enough ago so that we don't
153
+ // immediately log or adjust the kill rate if the node is already
154
+ // under load. Unfortunately, on OSX, `Instant` measures time from
155
+ // the last boot, and if that was less than 60s ago, we can't
156
+ // subtract 60s from `now`. Since the worst that can happen if
157
+ // we set `before` to `now` is that we might log more than strictly
158
+ // necessary, and adjust the kill rate one time too often right after
159
+ // node start, it is acceptable to fall back to `now`
160
+ let before = {
161
+ let long_ago = Duration :: from_secs ( 60 ) ;
162
+ let now = Instant :: now ( ) ;
163
+ now. checked_sub ( long_ago) . unwrap_or ( now)
164
+ } ;
155
165
Self {
156
166
kill_rate : 0.0 ,
157
167
last_update : before,
You can’t perform that action at this time.
0 commit comments