Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(log): avoid divide by zero in log info (#2514)
#2472 is supposed to make log summary run regularly and not get blocked by something else on the event loop. However, it didn't actually achieve that. What's worse, I think it caused the correct number of calls to be scheduled, but not executed at the same time. When the event loop is busy, it can end up executing 10 calls at the same time, which results in the confusing logs: ``` Apr 22 05:37:57.914 INFO stats: # 3166239 Downloading headers 48% -/10 6/6/40 peers ⬇ 11.7kiB/s ⬆ 22 B/s 0.00 bps 0 gas/s CPU: 110%, Mem: 50.2 MiB Apr 22 05:37:57.915 INFO stats: # 3166239 Downloading headers 48% -/10 6/6/40 peers ⬇ 11.7kiB/s ⬆ 22 B/s 0.00 bps 0 gas/s CPU: NaN%, Mem: 50.2 MiB Apr 22 05:37:57.916 INFO stats: # 3166239 Downloading headers 48% -/10 6/6/40 peers ⬇ 11.7kiB/s ⬆ 22 B/s NaN bps 9223372.04 Tgas/s CPU: NaN%, Mem: 50.2 MiB Apr 22 05:38:48.839 INFO stats: # 3166239 Downloading headers 48% -/10 7/7/40 peers ⬇ 26.1kiB/s ⬆ 1.8kiB/s 0.00 bps 0 gas/s CPU: 108%, Mem: 52.5 MiB Apr 22 05:38:48.840 INFO stats: # 3166239 Downloading headers 48% -/10 7/7/40 peers ⬇ 26.1kiB/s ⬆ 1.8kiB/s NaN bps 9223372.04 Tgas/s CPU: NaN%, Mem: 52.5 MiB ``` This is because time elapsed between two `log_summary` calls is less than one millisecond and it causes some divide by zero errors. This PR therefore reverts the change in #2472. Test plan --------- Run a node locally to see that there is no more `NaN`s.
- Loading branch information