Share
Embed
Transcript
34 slides
-
How IntelliJ IDEA Performance Improved: Past, Present, and Future Yuriy
Artamonov Product Manager -
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 -
(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 -
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 -
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 -
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 -
Improved multi-threaded indexing Multi-thread indexing spending 25% of time waited
for a lock to perform mapReduce of the indexing data: -
Indexing of library sources Downloading sources of libraries disabled by
default for IntelliJ IDEA 2023.3 led to improvements in indexing: -
Actions: - Search for Classes and Symbols - Completion -
Build - Run - Generate… Actions available during indexing -
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 -
Highlighting in reopened files loaded from disk cache and shown
immediately! Cached Editor Markup -
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 -
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 -
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 -
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 -
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 -
• 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 -
• 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 -
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 -
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 -
Profilers: • IntelliJ Profiler (CPU, memory allocations, heap dumps) •
YourKit (CPU, memory, classloading) • JVM TI agents (classloading) Tools -
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