morganstanley/binlog

tsc time issue

Closed this issue · 6 comments

image

Hi ,I read tsc value as above. But my log time was not correct.

image

[2021-04-30 **15:21:15.**031082254] [139967332558592] [INFO] [HXQuoteDemo/HXQuoteDemo.cpp:295 OnRtnMarketData] **15:22:35.**000036,code:510050

actual time is 15:22:35, but binlog time is 15:21:15.

can you help me?

image

image

attached is frequency value on my machine.
I used TSC_INFO_W to output log.
image

The last image doesn't show how the "actual time" is computed. However, there's no way I could figure out what's going on by looking at partial images of your source code. TSC timetsamping is a difficult topic, subject to a large number of issues (e.g: see comment in the code that you copied from google benchmark, or think about clock skew, that requires sending TscSync entries peridocally, etc).

The last image doesn't show how the "actual time" is computed. However, there's no way I could figure out what's going on by looking at partial images of your source code. TSC timetsamping is a difficult topic, subject to a large number of issues (e.g: see comment in the code that you copied from google benchmark, or think about clock skew, that requires sending TscSync entries peridocally, etc).

image

image

Attach my local time function GetCurTimeStr()

My program run at CentOS 8.

image

In win32 platform, the time stamp of binlog seems the same with GetCurTimeStr().

Clock skew is described here: https://en.wikipedia.org/wiki/Clock_skew
If you experience that the tsc timestamp increasingly drifts away from the NTP synchronized clock, you can try adding a ClockSync entry periodically (e.g: once in a minute), or improve the way the tsc frequency is calculated.