Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How IntelliJ IDEA Performance Improved: Past, P...

How IntelliJ IDEA Performance Improved: Past, Present, and Future

Yuriy Artamonov

October 27, 2024
Tweet

More Decks by Yuriy Artamonov

Other Decks in Programming

Transcript

  1. APDEX (Application Performance Index) metric indicates the performance status. In

    other words, it reflects user satisfaction with the duration of application processes. Different categories indicate different APDEX ranges. It is common to set the following thresholds for APDEX categories: APDEX
  2. (Mega)APDEX converts many measurements into one number on a uniform

    scale of 0-to-1, where 0 = no users satisfied with any events, 1 = all users satisfied with all events. It is based on counts of "satisfied," "tolerating," and "frustrated" events. MegaAPDEX
  3. All JetBrains IDEs log a lot of numbers about their

    internal life. Those numbers (Metrics) are stored in the <logs> folder, in a plain CSV format. In the same <logs> folder there is a simple yet powerful html dashboard/visualizer for that data -- it takes ~15 seconds to get timeseries plotted. Powered by https://opentelemetry.io OpenTelemetry
  4. A long time ago in a galaxy far, far away....

    There was Dependency Injection pattern • ProjectComponent • ApplicationComponent • Contructor injection Use @Service locator instead! Components and Dependency Injection
  5. At the moment, IDEA requires about 50k JVM classes to

    start with typical project. How to find reasons: • YourKit - Events / Classloading • JVM TI agent ! (in tests) Class loading and eager init
  6. Improved multi-threaded indexing Multi-thread indexing spending 25% of time waited

    for a lock to perform mapReduce of the indexing data:
  7. Indexing of library sources Downloading sources of libraries disabled by

    default for IntelliJ IDEA 2023.3 led to improvements in indexing:
  8. Actions: - Search for Classes and Symbols - Completion -

    Build - Run - Generate… Actions available during indexing
  9. Code completion in Kotlin files gets faster thanks to ML

    technologies . The idea is that the ML model reorders CompletionContributors, prioritizing the most relevant contributors. This approach aims to accelerate the retrieval of the correct element and open the lookup window faster. The megaAPDEX score for code completion has jumped from 0.71-0.76 to a remarkable 0.81-0.85. Kotlin and Turbo Complete
  10. Language injections is a sophisticated mechanism that enables JetBrains IDEs

    to integrate fragments of code into String literals of another language. Sometimes, highlighters of languages use ineffective resolve() and this could lead to stuck highlighting. Story of Java and JPQL
  11. Azure Pipelines Schema: https://schema.management.azure.com/schema s/2015-01-01/deploymentTemplate.json Parsing switched from PSI to

    Jackson, mostly to improve memory consumption, but it led to big improvements in speed as well. JSON Schema drama
  12. IntelliJ IDEA is built around single lock: com.intellij.openapi.application.impl. ReadMostlyRWLock Operations:

    • Write (exclusive) - happens on Event Dispatch Thread at the moment • Read (parallel) - blocking or non-blocking • Read with write priority AWT, EDT, and locks Drama of concurrency and UI
  13. Every button, menu, shortcut handler is Action. Action provides 2

    operations: • update • actionPerformed Both may need Event Dispatch Thread. But now, most of them update in parallel in coroutines! Actions, context menus and coroutines
  14. VFS (Virtual File System) is an abstraction layer for IDE

    to work with various files in unified way. This structure maintains consistency guarantees for ReadWriteLock which sometimes lead to freezes. What we improved: • Introduced prefetech • Implemented asynchronous processing in workspace model VFS synchronization
  15. • Stopped putting IDEA in dumb mode for the whole

    sync duration. • Workspace model API significantly improved batch update performance in one of the sync post-processing jobs. • Since version 7.4+, Gradle provides an internal API that runs some sync steps in parallel. We started to use this API Importing Gradle projects
  16. • Switched to parallel dependencies and plugin resolution. • Optimized

    generation of sources. Improved UI memory consumption. • Rolled out workspace-model-based Maven sync. These improvements have contributed to a significant improvement of Maven sync MegaAPDEX in 2023.2 Maven import improvements
  17. With its new K2 mode, IntelliJ IDEA can now use

    the embedded K2 Kotlin compiler for analyzing Kotlin code. The K2 Kotlin compiler is being rewritten from the ground up, so we migrated the Kotlin code support in IntelliJ IDEA as well. The performance and stability of the code highlighting and code completion have been significantly improved, but not all IDE features are supported yet. Word on Kotlin K2
  18. Integration and unit performance tests let us detect performance degradation

    after we switched the default JBR from the 17 to 21 version at the beginning of January (JBR-6474). We reverted to JBR 17 and started an investigation of this performance problem. Problems: • Garbage Collection • Just-In-Time Compiler (-XX:CICompilerCount=2) What happened to JBR 21
  19. Profilers: • IntelliJ Profiler (CPU, memory allocations, heap dumps) •

    YourKit (CPU, memory, classloading) • JVM TI agents (classloading) Tools
  20. Reporting performance problems - https://intellij-support.jetbrains.com/hc/en-us/arti cles/207241235-Reporting-performance-problems We appreciate a lot:

    • CPU snapshots • Thread dumps and freeze reports from logs/ • Heap dumps The team reads and checks all of them! How you can help