-
Notifications
You must be signed in to change notification settings - Fork 957
Consider different mechanism for computing time of exemplar measurements #6403
Copy link
Copy link
Closed
Labels
Feature RequestSuggest an idea for this projectSuggest an idea for this project
Description
When we offer a measurement to an exemplar reservoir cell, we call Clock.now(), which is resolved inefficiently for java 9+:
@Override
public long currentTimeNanos() {
Instant now = Clock.systemUTC().instant();
return TimeUnit.SECONDS.toNanos(now.getEpochSecond()) + now.getNano();
}
For java 8, the implementation is simpler and more efficient:
/** Returns the number of nanoseconds since the epoch (00:00:00, 01-Jan-1970, GMT). */
public long currentTimeNanos() {
return TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
}
As discussed here, this is a factor in reduced performance when exemplars are enabled. Its particularly impactful for explicit bucket histograms, which always take the last value for each cell, and are therefore calling currentTimeNanos() for each and every measurement.
We should consider optimizing the java 9+ or using the simpler (but likely less accurate) java 8 version for java 9+. Perhaps we only use the simpler / less accurate implementation for exemplars, which are less important.
cc @jsuereth
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Feature RequestSuggest an idea for this projectSuggest an idea for this project