Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prime Number Cache Performance Testing Improvement #21

Merged
merged 11 commits into from
Jul 7, 2021

Conversation

DK96-OS
Copy link
Owner

@DK96-OS DK96-OS commented Jul 5, 2021

Improve performance testing by recording small, independent time measurements, and then performing statistical analysis to determine the reliability of each measurement.

* Rely on Statistics package for calculating StandardDeviation, eliminate duplicated code
* Extract targetedAccessTest from BytePrimeCacheTest

Update BytePrimeCacheTest:
* Refactor prime number list to be public and static, accessible from PerformanceTest class
* Add Statistics import for easy data summary
* Create FindPrime method test case, which collects nanosecond time measurements for various prime number search cases
* Code style / format correction
@DK96-OS DK96-OS added bug Something isn't working documentation Improvements or additions to documentation labels Jul 5, 2021
@DK96-OS DK96-OS self-assigned this Jul 5, 2021
* Create Print function for processing and displaying time results
* Improve FindPrime Test stability by wrapping in a coroutine
* Refactor TargetedAccess Test to use new measurement process
* Fix PrintTestResults, now removing the 3 longest measurements
* Wrapped TargetedAccess Test in coroutines
* Create IsPrime Test case with a range of parameters
* Add more Parameters to existing test cases to collect more data, doubling certain parameters with a high variance
@DK96-OS
Copy link
Owner Author

DK96-OS commented Jul 6, 2021

GitHub Actions Test Results Accuracy Issue

Performance testing using Kotlin's built in measureNanoTime function provides highly accurate and reliable time measurements for blocks of code.
This has been demonstrated offline using OpenJDK 11, however it appears that on GitHub, the measureNanoTime function returns values that are multiples of 100, or 0.
TestTargetedAccessJuly6_2021_12_25
Table 1: TargetedAccess Test Measurements The most recent GitHub Actions Test report for PrimeCachePerformanceTest, showing the TargetedAccess Test output.
This occurs in both Java 8 and Java 11 Test Reports.

Implications

Without a common reliable computing resource, reproducibility is a challenge. Comparing results between changes over time will require consideration of the system running the tests, which unfortunately will not be GitHub.

Potential Resolutions

One way that this could be resolved, is to investigate alternative OpenJDK distributions available in GitHub Actions. Another is to try to use a newer version of OpenJDK.

* Remove Coroutines after determining that they have no visible impact on the test results
* Cleanup unused imports, including removing assertions, as this test class is not concerned with correctness
* Add Java versions 14, 15, 16
* Remove unused import
@DK96-OS
Copy link
Owner Author

DK96-OS commented Jul 6, 2021

Java Version Performance Comparison

While the precision of each measurement is still limited to 100 nanoseconds by GitHub actions, there are noteable differences between Java versions.
PrimeCachePerformanceGraph
Table 2 : Prime Cache Performance Across Java Versions This graph shows the output results for TargetedIndex Test, for versions 11, 14, 15, and 16. Version 8 is shown in the legend, but this data was not included in the graph.

Java version 14 is clearly the performance winner, with 15 in second place. Version 16 delivers the worst performance overall, but appears to be more stable than 11. With monotonically increasing measurements, there are no spikes in performance at specific target indices, which cannot be said for any other version.

@DK96-OS
Copy link
Owner Author

DK96-OS commented Jul 7, 2021

Consider that:

  • 11 is the latest LTS release
  • 16 is the latest available stable version
  • 8 is gradually declining in popularity

These statements, while true, justify removing support for 8, and adding support for 16.

* Remove java version 8, add version 16
@DK96-OS DK96-OS merged commit 002464a into master Jul 7, 2021
@DK96-OS DK96-OS deleted the primes-performance branch July 7, 2021 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant