1 / 27

IntelliJ IDEA Architecture and Performance

IntelliJ IDEA Architecture and Performance. Dmit ry Jemerov Development Lead JetBrains, Inc. ht tp://www.jetbrains.com/. Learn about performance optimization techniques used in IntelliJ IDEA Understand the factors affecting IntelliJ IDEA performance in normal use. Agenda.

ryan-gibson
Download Presentation

IntelliJ IDEA Architecture and Performance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IntelliJ IDEA Architecture and Performance Dmitry Jemerov Development LeadJetBrains, Inc.http://www.jetbrains.com/

  2. Learn about performance optimization techniques used in IntelliJ IDEA • Understand the factors affectingIntelliJ IDEA performance in normal use

  3. Agenda Elements of Architecture Performance Tips

  4. Component Model • Hierarchy of PicoContainer containers • 3 levels of components: application, project and module • Components have strictly defined lifecycle • Registration through XML configuration files (typically)

  5. Services: Lazy Loading • No strict lifecycle: loaded on demand • Key for loading service is FQN of service interface • Not even classloading happens before service is accessed • Service may have persistent settings which are automatically loaded on instantiation

  6. Disposer Hierarchy • Tree of dependencies between objects • Disposing of parent object also disposes of all its children • Relationships stored outside of object: no common base class required • Typical actions on dispose: • Detaching listeners • Stopping timers/background threads • UI component cleanup

  7. Persistent File System • Complete snapshot of files under project stored in single file • Improves startup performance • Directory tree walk is very expensive, especially on Windows • Provides old content when file is changed • Required for update of indexes • Supports custom persistent attributes

  8. File System Synchronization • On startup, background synchronization of all files under project is performed • Watching for file system notifications • ReadDirectoryChangesW() on Windows • /dev/fsevents on Mac (fslogger) • Linux has no API for recursive watching, requires keeping a file handle for every directory under project

  9. Indexing Framework • Indexer builds list of key/value pairs from file content • Keys and values are arbitrary beans • Indexer provides binary serialization for keys and values • Application-level • same file under different projects indexed only once

  10. Indexing Framework Usages • Word index • Key: hashcode of word • Value: occurrence mask • identifier, comment, string literal • Used for Find in Path, Find Usages etc. • TODO index • File name index • etc.

  11. PSI • Program Source Interface • Read/write access to program syntax tree • From directories down to individual tokens • Works across languages • Some elements (whitespace, comment etc.) used by all languages

  12. Building PSI from Source • Lexer produces stream of tokens • Lexers usually generated with Flex • Parser builds syntax tree • Usually hand-written recursive descent • Table-driven parsers seldom provide adequate error recovery • Language creates PSI elements for syntax tree nodes

  13. Updating PSI • Syntax highlighting based on lexer • Synchronous and incremental • PSI updates triggered by background analysis • Starts after 300 ms of inactivity • Cancelled by next user action • Syntax tree (AST) is built for entire file • PSI is replaced for changed parts of AST

  14. PSI Stubs • Compact binary serialization of externally visible interface of file • Can be provided for any language • Must be sufficient for resolving imported declarations without parsing imported files • PSI elements can exist in two modes: stub-based and AST-based • Switching from stubs to AST is transparent for the client

  15. Stub Indexes • For a stub element, a number of keys for different indexes can be provided • PSI elements can then be retrieved by such keys • Sample indexes: • Classes by name (Goto Class) • Symbols by name (Goto Symbol) • Classes by superclass name (Goto Implementations)

  16. Background Analysis • Multiple passes with different priorities • Faster analysis performed first • Separate high-priority passes for highlighting only visible area • Minimum affected scope is re-analyzed after change • Cancellation on user activity • Cancellation flag checked in many low-level operations, exception thrown and caught on top level

  17. Multi-Core Support • Inspections: Different inspections for same file run in parallel on multiple cores • Find Usages: Different occurrences of target identifier are checked in parallel • JobScheduler API • Starts # of threads depending on # of available CPU cores • Distributes work units between threads • Waits until all work units processed

  18. Multi-Core Support Challenges • Deadlocks • Lock ordering policies must be followed consistently • Lock contention • Lock granularity must be reduced to ensure that all threads can run in parallel • YourKit used for profiling • Creating too many sync objects • Lock pooling: fixed size pool of locks evenly distributed between all objects

  19. Agenda Elements of Architecture Performance Tips

  20. Performance Tips: System • IDEA is heavily IO-bound • Do not store sources, caches or system directories on network drives • Disable antivirus scanning for system directory • Regularly run disk defragmenter • Turn off Windows System Restore

  21. Performance Tips: JVM • Use JDK 6 • In –server mode, increasing –Xmx helps IDEA’s caches live longer • Parallel GC helps on multicore machines • However: May cause stability issues. YMMV.

  22. Performance Tips: IDE • Use latest version • Disable unused plugins • Exclude unneeded folders • Set version control to None for generated code • Avoid large number of unversioned files

  23. Performance Tips: IDE (2) • Do not disable “Synchronize files on frame activation” • Switch Project view to “Project” rather than “Packages” • Disable expensive inspections • Disable framework-specific validation on Make • Do not use method breakpoints

  24. Reporting Performance Issues • Enable built-in YourKit profiling • -agentlib:yjpagent in idea.exe.vmoptions • On by default in EAP builds • Capture snapshot • Create JIRA issue and attach snapshot • http://www.jetbrains.net/jira • Also possible to use standalone YourKit • For example, for startup profiling

  25. For More Information • IntelliJ IDEA: • http://www.jetbrains.com/idea/ • Plugin Development Kit: • http://www.jetbrains.com/idea/plugins/plugin_developers.html • Discussion forums: • http://www.intellij.net/forums/

  26. Q&A Dmitry Jemerov yole@jetbrains.com

  27. IntelliJ IDEA Architecture and Performance Dmitry Jemerov Development LeadJetBrains, Inc.http://www.jetbrains.com/

More Related