real-logic / artio

Artio - Resilient High-Performance FIX and FIXP Gateway
Apache License 2.0
299 stars 122 forks source link

Engine based messages always have millisecond resolution #388

Closed vdaniloff closed 4 years ago

vdaniloff commented 4 years ago

Hi, messages sent via the engine itself always have millisecond resolution, because millis-based EpochClock is used. Also, messages sent by a Session#send(Encoder) also have the sending time set to millis-based clock (to support micros one has to call prepare, then set it externally and then send a buffer instead of encoder).

I see several possible fixes for this: 1) switch to EpochNanoClock for that (only used by i3link for now). Possible problem is their subtle discrepancy with millis-based clock, probably this is negligible 2) introduce an EpochFractionClock similar to aeron-cluster ClusterClock. Get rid of epochnanoclock and epochclock in configuration, with only passing one (and then converting)

Happy to fix this myself, but let's discuss it first.

RichardWarburton commented 4 years ago

The thing is that we have a configuration option for sessionEpochFractionFormat() in theCommonConfiguration` which should determine this. I guess the issue here is that even though we pass that in we get milliseconds configured as the option. I'm not sure how that ended up happening.

I don't think we should get rid of the EpochNanoClock and the EpochClock from configuration as they allow users to provide custom implementations of those clocks including based upon more accurate hardware timestamps than we can provide with a general Java implementation.

I like the idea of adding an EpochFractionClock as an internal class - maybe a composite of an EpochNanoClock and an EpochClock taking a the EpochFractionFormat as an argument that can be used by the FIX implementation.

vdaniloff commented 4 years ago

sessionEpochFractionFormat defines the precision, but not the clock resolution. so yes, there would be microseconds in the format, but it will end with 000. OK, then let's have a composite of clocks :)