|
| 1 | +--- |
| 2 | +title: Troubleshoot analyzer performance |
| 3 | +description: >- |
| 4 | + Learn how to diagnose and resolve common |
| 5 | + Dart analysis server performance issues. |
| 6 | +--- |
| 7 | + |
| 8 | +This guide helps you diagnose and resolve common Dart analysis server |
| 9 | +performance issues in your Dart or Flutter IDE. |
| 10 | + |
| 11 | +## Known performance issues |
| 12 | + |
| 13 | +Several common issues significantly hurt the performance of |
| 14 | +the Dart analysis server (the analyzer). |
| 15 | +Check the following issues to see if they might be impacting |
| 16 | +your development environment. |
| 17 | + |
| 18 | +### Security software on Windows |
| 19 | + |
| 20 | +On Windows systems, if Windows Defender (or other real-time security software) |
| 21 | +is enabled, it can slow down the file read times enough |
| 22 | +to impact analyzer performance. The analyzer frequently reads files, |
| 23 | +and constant scanning can introduce latency. To mitigate this, |
| 24 | +you can set up exclusions for the directories the analyzer reads from. |
| 25 | + |
| 26 | +:::warning |
| 27 | +Excluding directories from security scans might diminish the |
| 28 | +protection that your antivirus software provides. |
| 29 | +Proceed with caution. |
| 30 | +::: |
| 31 | + |
| 32 | +If you choose to set up exclusions, include the following directories: |
| 33 | + |
| 34 | +* The analysis server's cache directory: `%LOCALAPPDATA%\.dartServer` |
| 35 | +* The directory for packages downloaded by pub: `%LOCALAPPDATA%\Pub\Cache` |
| 36 | +* Any other directories containing code for your applications. |
| 37 | + |
| 38 | +For another way to improve file I/O performance, |
| 39 | +consider setting up a [dev drive][]. |
| 40 | + |
| 41 | +### Symbolic links |
| 42 | + |
| 43 | +If your package directory contains symbolic links that point |
| 44 | +to a location inside the same directory, or to a parent directory, |
| 45 | +you might experience performance problems with Dart tooling (like the analyzer). |
| 46 | + |
| 47 | +**Status:** The Dart team is actively working on a fix for this issue. |
| 48 | + |
| 49 | +**Workaround:** There are no known workarounds at this time. |
| 50 | + |
| 51 | +## Report unknown issues |
| 52 | + |
| 53 | +If the known issues don't seem to apply to your situation, |
| 54 | +please open an issue in the [Dart SDK issue tracker][]. |
| 55 | +The more information you provide, |
| 56 | +the faster the team can diagnose and fix the problem. |
| 57 | + |
| 58 | +### Include reproduction steps |
| 59 | + |
| 60 | +In your issue, please provide detailed steps to |
| 61 | +reproduce the behavior you're observing. |
| 62 | + |
| 63 | +1. If you're working on an open-source project, include instructions |
| 64 | + for downloading the code. |
| 65 | +2. If you can't share your code, create a small, self-contained reproduction case. |
| 66 | +3. If you can't provide either, please state that in the issue. |
| 67 | + |
| 68 | +### Provide performance data |
| 69 | + |
| 70 | +If the issue is related to performance, providing performance data |
| 71 | +can be very helpful. You can collect this data using the |
| 72 | +analysis server's diagnostic pages: |
| 73 | + |
| 74 | +1. **Open the Analyzer Diagnostics page:** |
| 75 | + * **If you are using VS Code:** |
| 76 | + 1. Click **View > Command Palette**. |
| 77 | + 2. Type `Dart: Open Analyzer Diagnostics` and select it. |
| 78 | + * **If you are using IntelliJ / Android Studio:** |
| 79 | + 1. Open the **Dart Analysis** tool window. |
| 80 | + 2. Click the settings icon, and then select **View analyzer diagnostics**. |
| 81 | +2. **Collect the report:** |
| 82 | + 1. In the browser page that opens, click **Collect Report** in the top banner. |
| 83 | + 2. Perform the actions that trigger the slow behavior. |
| 84 | + 3. Click the **Download report** link. |
| 85 | +3. **Attach the report to your issue.** |
| 86 | + |
| 87 | +:::note |
| 88 | +While the report shouldn't contain |
| 89 | +personal or proprietary information, |
| 90 | +review it before submitting it. |
| 91 | +::: |
| 92 | + |
| 93 | +### Capture instrumentation logs |
| 94 | + |
| 95 | +In some cases, instrumentation logs can provide additional |
| 96 | +details for diagnosing issues. |
| 97 | + |
| 98 | +To capture these logs: |
| 99 | + |
| 100 | +* **VS Code:** Follow the instructions for |
| 101 | + [capturing analyzer instrumentation logs][]. |
| 102 | +* **IntelliJ / Android Studio:** Follow the |
| 103 | + [analyzer instrumentation instructions][]. |
| 104 | + |
| 105 | +Before attaching logs to a GitHub issue, review them carefully |
| 106 | +to ensure they do not contain any personal, sensitive, or proprietary |
| 107 | +information. |
| 108 | + |
| 109 | +[dev drive]: https://learn.microsoft.com/windows/dev-drive/ |
| 110 | +[Dart SDK issue tracker]: https://github.com/dart-lang/sdk/issues |
| 111 | +[capturing analyzer instrumentation logs]: https://dartcode.org/docs/logging/#analyzer-instrumentation |
| 112 | +[analyzer instrumentation instructions]: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/tutorial/instrumentation.md#intellij-idea-and-android-studio |
0 commit comments