Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-11805

SolrRequest elapsedTime is not computed correctly (premature millisecond conversion)

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 7.3
    • None
    • None

    Description

      (this is not QTime, this is what the SolrJ client request duration is captured as)
      This is what SolrRequest.process looks like:

          long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
          T res = createResponse(client);
          res.setResponse(client.request(this, collection));
          long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
          res.setElapsedTime(endTime - startTime);
          return res;
      

      The millisecond conversion should be delayed to the very end, otherwise it could yield a time duration of a millisecond greater than it deserves. Also, it's better to put the unit into the variable name. Also, note the convenience methods on TimeUnit like "toMillis". Here's what this should look like:

          long startNanos = System.nanoTime();
          T res = createResponse(client);
          res.setResponse(client.request(this, collection));
          long endNanos = System.nanoTime();
          res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
          return res;
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            dsmiley David Smiley
            dsmiley David Smiley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment