Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8072692

Improve performance of SecurityManager.checkPackageAccess

    Details

    • Subcomponent:
    • Resolved In Build:
      b70
    • Verification:
      Verified

      Backports

        Description

        The package matching algorithm in the checkPackageAccess method can be optimized in several ways to improve performance:

        1. Restricted packages that are longer than the package being checked can be skipped; there is no need to compare them since they will never match
        2. A more efficient algorithm can be used when checking if the packages are equal to each other

          Issue Links

            Activity

            Hide
            mullan Sean Mullan added a comment -
            The improvement includes skipping restricted packages that are longer than the package being checked, and a few other optimizations.

            Results of the CheckPackageAccess jmh benchmark
            # Warmup: 5 iterations, 1 s each
            # Measurement: 10 iterations, 1 s each
            # Timeout: 10 min per iteration
            # Threads: 5 threads, will synchronize iterations

            Before fix:

            Benchmark Mode Samples Score Error Units
            o.o.b.j.l.SecurityManager.CheckPackageAccess.checkPackageAccess thrpt 20 26479.879 ± 692.491 ops/s

            After fix:

            Benchmark Mode Samples Score Error Units
            o.o.b.j.l.SecurityManager.CheckPackageAccess.checkPackageAccess thrpt 20 141873.894 ± 3130.127 ops/s
            Show
            mullan Sean Mullan added a comment - The improvement includes skipping restricted packages that are longer than the package being checked, and a few other optimizations. Results of the CheckPackageAccess jmh benchmark # Warmup: 5 iterations, 1 s each # Measurement: 10 iterations, 1 s each # Timeout: 10 min per iteration # Threads: 5 threads, will synchronize iterations Before fix: Benchmark Mode Samples Score Error Units o.o.b.j.l.SecurityManager.CheckPackageAccess.checkPackageAccess thrpt 20 26479.879 ± 692.491 ops/s After fix: Benchmark Mode Samples Score Error Units o.o.b.j.l.SecurityManager.CheckPackageAccess.checkPackageAccess thrpt 20 141873.894 ± 3130.127 ops/s
            Hide
            mullan Sean Mullan added a comment -
            Attached is a chart comparing the performance of SecurityManager.checkPackageAccess(String) before and after the fix with various numbers of threads. The system under test was Intel® Core™ i5-2520M CPU @ 2.50GHz × 4 running Ubuntu 14.04 LTS. Throughput is increased 5-7 times depending on the number of threads.
            Show
            mullan Sean Mullan added a comment - Attached is a chart comparing the performance of SecurityManager.checkPackageAccess(String) before and after the fix with various numbers of threads. The system under test was Intel® Core™ i5-2520M CPU @ 2.50GHz × 4 running Ubuntu 14.04 LTS. Throughput is increased 5-7 times depending on the number of threads.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/935d2b780095
            User: mullan
            Date: 2015-06-17 19:48:40 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/935d2b780095 User: mullan Date: 2015-06-17 19:48:40 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/935d2b780095
            User: lana
            Date: 2015-06-20 18:08:09 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/935d2b780095 User: lana Date: 2015-06-20 18:08:09 +0000

              People

              • Assignee:
                mullan Sean Mullan
                Reporter:
                mullan Sean Mullan
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: