-
Notifications
You must be signed in to change notification settings - Fork 6k
Speed up clang-tidy script by skipping third_party files #29640
Conversation
zanderso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. So is this code https://github.com/flutter/engine/blob/master/tools/clang_tidy/lib/clang_tidy.dart#L157 including files that don't exist?
I guess I had run Really, the speed up is in skipping the expensive |
tools/clang_tidy/lib/clang_tidy.dart
Outdated
| for (final dynamic data in buildCommandsData) { | ||
| final Command command = Command.fromMap(data as Map<String, dynamic>); | ||
| final LintAction lintAction = await command.lintAction; | ||
| if (lintAction != LintAction.skipMissing && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip files that don't exist in case there is anything stale in host_debug/compile_commands.json.
| } | ||
|
|
||
| final io.File file = io.File(filePath); | ||
| if (!file.existsSync()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this check reading the lines crashes
engine/tools/clang_tidy/lib/src/command.dart
Line 103 in ab47e45
| final Stream<String> lines = file.openRead() |
Also, no, the repo list check only includes files that exist, and engine/tools/clang_tidy/lib/src/command.dart Line 103 in ab47e45
|
| '--compile-commands', | ||
| // This just has to exist. | ||
| io.Platform.executable, | ||
| io.Platform.script.path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
io.Platform.executable crashed, this file is actually parsed now and needs to be utf8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the comment on the line above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
zanderso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| '--compile-commands', | ||
| // This just has to exist. | ||
| io.Platform.executable, | ||
| io.Platform.script.path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the comment on the line above?
| ); | ||
| const String filePath = '/path/to/a/source_file.cc'; | ||
|
|
||
| // This just has to exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Significantly speed up the
clang-tidyscript. The changed files/compile-commands intersectioncontainsAnycalculation is very expensive. Short-circuit this call for thethird_partyfiles that would only have been skipped later.Reduced
--lint-allios_debugon my machine from 11:54 minutes to 2:28.Optimize for linting all files in a target with flutter/flutter#61661.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.