Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To achieve a higher precision to handle low-latency environments better, we can use Java’s System.nanoTime().

Public Interfaces

Proposed Changes

This KIP proposes using nanoTime() to record latencies to provide higher precision.

...

By using 3 decimal places in millisecond latency measurements, we are able to observe a ~0.2% spread in a low-latency environment dealing with latencies around 1 ms. 3 decimal places for milliseconds is equivalent to microseconds. This 0.2% spread is quite small, especially since other factors are likely to generate a larger variance.

Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
  • If we are changing behavior how will we phase out the older behavior?
  • If we need special migration tools, describe them here.
  • When will we remove the existing behavior?

Rejected Alternatives

Consideration #2: Long Overflow

It is important to look at potential overflow as we are saving latency in microseconds now, which means each value is multiplied by 1000 (1 millisecond is 1000 microseconds).

To calculate overall average latency, ProducerPerformance will save all observed latencies in a single `totalLatency` long variable.

We can run some calculations to observe how many record latencies can be stored in a Long based on different average latencies.

Image Added

The chart above shows that if the average latency is 1 minute, then a Long can hold 153 billion records (latencies). This covers most use cases.

Public Interfaces

This proposed change only impacts the output of the ProducerPerformance.java class by adding more precision.

Compatibility, Deprecation, and Migration Plan

This proposed change only impacts the output of the ProducerPerformance.java class by adding more precision.

Rejected Alternatives


1. Adding a "low-latency" option to enable recording measurements using System.nanoTime()If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.