JDK-8072692 : Improve performance of SecurityManager.checkPackageAccess
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: java.security
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-02-06
  • Updated: 2016-08-24
  • Resolved: 2015-06-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b70Fixed
Related Reports
Relates :  
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
Comments
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.
16-06-2015

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
06-02-2015