Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45915

Make Jenkins use more efficient Java 8 Base64 Decoder for ConsoleNotes

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • core

      We've observed that high CPU load for one user reading consoleText via Run#doConsoleText, which showed a bottleneck in decoding Base64:

      at org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:387)
      {{ at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:697)}}
      {{ at hudson.util.UnbufferedBase64InputStream.read(UnbufferedBase64InputStream.java:41)}}
      {{ at hudson.util.UnbufferedBase64InputStream.read(UnbufferedBase64InputStream.java:53)}}
      {{ at java.io.DataInputStream.read(Unknown Source)}}
      {{ at java.io.DataInputStream.readFully(Unknown Source)}}
      {{ at hudson.util.IOUtils.skip(IOUtils.java:87)}}
      {{ at hudson.console.ConsoleNote.skip(ConsoleNote.java:286)}}
      {{ at hudson.console.PlainTextConsoleOutputStream.eol(PlainTextConsoleOutputStream.java:68)}}
      {{ at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)}}
      {{ at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)}}
      {{ at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)}}
      {{ at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1793)}}
      {{ at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)}}
      {{ at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)}}
      {{ at hudson.model.Run.doConsoleText(Run.java:2090)}}

      Looking at the implementation here, Java 8 provides a much much efficient Base64 decoder implementation, which has been benchmarked as 2x-3x as fast:

      http://java-performance.info/base64-encoding-and-decoding-performance/

      https://aws.amazon.com/blogs/developer/follow-up-on-base64-codec-performance/

      JENKINS-43780 should cover most of the uses of the Trilead Base64 implementations

          [JENKINS-45915] Make Jenkins use more efficient Java 8 Base64 Decoder for ConsoleNotes

          Code changed in jenkins
          User: Sam Van Oort
          Path:
          core/src/main/java/hudson/util/UnbufferedBase64InputStream.java
          http://jenkins-ci.org/commit/jenkins/7550d796b36511b8f30efbe5f617016c4930dbf9
          Log:
          JENKINS-45915 - Switch to the Java8 Base64 rather than Apache commons (#2958)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sam Van Oort Path: core/src/main/java/hudson/util/UnbufferedBase64InputStream.java http://jenkins-ci.org/commit/jenkins/7550d796b36511b8f30efbe5f617016c4930dbf9 Log: JENKINS-45915 - Switch to the Java8 Base64 rather than Apache commons (#2958)

          Oleg Nenashev added a comment -

          The fix has been released in 2.73

          Oleg Nenashev added a comment - The fix has been released in 2.73

            svanoort Sam Van Oort
            svanoort Sam Van Oort
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: