hyb

Results 76 comments of hyb

下面这段代码每200ms运行一次,为减少同步卡顿,做了如下校验不知是否有问题 ``` void Clock::AdjustTime() const { const auto nowns = tn.rdns(); const auto nowss = tn.rdsysns(); //steady clock if (std::abs(nowns - nowss) > 1000) tn.init(); } ``` 1. 调整后的时钟是否因为较准往前回拨? 2....

笔记本上使用发现时间漂移比较严重,盒盖再翻盖后时钟误差巨大,甚至出现回拨现象,按如下解决 ``` void Clock::AdjustTime() const { const auto nowns = tn.rdns(); const auto nowss = tn.rdsysns(); //steady clock if (std::abs(nowns - nowss) > 10'000) //误差比较大,频率可能发生较大变化 tn.init(); else if (std::abs(nowns -...

目前测试看新旧版本性能差不多

测试发现时间变小, win和WSL-linux 都存在。 定期会调用calibrate()

> 时间变小是指什么呢 t1 = tn.rdns(); ...运行大概不到10分钟 t2 = tn.rdns(); t2 < t1

``` void saveParam(int64_t base_tsc, int64_t base_ns, int64_t sys_ns, double new_ns_per_tsc) { last_ns = sys_ns; last_ns_err = base_ns - sys_ns; printf(" base_tsc = %lld, base_ns = %lld, diff = %d ns,...

wsl2 init tsc_ghz: 3.00001659966801 rdsys_latency: 87.3126873126873, rdtsc_latency: 5.71268731268731, rdns_latency: 6.01268731268731, tmp: -5355641559474113368 calibrate_latency: 5, tsc_ghz: 3.00001659966801, b2c: 336, c2d: 17, err: 0, rdsysns_latency: 347 calibrate_latency: 9, tsc_ghz: 3.00001659966801, b2c: 4591,...

init 默认参数,单线程程序。30秒调用一次 calibrate() 如果改成1秒调用一次就OK

> 如果30秒调用一次calibrate(),需要把init()的第二个参数也设到30秒。实际calibrate的周期不应该高于第二个参数。 thanks reply