Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider different mechanism for computing time of exemplar measurements #6403

Closed
jack-berg opened this issue Apr 19, 2024 · 0 comments · Fixed by #6417
Closed

Consider different mechanism for computing time of exemplar measurements #6403

jack-berg opened this issue Apr 19, 2024 · 0 comments · Fixed by #6417
Labels
Feature Request Suggest an idea for this project

Comments

@jack-berg
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Suggest an idea for this project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant