Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Analyzer] Analyzer extremely slow #43943

Closed
saltedpotatos opened this issue Oct 27, 2020 · 17 comments
Closed

[Analyzer] Analyzer extremely slow #43943

saltedpotatos opened this issue Oct 27, 2020 · 17 comments
Labels
analyzer-stability area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-intellij Tracking issues for the Dart IntelliJ plugin. closed-stale Closed as the issue or PR is assumed stale P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@saltedpotatos
Copy link

Dart Analyzer performance has really dropped for me recently, in Android Studio and in VS Code.

I am also seeing Android Studio run out of memory and crash, which I think is related, but could be wrong.

In order to have the analyzer pickup a change in a generated file, I have to restart the analysis server.

Looking at analysis diagnostics, across 2200 requests over 28 minutes, my average latency is 641ms, my maximum is 3,446ms, and 54% are greater than 150ms.

If this is better filed elsewhere, please let me know.

I have

  • deleted the ~/.dartServer folder
  • deleted Android Studio and reinstalled, including all plugins
  • Tried VS Code to see if it would perform better
  • Tried the master branch of Flutter
  • Flutter clean, pub get, pub upgrade, etc
  • Dart SDK Version (dart --version) : Dart SDK version: 2.10.2 (stable) (Tue Oct 13 15:50:27 2020 +0200) on "macos_x64"

  • Whether you are using Windows, MacOSX, or Linux (if applicable) : OSX

Analysis_options

include: package:pedantic/analysis_options.yaml

analyzer:
#  enable-experiment:
#    - non-nullable
  errors:
    missing_return: error
    missing_required_param: error
    must_be_immutable: error
  exclude:
    # ignore warnings in files from json_serializable, built_value and most generators
    - "**/*.g.dart"
    # ignore warnings in files generated by Freezed specifically.
    - "**/*.freezed.dart"

Flutter doctor -v

I believe not seeing plugins in AS is a bug at the moment. It does see them on the master branch.

    • Flutter version 1.22.2 at /Users/michael/flutter
    • Framework revision 84f3d28555 (12 days ago), 2020-10-15 16:26:19 -0700
    • Engine revision b8752bbfff
    • Dart version 2.10.2

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/michael/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.9.1

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.1

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

Pubspec dependencies


environment:
  sdk: ">=2.9.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  #  cupertino_icons: ^0.1.2
  json_serializable: ^3.4.1
  path_provider: ^1.6.14
  url_launcher: ^5.4.11
  flutter_cognito_plugin: ^2.2.0
  chopper: ^3.0.3
  logging: ^0.11.4
  flutter_bloc: ^6.0.2
  equatable: ^1.2.4
  geolocator: ^5.3.2+2
  barcode_scan: ^3.0.1
  keyboard_actions: ^3.3.0+1
  flutter_typeahead: ^1.8.8
  font_awesome_flutter: ^8.8.1
  rxdart: ^0.24.1
  package_info: ^0.4.3
  local_auth: ^0.6.3+1
  flutter_secure_storage: ^3.3.3
  shared_preferences: ^0.5.12+2
  provider: ^4.3.2+1
  firebase_crashlytics: ^0.2.1
  firebase_core: ^0.5.0
  firebase_analytics: ^6.0.1
  freezed_annotation: ^0.12.0
  injectable: ^1.0.5
  get_it: ^5.0.1
  mockito: ^4.1.1
  jiffy: ^3.0.1
  kt_dart: ^0.8.0
  dartz: ^0.9.1
  intl: ^0.16.1
  jwt_decoder: ^1.0.1
  flushbar: ^1.10.4




dev_dependencies:
  build_runner: ^1.10.4
  chopper_generator: ^3.0.5
  pedantic: ^1.9.0
  freezed: ^0.12.2
  injectable_generator: ^1.0.6
  flutter_test:
    sdk: flutter

Android Studio idea.log excerpt

2020-10-27 13:46:04,574 [12700541]   INFO - yzer.DartAnalysisServerService - analysis_getImportedElements() took longer than 100ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:04,736 [12700703]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:05,106 [12701073]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:07,359 [12703326]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:07,362 [12703329]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:08,546 [12704513]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:08,546 [12704513]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:10,832 [12706799]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:11,778 [12707745]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:11,778 [12707745]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:22,768 [12718735]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:24,499 [12720466]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:24,499 [12720466]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:24,511 [12720478]   INFO - im.listener.VimListenerManager - Adjust non vim selection change 
2020-10-27 13:46:24,512 [12720479]   INFO - ome.idea.vim.group.ChangeGroup - Reset caret to a block shape 
2020-10-27 13:46:24,614 [12720581]   INFO - up.visual.IdeaSelectionControl - Adjust non-vim selection. Source: MOUSE 
2020-10-27 13:46:25,724 [12721691]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:25,724 [12721691]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:25,724 [12721691]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:26,946 [12722913]   INFO - yzer.DartAnalysisServerService - edit_getAssists() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_bloc.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:28,182 [12724149]   INFO - yzer.DartAnalysisServerService - analysis_getHover() took longer than 1000ms, for file /Users/michael/AndroidStudioProjects/Flutter/flutter_app/lib/application/create_order/create_order_state.dart, Dart SDK version: 2.10.2 
2020-10-27 13:46:43,252 [12739219]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=false 
2020-10-27 13:46:43,255 [12739222]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=true 
2020-10-27 13:46:48,796 [12744763]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=false 
2020-10-27 13:46:48,798 [12744765]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=true 
2020-10-27 13:46:50,947 [12746914]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=false 
2020-10-27 13:46:50,949 [12746916]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=true 
2020-10-27 13:46:54,097 [12750064]  ERROR - llij.ide.plugins.PluginManager - Java heap space 
java.lang.OutOfMemoryError: Java heap space
2020-10-27 13:46:54,098 [12750065]  ERROR - llij.ide.plugins.PluginManager - Android Studio 4.1  Build #AI-201.8743.12.41.6858069 
2020-10-27 13:46:54,098 [12750065]  ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_242-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2020-10-27 13:46:54,098 [12750065]  ERROR - llij.ide.plugins.PluginManager - OS: Mac OS X 
2020-10-27 13:46:55,591 [12751558]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=false 
2020-10-27 13:46:57,133 [12753100]   INFO - .openapi.util.LowMemoryWatcher - Low memory signal received: afterGc=true 
2020-10-27 13:47:02,432 [12758399]   INFO - ction.HeapDumpSnapshotRunnable - HeapDumpSnapshotRunnable started: reason=UserInvoked, analysisOption=SCHEDULE_ON_NEXT_START 
2020-10-27 13:47:02,436 [12758403]  ERROR - llij.ide.plugins.PluginManager - null 
java.lang.NullPointerException
	at com.intellij.diagnostic.hprof.action.HeapDumpSnapshotRunnable.run(HeapDumpSnapshotRunnable.kt:113)
	at com.intellij.diagnostic.OutOfMemoryDialog$3.doAction(OutOfMemoryDialog.java:91)
	at com.intellij.openapi.ui.DialogWrapper$DialogWrapperAction.actionPerformed(DialogWrapper.java:1819)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
	at java.awt.Component.processMouseEvent(Component.java:6550)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3325)
	at java.awt.Component.processEvent(Component.java:6315)
	at java.awt.Container.processEvent(Container.java:2239)
	at java.awt.Component.dispatchEventImpl(Component.java:4899)
	at java.awt.Container.dispatchEventImpl(Container.java:2297)
	at java.awt.Component.dispatchEvent(Component.java:4721)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
	at java.awt.Container.dispatchEventImpl(Container.java:2283)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4721)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
	at java.awt.EventQueue$4.run(EventQueue.java:739)
	at java.awt.EventQueue$4.run(EventQueue.java:737)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:736)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:912)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:844)
	at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:730)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:502)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
	at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
	at java.awt.Dialog.show(Dialog.java:1077)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:708)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:437)
	at com.intellij.openapi.ui.DialogWrapper.doShow(DialogWrapper.java:1685)
	at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1644)
	at com.intellij.diagnostic.DefaultIdeaErrorLogger.lambda$handle$0(DefaultIdeaErrorLogger.java:94)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:847)
	at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:741)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:502)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Thanks!

@vsmenon vsmenon added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Oct 28, 2020
@Dana-Ferguson
Copy link

I am having the same issue in WebStorm with Dart (w/o Flutter).
I tried deleting ~/.dartServer/.analysis-driver/ and it did not solve my issue. I've tried reinstalling programs.

I'm getting the same analyzer response times as described above. I suspected the WebStorm Dart plugin might not work well yet with dart v2.10 -- my issue seems almost exactly the same as above. On my small projects its fine, on large projects, Analyzer is not fine.

I tried to set it up so I can get observatory running on the analyzer to peek at it, but I can't get dart v2.10.2 analyzer to start (which I guess is a separate issue, hasn't worked since the new combined Dart tool came out).

@KrystofM
Copy link

Having the same problem with Android studio, it seems like some kind of extreme memory leak problem. Any news on this issue?

@jonaird
Copy link

jonaird commented Feb 1, 2021

I am also having this issue in VSCode. It seems to be way worse in projects where there I have documented a lot of the code with triple-slash comments. I have to wait many seconds every time I write any new code for the analyzer.

@saltedpotatos
Copy link
Author

saltedpotatos commented Feb 9, 2021

Just chiming back in that this is still an issue with out of memory warnings / crashes in android studio in the most recent stable flutter version.

Potentially unrelated, but my auto complete / auto suggest ( ctrl - space) stopped working, potentially when I upgraded to dart 2.10? But it's been so long that I can't say for certain.

This was caused by OSX intercepting ctrl-space as a default keybind to cycle through input sources.

Flutter doctor

[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2 20D64 darwin-x64, locale en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.53.0)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

Dart plugin version: 201.9317
Flutter plugin version: 53.1.1

@izznfkhrlislm
Copy link

I am also having this issue both in Android Studio and VSCode. Temporarily solved the issue by increasing the Android Studio's custom VM options to -Xmx4096m in Help -> Edit Custom VM Options

@noskap
Copy link

noskap commented Apr 23, 2021

Same issue in Android Studio after upgrading to Flutter 2

@liempo
Copy link

liempo commented May 17, 2021

Bug still exists in Flutter (Channel stable, 2.0.6, on macOS 11.1 20C69 darwin-x64, locale en-PH)

@jcollins-g jcollins-g added area-intellij Tracking issues for the Dart IntelliJ plugin. P2 A bug or feature request we're likely to work on labels Sep 1, 2021
@WidarVauth
Copy link

WidarVauth commented Dec 16, 2022

hello any news on this problem ?
my analyzer is very slow when there is too much line I increased the ram to 4giga but it does not change anything
(config: Mac m1pro 32g ram)
if I press on another window during the analysis then it suddenly becomes fast

exemple:
1 I'm on my homepage with lot of line, I have to wait several seconds after each word I write or make a right click to see Show context action.

2 I open my Main (which has only a few lines)

3 I put the two windows next to each other.

4 I repeat action 1
but within the millisecond after writing. With my mouse I go to my main window and left click on it.Ssuddenly analyzing it ends up on HomePage

I don't understand we have 10 pc in the office and they all have the same problem.

@ZiyadF296
Copy link

Any updates on issues related to analyzer performance? Performance is very degrading and sometimes hangs causing me to have to restart and wait for the analyzer to re-analyze the entire project. Bigger projects crossing 50K LOC take a considerable amount of time to analyze.

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 13, 2024
@mocki-toki
Copy link

I think my case is rare, but removing the dart_code_metrics package helped me. it is a plugin for the dart linter and for some reason slows down the analyzer a lot, especially in the monorepo

@bwilkerson
Copy link
Member

At least part of the performance issues appears to be the number of analysis contexts that are created in order to perform analysis. We are actively working on two independent but related changes that should help reduce the number of contexts that get created. (You can think of an analysis context as a region of the file system in which every .dart file can be analyzed with the same 'metadata'.)

For example, we currently create a new context whenever the code needs to be analyzed with a different analysis_options.yaml file. For example, if you have an analysis options file in the root of a package, and a separate analysis options file in the test directory, this will currently cause two contexts to be created.

The first change will make it possible to use a single context to analyze a whole package even when there are multiple analysis options files in the package. The hope is that this will help some users, but it is also a necessary step to allow the second change.

The second change is to add support to both the analyzer and to pub to better support the notion of a monorepo. The expectation is that this will allow us to create a single context for the entire monorepo, which ought to significantly improve the performance for projects that are using monorepos.

@ZiyadF296
Copy link

Looking forward to seeing improvements.

@incendial
Copy link
Contributor

and for some reason slows down the analyzer a lot

This is a known issue with the plugins and affects all plugins. If you still want to use DCM, consider trying the standalone version (not the package) as it doesn't have this issue.

@AndryHTC
Copy link

AndryHTC commented Oct 2, 2024

What I really love about Dart is the DX.
90% of the DX comes from inspecting methods/attributes directly with autocomplete, and knowing if what you are writing is correct.

The Dart and Flutter community knows this so well that they develop packages with this mental pattern.

Fast static analysis is necessary and must be a priority for Dart.
💕

@mraleph
Copy link
Member

mraleph commented Oct 3, 2024

@saltedpotatos what is your current experience with analyzer performance? (if you are still writing Dart code).

@saltedpotatos
Copy link
Author

Hi @mraleph

I currently have no complaints with the analyzer performance. (and am still writing Dart code).

As an aside, I also enjoyed watching the talk you gave at Flutter & Friends '24

@mraleph
Copy link
Member

mraleph commented Oct 8, 2024

Thanks! I am going to close this issue then. If you start experiencing some issues with analyzer again - please don't hesitate to file another issue.

PS. Happy you liked the talk.

@mraleph mraleph closed this as completed Oct 8, 2024
@mraleph mraleph added the closed-stale Closed as the issue or PR is assumed stale label Oct 8, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
analyzer-stability area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-intellij Tracking issues for the Dart IntelliJ plugin. closed-stale Closed as the issue or PR is assumed stale P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests