-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Startup flutter faster (cache git calls)
#111392
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
Startup flutter faster (cache git calls)
#111392
Conversation
flutter fasterflutter faster (cache git calls)
|
Any input on this one? |
|
For the actual caching behavior you've outlined, I would defer to our resident git authority @christopherfujino . I would say that in general I'm okay with trying this out because we have a lot of runway before our next release, but in general it does strike me as the change most likely to introduce a bug. |
packages/flutter_tools/test/commands.shard/hermetic/upgrade_test.dart
Outdated
Show resolved
Hide resolved
2d5b3d7 to
3e5303e
Compare
|
Thanks for the feedback @jonahwilliams. It should all be incorporated now. |
jonahwilliams
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 if LG to @christopherfujino
christopherfujino
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.
I'm sorry I didn't review this one earlier. I'm not sure this is the right change to make, although I'm sure we can improve this. I'm pretty sure if we're on a release branch, we shouldn't need to ever fetch tags.
However, if we ARE on master, I don't think we want to cache this call, as there could have been a newer tag added after we checked to a commit that is an ancestor of our current HEAD, and we would want the Flutter version to report the commit as being more recent than that.
I don't understand this part. Either I don't understand what you're saying, or I don't understand why it should be the case (the way I'm reading it we should suddenly report an old version as being newer?). Also it's not clear to me which command you think shouldn't be cached.
So none of the cached commands access the network. So the only way the answers can become "externally out-of-date" is by other commands accessing the network:
|
f4b9333 to
82cc3dc
Compare
Consider that you check out the master branch at commit abcd, which is 10 commits past the last tagged release, version Now consider we tag a commit 5 commits past version 1 and 5 commits before commit abcd as version 2.0.0. Now, the result of |
This would require the user to fetch new tags though. Meaning there will always be a window in which they see it as |
0dbf62c to
c1929e1
Compare
c1929e1 to
854b7bd
Compare
|
ping. |
christopherfujino
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.
You know, I'm sorry to do this, but after having gone through this PR, I think we should actually just refactor this version reporting code to read from a version file checked in to the repo (tracked #112833). We will likely need to do this for SLSA compliance anyway.
|
In a private email I've been told that the above means that the PR has been rejected so I'm closing this PR. |
This PR makes
flutter(as measured withflutter testdirectly in theflutterdirectory which has notestdirectory, thus just writing "there's notestdirectory) startup faster by cachinggitcalls.When starting
fluttera number ofgitcalls are made, which is quite expensive. This PR introduces caching of these calls.Caching is deleted when also creating a new snapshot (i.e. it's guarded by the same mechanism, which is the git hash).
This does mean that these things can change:
flutterand caches that, a tag is then created, the user fetches (but stays on the old hash) --- git would now know about the new tag, but caching isn't updated. Again I'll say this doesn't matter and any crash reports or whatever would have to handle the case anyway because not everyone has necessarily fetched.To me, neither of these seems like big deals though.
The startup changes as measured on my machines is this:
Linux
While not important for this PR I'll note that it's faster to startup
flutterwhen not on a branch called master:This PR improves things (compared to now on branch called master):
This PR improves things (compared to now on branch not called master):
I.e. it's somewhere from 20 to 25% faster, cutting off something like 110 to 175 ms.
Windows (Google issued with whatever security software)
This PR improves things:
I.e. it's almost 30% faster, cutting off almost a full second.
A more detailed analysis is available internally at go/FlutterStartupTimeAnalysis (which also discussed future PRs).