mirror of https://github.com/grpc/grpc.git
[time] Fix multiple second stall at startup of mac/ios apps (#31844)
Quick explainer (this is gross): - `grpc_core::Timestamp` measures millis since an arbitrary epoch, and on 32-bit platforms is 32-bit precise - `gpr_now(GPR_CLOCK_MONOTONIC)` measures nanos since a different arbitrary epoch - since Timestamp has limited range, we choose its epoch to roughly correlate with process startup to avoid overflow - since we have static initialization problems on some platforms we choose 0 as an uninitialized designator for that epoch - since we have bugs elsewhere, we insist that time values are >1 second from Timestamp - to deal with all that, if we get `gpr_now(GPR_CLOCK_MONOTONIC)` values that are close to 0 or 1 seconds we wait for a little while to get values that will work better later - on mac and windows gpr_now(GPR_CLOCK_MONOTONIC) was setting its epoch to be process startup exactly, and so we hit this all the time This PR fixes some bugs in initialization of the Timestamp epoch and clarifies the code somewhat, and (more importantly) shifts the Windows and Mac epochs five seconds prior to process startup, guaranteeing that the logic in `grpc_core::Timestamp`'s epoch sees values that it can immediately use in all cases and eliminating the need for the pause.pull/31807/head^2
parent
1f15f21540
commit
7c206579ab
3 changed files with 19 additions and 8 deletions
Loading…
Reference in new issue