Skip to content

Instantly share code, notes, and snippets.

@johnzweng
Last active June 3, 2020 06:14
Show Gist options
  • Save johnzweng/68253d84ddf6dee908918851808c20f1 to your computer and use it in GitHub Desktop.
Save johnzweng/68253d84ddf6dee908918851808c20f1 to your computer and use it in GitHub Desktop.

Analyze IDEA Performance Issues:

January 10, 2019

Setup:

  • IDEA Version and JVM runtime (JVM is the bundled one by JetBrains):

    IntelliJ IDEA 2018.3.3 (Ultimate Edition)
    Build #IU-183.5153.38, built on January 9, 2019
    JRE: 1.8.0_152-release-1343-b26 x86_64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    macOS 10.13.6
    

    IDEA installed via JetBrain Toolbox

  • Custom VM settings: cat $HOME/Library/Preferences/IntelliJIdea2018.3/idea.vmoptions :

    # custom IntelliJ IDEA VM options
    
    -Xms128m
    -Xmx3000
    -XX:ReservedCodeCacheSize=240m
    -XX:+UseCompressedOops
    -Dfile.encoding=UTF-8
    -XX:+UseConcMarkSweepGC
    -XX:SoftRefLRUPolicyMSPerMB=50
    -ea
    -Dsun.io.useCanonCaches=false
    -Djava.net.preferIPv4Stack=true
    -Djdk.http.auth.tunneling.disabledSchemes=""
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:-OmitStackTraceInFastThrow
    -Xverify:none
    
    
    -XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
    -XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
    
    
    
  • No JavaFX involved: jstack <IDE pid> | grep -i Renderer

  • Mac Hardware:

    • Macbook Hardware:

      • MacBook: MacBook Pro (Retina, 13-inch, Early 2015)
      • Processor: 3.1 GHz Intel Core i7
      • Memory: 16 GB 1867 MHz DDR3
      • Graphics: Intel Iris Graphics 6100 1536 MB
    • Display(s): system_profiler SPDisplaysDataType

      Graphics/Displays:
      
          Intel Iris Graphics 6100:
      
            Chipset Model: Intel Iris Graphics 6100
            Type: GPU
            Bus: Built-In
            VRAM (Dynamic, Max): 1536 MB
            Vendor: Intel
            Device ID: 0x162b
            Revision ID: 0x0009
            Metal: Supported, feature set macOS GPUFamily1 v3
            Displays:
              Color LCD:
                Display Type: Built-In Retina LCD
                Resolution: 2560 x 1600 Retina
                Framebuffer Depth: 24-Bit Color (ARGB8888)
                Mirror: Off
                Online: Yes
                Rotation: Supported
                Automatically Adjust Brightness: No
              LG Ultra HD:
                Resolution: 3840 x 2160 (2160p 4K UHD - Ultra High Definition)
                UI Looks like: 3840 x 2160 @ 60 Hz
                Framebuffer Depth: 24-Bit Color (ARGB8888)
                Main Display: Yes
                Mirror: Off
                Online: Yes
                Rotation: Supported
                Automatically Adjust Brightness: No
                Connection Type: DisplayPort
      
      
    • But I also tested without external displays, only with Default for display resolution setting: Output of system_profiler SPDisplaysDataType:

      Graphics/Displays:
      
          Intel Iris Graphics 6100:
      
            Chipset Model: Intel Iris Graphics 6100
            Type: GPU
            Bus: Built-In
            VRAM (Dynamic, Max): 1536 MB
            Vendor: Intel
            Device ID: 0x162b
            Revision ID: 0x0009
            Metal: Supported, feature set macOS GPUFamily1 v3
            Displays:
              Color LCD:
                Display Type: Built-In Retina LCD
                Resolution: 2560 x 1600 Retina
                Framebuffer Depth: 24-Bit Color (ARGB8888)
                Main Display: Yes
                Mirror: Off
                Online: Yes
                Rotation: Supported
                Automatically Adjust Brightness: No
      

PROBLEM

Font rendering seems to use a lot of CPU cycles. I tested in a new project, in a newly created (empty) Text-File (test.txt) to rule out issues with code completion, etc.

When pressing (and keeping pressed) a single letter on the keyboard, the CPU load goes up and in some cases (IDEA in fullscreen on high resolution display) IDEA cannot keep up with rendering the letters in the speed it gets typed.

When I stop pressing the key, IDEA takes several seconds to catch up, until all the text is finally rendered. The CPU load goes down again immediately afterwards.

While it is pretty clear to see how the CPU load goes up with a single key-press and goes down immediately afterwards, I'm not sure if this is the root problem.

Interesting:

When I use an external 4K display on full resolution (display's native resolution), the CPU load seems to be less than when using a scaled (lower) resolution, but the lagging seems to be worse using the 4k display?

I also used "Quartz Debug" (from the "Graphics Tools for Xcode" package, see also here) to check when and what IDEA is redrawing.

It seems that IDEA is always (on each typing, on each caret blink, ..) redrawing the whole UI (not only the editor part). (see video below)

Tried actions:

  • File -> Invalidate Caches and Restart

    • didn't notice any difference
  • Preferences - > Appearance -> Antialiasing (IDE and Editor) -> "Grayscale" and also tried "No antialiasing"

    • maybe a little bit better? But might also be placebo (when holding down a single letter in keyboard, CPU load goes still to
  • Tested settings (which didn't seem to have an effect for this issue)

  • tried enabling Java2D tracing:

    • -Dsun.java2d.trace=log,ptime,name:OGLTR_AddToGlyphCache,out:/tmp/java2d_trace.txt
    • -Dsun.java2d.trace=log,timestamp,ptime,out:/tmp/java2d_trace.txt,verbose
  • Installed JB SDK Bintray Downloader plugin and for testing switched back to exactly the 1.8.0_152-release-1248-b8 runtime JetBrains runtime version as the Realease Notes of 1.8.0_152-release-1248-b8 x86_64 indicate that JRE-526 got fixed? Seems to be similiar to current JRE version.

Videos:

References:

Support

Found Issues on Issue Tracker and forums

Run IDEA from commandline (on macos)

cd "$HOME/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.4886.37/IntelliJ IDEA.app/Contents/MacOS"
export _JAVA_OPTIONS='-Dsun.java2d.opengl=false'
./idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment