Documentation
¶
Overview ¶
Package clock turns the tick counter in a completion into nanoseconds.
It is its own package, with no cgo in it, so that the arithmetic can be tested: the conversion lives on the receive path of the fastest backend and is the easiest thing in it to get quietly wrong.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
A Counter converts the ticks of one queue's completions to nanoseconds, carrying the wraps.
The counter in a completion is narrow -- 41 bits on a ConnectX-6 Dx, which at a nanosecond a tick comes back round every 37 minutes -- so scaling it on its own gives a time that jumps backwards by half an hour several times a day, and one interval of about six hundred years each time it does. Anything watching a link for longer than half an hour meets this, and the whole point of a timestamp is the interval between two of them.
So the wraps are counted here and added back, which makes the result rise for as long as the queue is open. A Counter belongs to one queue and is not safe to share, like everything else on the receive path.
func (*Counter) NS ¶
NS converts one completion's ticks.
Timestamps that step backwards a little are ordinary: a card stamps a packet at the port and places it in a queue afterwards, so under loss the two orders come apart. A wrap is a step backwards of half the counter, which is eighteen minutes here, so the two cannot be confused by anything the hardware does.