Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Dart analysis server at 100% cpu indefinitely when opening the Dart SDK repo (or flutter engine, which includes a nested copy) #5101

Closed
gaaclarke opened this issue May 9, 2024 · 8 comments
Labels
upstream in dart / flutter Needs changing in Dart or Flutter

Comments

@gaaclarke
Copy link

Description

The dart analysis server just sits at 100% when editing the flutter engine repo.

To Reproduce

  1. Check out the flutter engine repo
  2. Open it in VSCode with the dart plugin installed
  3. Notice that dart process that is running the analysis server sits at around 100% and never stops.

Expected behavior

I would expect the process to reach some stasis of VSCode is not being interacted with.

Screenshots

Maybe it's related that there is a huge number of issues that are reported that I never mind:

Screenshot 2024-05-09 at 9 03 50 AM

Logs

openfiles.txt

sample.txt

Details

  • Operating System and version: macOS 14.4.1
  • VS Code version: 1.89.0
  • Dart extension version: v3.89.20240509 (pre-release)
  • Dart/Flutter SDK version: engine 0e23e60093d162e19108fcf28233f918fdafc136
  • Target device (if the issue relates to Flutter debugging):

(spawned from #5084)

@gaaclarke
Copy link
Author

This PR to the analysis options seems to resolve this issue: flutter/engine#52699

We were just overloading it and getting it into a bad state. It's probably still worth fixing, but it's not an issue for me anymore.

gaaclarke added a commit to flutter/engine that referenced this issue May 9, 2024
related issue Dart-Code/Dart-Code#5101

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
@DanTup
Copy link
Member

DanTup commented May 13, 2024

@gaaclarke do you know if there are extra steps beyond cloning the repo required to trigger this? I wasn't able to reproduce (even with gclient sync). I wonder if there are other steps you may have performed during setting up your environment for the engine.

(eg., if you clone a new copy of the repo, can you trigger it on that?)

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label May 13, 2024
@gaaclarke
Copy link
Author

No, it can't be a new clone, you have to checkout before: flutter/engine@233a57b

here is my workspace, but i don't see anything that may be off. Maybe the fact that I'm using a workspace is enough to mess it up?

$ cat engine.code-workspace 
{
	"folders": [
		{
			"path": "src/flutter"
		},
		{
			"path": "src/third_party/vulkan-deps/vulkan-headers"
		},
		{
			"path": "src/flutter/lib/ui"
		}
	],
	"settings": {
		"files.associations": {
			"optional": "cpp",
			"__bit_reference": "cpp",
			"__bits": "cpp",
			"__config": "cpp",
			"__debug": "cpp",
			"__errc": "cpp",
			"__hash_table": "cpp",
			"__locale": "cpp",
			"__mutex_base": "cpp",
			"__node_handle": "cpp",
			"__nullptr": "cpp",
			"__split_buffer": "cpp",
			"__string": "cpp",
			"__threading_support": "cpp",
			"__tree": "cpp",
			"__tuple": "cpp",
			"any": "cpp",
			"array": "cpp",
			"atomic": "cpp",
			"bitset": "cpp",
			"cctype": "cpp",
			"chrono": "cpp",
			"cinttypes": "cpp",
			"clocale": "cpp",
			"cmath": "cpp",
			"codecvt": "cpp",
			"compare": "cpp",
			"complex": "cpp",
			"concepts": "cpp",
			"condition_variable": "cpp",
			"csignal": "cpp",
			"cstdarg": "cpp",
			"cstddef": "cpp",
			"cstdint": "cpp",
			"cstdio": "cpp",
			"cstdlib": "cpp",
			"cstring": "cpp",
			"ctime": "cpp",
			"cwchar": "cpp",
			"cwctype": "cpp",
			"deque": "cpp",
			"exception": "cpp",
			"forward_list": "cpp",
			"fstream": "cpp",
			"future": "cpp",
			"initializer_list": "cpp",
			"iomanip": "cpp",
			"ios": "cpp",
			"iosfwd": "cpp",
			"iostream": "cpp",
			"istream": "cpp",
			"limits": "cpp",
			"list": "cpp",
			"locale": "cpp",
			"map": "cpp",
			"memory": "cpp",
			"mutex": "cpp",
			"new": "cpp",
			"numeric": "cpp",
			"ostream": "cpp",
			"queue": "cpp",
			"random": "cpp",
			"ratio": "cpp",
			"regex": "cpp",
			"set": "cpp",
			"span": "cpp",
			"sstream": "cpp",
			"stack": "cpp",
			"stdexcept": "cpp",
			"streambuf": "cpp",
			"string": "cpp",
			"string_view": "cpp",
			"strstream": "cpp",
			"system_error": "cpp",
			"tuple": "cpp",
			"type_traits": "cpp",
			"typeinfo": "cpp",
			"unordered_map": "cpp",
			"unordered_set": "cpp",
			"valarray": "cpp",
			"variant": "cpp",
			"vector": "cpp",
			"algorithm": "cpp",
			"filesystem": "cpp",
			"memory_resource": "cpp",
			"bit": "cpp",
			"charconv": "cpp",
			"format": "cpp",
			"functional": "cpp",
			"iterator": "cpp",
			"utility": "cpp",
			"__assert": "cpp",
			"*.inc": "cpp",
			"__verbose_abort": "cpp",
			"*.def": "cpp",
			"*.hpp11": "cpp",
			"__functional_base": "cpp",
			"shared_mutex": "cpp",
			"coroutine": "cpp",
			"hash_map": "cpp",
			"hash_set": "cpp",
			"thread": "cpp",
			"propagate_const": "cpp",
			"*.gen": "cpp",
			"simd": "cpp"
		},
		"C_Cpp.default.includePath": [
			"${default}",
			"/Users/aaclarke/dev/engine/src/",
			"/Users/aaclarke/dev/engine/src/flutter",
			"/Users/aaclarke/dev/engine/src/third_party/vulkan-deps/vulkan-headers/src/include/"
		],
		"dotnet.defaultSolution": "disable"
	}
}

@DanTup
Copy link
Member

DanTup commented May 14, 2024

I think I may have reproduced this using your workspace. It doesn't seem "stuck" because it's still sending analysis diagnostics (it's generating a lot of diagnostics because there is a copy of the SDK in there that doesn't seem to resolve any packages) but it's been going at least 10 minutes.

I wonder if it's because you have the same folders included multiple times:

{
	"path": "src/flutter"
},
{
	"path": "src/flutter/lib/ui" // this is included by the one above
}

I'll do some more digging, thanks!

@DanTup DanTup removed the awaiting info Requires more information from the customer to progress label May 14, 2024
@DanTup DanTup added this to the v3.90.0 milestone May 14, 2024
@DanTup
Copy link
Member

DanTup commented May 14, 2024

btw, in your workspace above you have:

"path": "src/third_party/vulkan-deps/vulkan-headers"

But I don't have a vulkan-deps at that location (even after gclient sync), it's only at src/flutter/third_party, so this folder shows as "missing". Did I set something up differently to you?

@DanTup
Copy link
Member

DanTup commented May 14, 2024

Seems that this is caused by the Dart SDK in src/third_party/dart. If I open only that folder, I still see the same behaviour. And, if I just open a clone of the Dart SDK directly (not part of engine), I see the same too.

It is known that there are issues trying to analyze the whole SDK repo (it's full of test projects and things), but I'm surprised that it seems to be analyze forever (or at least, it's so slow it doesn't complete in any reasonable amount of time).

An extra weird thing - this repros on Windows (server is stuck forever analyzing), yet it uses almost no CPU to do so (I presume something else is a bottleneck, but nothing else like disk seem saturated oddly).

I'm gonna leave it running in the background and while I for lunch on the chance it does complete, but otherwise I'll do some more debugging to see what's going on.

@DanTup
Copy link
Member

DanTup commented May 14, 2024

I tracked this down to an infinite loop in the linter when there are cycling redirecting constructors. The Dart SDK includes a test file that has that (but I guess never triggers the linter over it in tests).

I've opened dart-lang/linter#4970 with the details and will close this one. Thanks!

@DanTup DanTup closed this as completed May 14, 2024
@DanTup DanTup removed this from the v3.90.0 milestone May 14, 2024
@DanTup DanTup added upstream in dart / flutter Needs changing in Dart or Flutter and removed is bug labels May 14, 2024
@DanTup DanTup changed the title Dart analysis server at 100% cpu indefinitely when editing flutter engine Dart analysis server at 100% cpu indefinitely when opening the Dart SDK repo (or flutter engine, which includes a nested copy) May 14, 2024
@gaaclarke
Copy link
Author

Thanks Danny! Yea we've recently moved the vulkan headers but I haven't had the need to update my workspace. I don't even know why I'd have "src/flutter" and "src/flutter/lib/ui" separately. Thanks for figuring it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream in dart / flutter Needs changing in Dart or Flutter
Projects
None yet
Development

No branches or pull requests

2 participants