You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My hypothesis is that this read is not atomic, the high bits are read, then the timer rolls over to a new high bit, the low bits have gone from max to min value when they roll over, and now the low bits are read.
Before the call to getUsed the timer may have been
I believe if cpuTime is copied to a local value first, and then destructed [0], [1]. Time will no longer go backwards and getUsed will never be negative
Cheers.
The text was updated successfully, but these errors were encountered:
Following are the results of pairs of calls to getCpuTme() on MMO today (14th May 2024) that occurred not long after each other.
1st call
2nd call
delta
-1200.0631857999251
100.26343420002377
1300.326619999949
-1226.9246276998892
73.41425370005891
1300.3388813999481
-1242.352072100155
57.95801579998806
1300.3100879001431
70.28952509999363
-1229.4321969000011
-1299.7217219999948
58.899245199994766
-1240.8014530000073
-1299.700698200002
This is a rare event as my bot makes many calls to getCpuTime() in the course of a day, and this condition occurs less than 100 times a day. When it occurs, the difference between the result of the two calls is consistently very close to 1300 CPU.
My hypothesis is that this read is not atomic, the high bits are read, then the timer rolls over to a new high bit, the low bits have gone from max to min value when they roll over, and now the low bits are read.
Before the call to getUsed the timer may have been
0xFAFF
Now it's
0xFB00
The JavaScript code reads
0xFA00
(Numbers not to scale)
driver/lib/runtime/runtime.js
Line 26 in e691bd3
I believe if cpuTime is copied to a local value first, and then destructed [0], [1]. Time will no longer go backwards and getUsed will never be negative
Cheers.
The text was updated successfully, but these errors were encountered: