Live data from Hacker News

Measuring Latency in Linux (2014)

btorpey.github.io

1–10 of 37 posts

Re: Measuring Latency in Linux (2014)

#3
OP: Related stuff

How Golang[1] implements monotonic clocks — basically it retrieves always both wall and monotonic clocks on "time.Now()" and when doing operations of subtraction it uses the monotonic. When printing, it uses the wall time. Pretty neat. Details on the proposal by Russ Cox [2].

[1] https://golang.org/pkg/time/#hdr-Monotonic_Clocks [2] https://go.googlesource.com/proposal/+/master/design/12914-m...

Re: Measuring Latency in Linux (2014)

#4
post #3

OP: Related stuff How Golang[1] implements monotonic clocks — basically it retrieves always both wall and monotonic clocks on "time.Now()" and when doing operations of subtraction it uses the monotonic. When printing, it uses the wall time. Pretty neat. Details on the proposal by Russ Cox [2]. [1] https://golang.org/pkg/time/#hdr-Monotonic_Clocks [2] https://go.googlesource.com/proposal/+/master/design/12914-m...

In Python:

  import time 
  time.get_clock_info(name)

where name can be one of those:

  'monotonic': time.monotonic()
  'perf_counter': time.perf_counter()
  'process_time': time.process_time()
  'thread_time': time.thread_time()
  'time': time.time()

Re: Measuring Latency in Linux (2014)

#8
post #3

OP: Related stuff How Golang[1] implements monotonic clocks — basically it retrieves always both wall and monotonic clocks on "time.Now()" and when doing operations of subtraction it uses the monotonic. When printing, it uses the wall time. Pretty neat. Details on the proposal by Russ Cox [2]. [1] https://golang.org/pkg/time/#hdr-Monotonic_Clocks [2] https://go.googlesource.com/proposal/+/master/design/12914-m...

How does scheduling a timer to go off at 3pm this Saturday work?

Re: Measuring Latency in Linux (2014)

#9
post #3

OP: Related stuff How Golang[1] implements monotonic clocks — basically it retrieves always both wall and monotonic clocks on "time.Now()" and when doing operations of subtraction it uses the monotonic. When printing, it uses the wall time. Pretty neat. Details on the proposal by Russ Cox [2]. [1] https://golang.org/pkg/time/#hdr-Monotonic_Clocks [2] https://go.googlesource.com/proposal/+/master/design/12914-m...

How does scheduling a timer to go off at 3pm this Saturday work?

Well, the parameter of a Timer is of type Duration:

  A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.
Which is not really good because we have to calculate the time between now() and Saturday. If "wall time" changes, the scheduler will not be triggered when expected.

In that case I would not rely on Timer to use it in a cron-like fashion, or trigger a Ticker every second, check the _current_ wall time, and decide if anything needs to be done.

You can read more about Timers, Tickers and Sleeps in this (pretty interesting) article[1]

[1] https://blog.gopheracademy.com/advent-2016/go-timers/

Re: Measuring Latency in Linux (2014)

#10
I don't think his comment about CLOCK_MONOTONIC_RAW being slow to query applies anymore. It used to be slow because it was not implemented in the vDSO library and so it included the overhead of a syscall. But there was a big vDSO refactoring that landed on 5.3 that I think fixed this problem.

Edit: found the patchset. In includes benchmarks for several architectures as well: https://lore.kernel.org/linux-arm-kernel/20190621095252.3230...

Post reply on HN