Spring Framework
  1. Spring Framework
  2. SPR-9781

ResourceDatabasePopulator incredibly slow on JDK 1.7.0_06 or newer

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.1.3, 3.2 M2
    • Component/s: Data:JDBC
    • Labels:
    • Last commented by a User:
      false

      Description

      I get a signifcant speed regression using the ResourceDatabasePopulator to load database scripts, when I switch from oracle JDK 1.7.0_05 to 1.7.0_06 or _07 on Windows XP SP3. With JDK 1.7.0_05 the script loads in 337ms with 1.7.0_06 or newer it takes over 40000ms to load the same script.

      According to my tests the regression is located in the splitSqlScript(script, delimiter, statements) method.

      1. mvn_output_jdk1.7.0_05.txt
        7 kB
        Philipp Hügelmeyer
      2. mvn_output_jdk1.7.0_07.txt
        6 kB
        Philipp Hügelmeyer

        Activity

        Hide
        Philipp Hügelmeyer added a comment -

        Testcase can be found under https://github.com/hygl/SRP-9781

        Show
        Philipp Hügelmeyer added a comment - Testcase can be found under https://github.com/hygl/SRP-9781
        Hide
        Philipp Hügelmeyer added a comment -

        Output of maven for jdk 1.7.0_05 and 1.7.0_07

        Show
        Philipp Hügelmeyer added a comment - Output of maven for jdk 1.7.0_05 and 1.7.0_07
        Hide
        Oliver Gierke added a comment -

        I've debugged it further and the issue seems to be with String.substring(…) called from ResourceDatabasePopulator.splitSqlScript(…) the final bottleneck being Arrays.copyOfRange.

        The has been a bug reported against that method for Java versions < 7u06, which was fixed with u06 which might cause the issue as the fix touches that method and was introduced in the version that seems to be the first one with the symptoms the original poster describes.

        Show
        Oliver Gierke added a comment - I've debugged it further and the issue seems to be with String.substring(…) called from ResourceDatabasePopulator.splitSqlScript(…) the final bottleneck being Arrays.copyOfRange . The has been a bug reported against that method for Java versions < 7u06, which was fixed with u06 which might cause the issue as the fix touches that method and was introduced in the version that seems to be the first one with the symptoms the original poster describes.
        Hide
        Oliver Gierke added a comment -

        Here seems to be another hint on why this was introduced… an "optimization" in the String class: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html

        Show
        Oliver Gierke added a comment - Here seems to be another hint on why this was introduced… an "optimization" in the String class: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
        Hide
        Oliver Gierke added a comment -
        Show
        Oliver Gierke added a comment - Pull request submitted: https://github.com/SpringSource/spring-framework/pull/143
        Hide
        Chris Beams added a comment -
        commit 3fb3b7d67a2a0b6990ad17978877a552d03f7b81
        Author: Oliver Gierke <ogierke@vmware.com>
        Commit: Chris Beams <cbeams@vmware.com>
        
            Work around JDK7 String#substring performance regression
            
            String#substring has become significantly slower as of JDK 1.7.0_06 [1],
            such that there are performance degradations by a factor of 100-1000 in
            ResourceDatabasePopulator, especially for large SQL files.
            
            This commit works around this problem by minimizing the substring scope
            to the least amount possible to prevent unnecessary internal copying of
            strings (which seems to cause the issue).
            
            [1]: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
            
            Issue: SPR-9781
        
        Show
        Chris Beams added a comment - commit 3fb3b7d67a2a0b6990ad17978877a552d03f7b81 Author: Oliver Gierke <ogierke@vmware.com> Commit: Chris Beams <cbeams@vmware.com> Work around JDK7 String#substring performance regression String#substring has become significantly slower as of JDK 1.7.0_06 [1], such that there are performance degradations by a factor of 100-1000 in ResourceDatabasePopulator, especially for large SQL files. This commit works around this problem by minimizing the substring scope to the least amount possible to prevent unnecessary internal copying of strings (which seems to cause the issue). [1]: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html Issue: SPR-9781

          People

          • Assignee:
            Oliver Gierke
            Reporter:
            Philipp Hügelmeyer
            Last updater:
            Chris Beams
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 32 weeks, 2 days ago