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

AES microbenchmark unnecessarily allocates memory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • performance
    • None

      The AES microbenchmark in openjdk/bench/javax/crypto/AES.java tests the performance on Cipher.doFinal(byte[]). This method allocates an array and returns it. AES is very fast due to the use of specialized instructions, and so the time required to allocate (and later collect) these arrays ends up being a significant fraction of the total execution time for this benchmark. As a result, this test gives somewhat misleading results.

      It would be better to allocate an array during setup and reuse it by calling Cipher.doFinal(byte[], int, int, byte[]). Also see if this pattern is repeated for other Cipher benchmarks.

            apetcher Adam Petcher (Inactive)
            apetcher Adam Petcher (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: