Solr
  1. Solr
  2. SOLR-5734

We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.7.1, 4.8, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      As brought up by Ramkumar Aiyengar in SOLR-5721.

      1. SOLR-5734.patch
        60 kB
        Mark Miller

        Activity

        Hide
        Mark Miller added a comment -

        I'll try and knock this off this weekend before we lose it.

        Show
        Mark Miller added a comment - I'll try and knock this off this weekend before we lose it.
        Hide
        Mark Miller added a comment -

        I've done some initial work on this, but I'm still trying to track down an issue or two with it. I'll put up a patch later today if Eclipse starts cooperating.

        Show
        Mark Miller added a comment - I've done some initial work on this, but I'm still trying to track down an issue or two with it. I'll put up a patch later today if Eclipse starts cooperating.
        Hide
        Mark Miller added a comment -

        Here is a pass that covers all the low hanging fruit in non test code.

        Show
        Mark Miller added a comment - Here is a pass that covers all the low hanging fruit in non test code.
        Hide
        ASF subversion and git services added a comment -

        Commit 1573425 from Mark Miller in branch 'dev/trunk'
        [ https://svn.apache.org/r1573425 ]

        SOLR-5734: We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time.

        Show
        ASF subversion and git services added a comment - Commit 1573425 from Mark Miller in branch 'dev/trunk' [ https://svn.apache.org/r1573425 ] SOLR-5734 : We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time.
        Hide
        ASF subversion and git services added a comment -

        Commit 1573426 from Mark Miller in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1573426 ]

        SOLR-5734: We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time.

        Show
        ASF subversion and git services added a comment - Commit 1573426 from Mark Miller in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1573426 ] SOLR-5734 : We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time.
        Hide
        Noble Paul added a comment -

        Any reason why System.currentTimeMillis is bad ?

        Show
        Noble Paul added a comment - Any reason why System.currentTimeMillis is bad ?
        Hide
        Mark Miller added a comment -

        Please see "As brought up by Ramkumar Aiyengar in SOLR-5721" or google search the difference of currentTimeMillis and nano.

        Show
        Mark Miller added a comment - Please see "As brought up by Ramkumar Aiyengar in SOLR-5721 " or google search the difference of currentTimeMillis and nano.
        Hide
        Steve Rowe added a comment -

        Mark Miller, should this be backported to 4.7.1? (It's marked as a bug here but you called it an improvement over on SOLR-5721.)

        Show
        Steve Rowe added a comment - Mark Miller , should this be backported to 4.7.1? (It's marked as a bug here but you called it an improvement over on SOLR-5721 .)
        Hide
        Mark Miller added a comment -

        It could go back - it's a bug really, but nothing that hasn't always existed for the most part. Though I suppose it wouldn't have existed in the SOLR-5721 code yet.

        Show
        Mark Miller added a comment - It could go back - it's a bug really, but nothing that hasn't always existed for the most part. Though I suppose it wouldn't have existed in the SOLR-5721 code yet.
        Hide
        ASF subversion and git services added a comment -

        Commit 1581162 from Steve Rowe in branch 'dev/branches/lucene_solr_4_7'
        [ https://svn.apache.org/r1581162 ]

        SOLR-5734: We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time. (merged branch_4x r1573426)

        Show
        ASF subversion and git services added a comment - Commit 1581162 from Steve Rowe in branch 'dev/branches/lucene_solr_4_7' [ https://svn.apache.org/r1581162 ] SOLR-5734 : We should use System.nanoTime rather than System.currentTimeMillis when calculating elapsed time. (merged branch_4x r1573426)
        Hide
        ASF subversion and git services added a comment -

        Commit 1581163 from Steve Rowe in branch 'dev/trunk'
        [ https://svn.apache.org/r1581163 ]

        SOLR-5734: move CHANGES.txt entry to 4.7.1 section

        Show
        ASF subversion and git services added a comment - Commit 1581163 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1581163 ] SOLR-5734 : move CHANGES.txt entry to 4.7.1 section
        Hide
        ASF subversion and git services added a comment -

        Commit 1581164 from Steve Rowe in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1581164 ]

        SOLR-5734: move CHANGES.txt entry to 4.7.1 section (merged trunk r1581163)

        Show
        ASF subversion and git services added a comment - Commit 1581164 from Steve Rowe in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1581164 ] SOLR-5734 : move CHANGES.txt entry to 4.7.1 section (merged trunk r1581163)
        Hide
        Steve Rowe added a comment -

        Mark, I think this issue can be resolved?

        Show
        Steve Rowe added a comment - Mark, I think this issue can be resolved?
        Hide
        Steve Rowe added a comment -

        Bulk close 4.7.1 issues

        Show
        Steve Rowe added a comment - Bulk close 4.7.1 issues
        Hide
        Paco Garcia added a comment -

        Hi, with this change our dataimport process is around 15% longer than with 4.7.0 Release.
        From the logs it seems that the connection is closed and reopen in every sql.

        After the change to nanoTime the method getConnection in JdbcDataSource.java is comparing nanos with millis.

        The constant CONN_TIME_OUT must be changed to nanos too.

        private Connection getConnection() throws Exception {
        long currTime = System.nanoTime();
        if (currTime - connLastUsed > CONN_TIME_OUT) {
        synchronized (this)

        { Connection tmpConn = factory.call(); closeConnection(); connLastUsed = System.nanoTime(); return conn = tmpConn; }

        } else

        { connLastUsed = currTime; return conn; }

        }

        private static final long CONN_TIME_OUT = 10 * 1000; // 10 seconds

        Regards

        Show
        Paco Garcia added a comment - Hi, with this change our dataimport process is around 15% longer than with 4.7.0 Release. From the logs it seems that the connection is closed and reopen in every sql. After the change to nanoTime the method getConnection in JdbcDataSource.java is comparing nanos with millis. The constant CONN_TIME_OUT must be changed to nanos too. private Connection getConnection() throws Exception { long currTime = System.nanoTime(); if (currTime - connLastUsed > CONN_TIME_OUT) { synchronized (this) { Connection tmpConn = factory.call(); closeConnection(); connLastUsed = System.nanoTime(); return conn = tmpConn; } } else { connLastUsed = currTime; return conn; } } private static final long CONN_TIME_OUT = 10 * 1000; // 10 seconds Regards
        Hide
        Mark Miller added a comment -

        Can you file a new JIRA issue so we can fix this for a possible 4.7.2 and 4.8?

        Show
        Mark Miller added a comment - Can you file a new JIRA issue so we can fix this for a possible 4.7.2 and 4.8?
        Hide
        Paco Garcia added a comment -
        Show
        Paco Garcia added a comment - SOLR-5954

          People

          • Assignee:
            Mark Miller
            Reporter:
            Mark Miller
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development