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

Slow code on critical path of CLI startup #1966

Open
bartekpacia opened this issue Nov 29, 2023 · 3 comments
Open

Slow code on critical path of CLI startup #1966

bartekpacia opened this issue Nov 29, 2023 · 3 comments
Labels
bug Something isn't working P2 Issues not at the top of the work list package: patrol_cli Related to the patrol_cli package

Comments

@bartekpacia
Copy link
Contributor

bartekpacia commented Nov 29, 2023

This code:

class Analytics {
Analytics({
required String measurementId,
required String apiSecret,
required FileSystem fs,
required Platform platform,
http.Client? httpClient,
FlutterVersionGetter getFlutterVersion = _getFlutterVersion,
required bool isCI,
}) : _fs = fs,

is executed on the critical path of Patrol CLI startup. The problem is that it calls flutter --version:

FlutterVersion _getFlutterVersion() {
final result = io.Process.runSync(
'flutter',
['--no-version-check', '--version', '--machine'],
runInShell: true,
);

and it's really slow (~2-3 seconds on my M1 MBA).

We should find a way to not block on it, because it's only needed for analytics. This is especially annoying when trying to use tab completion in shell – it makes completion way to slow, practically unusable.

@bartekpacia bartekpacia added bug Something isn't working package: patrol_cli Related to the patrol_cli package labels Nov 29, 2023
@jBorkowska jBorkowska added the P1 High-priority issues at the top of the work list label Dec 11, 2023
@piotruela
Copy link
Collaborator

@bartekpacia I tried to reproduce this problem but it's fast on my machine. I measured execution time of flutter --version and it's around 100ms. No matter if it's called by patrol_cli or typed by me in the console

@bartekpacia
Copy link
Contributor Author

Hmm, I must've had weaker network connection then. Still, this is something to be fixed, but maybe not with P1 but P2.

You should be able to reproduce this by adding some artificial timeout to _getFlutterVersion.

@bartekpacia bartekpacia added P2 Issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Dec 13, 2023
@bartekpacia
Copy link
Contributor Author

The problem I had in mind here is actually the update check being performed synchronously, see #2512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Issues not at the top of the work list package: patrol_cli Related to the patrol_cli package
Projects
None yet
Development

No branches or pull requests

3 participants