Skip to content

Time sometimes goes backwards for a moment  #54

@nevercast

Description

@nevercast

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)

return isolate.cpuTime[0] * 1e3 + isolate.cpuTime[1] / 1e6;

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions