When sending to device, use gzip compression level 1 instead of the default (6)#52666
When sending to device, use gzip compression level 1 instead of the default (6)#52666jensjoha wants to merge 3 commits intoflutter:masterfrom
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I tested this change locally on a mac pro + physical android device. Without this change, a hot reload to text.dart takes 3,940ms. Afterwards it takes 3,573ms. On a smaller change in home.dart I get times of about 420-450 ms before, 400-420ms after. |
zanderso
left a comment
There was a problem hiding this comment.
I think we need to make an effort to add tests for changes like this. In particular for this change, the implementation of contentAsGzip1CompressedStream() can be moved to base/os.dart, which a test can then mock out and verify is called.
I'm thinking you have probably read this wrong. Anyway, after implementing the feedback from @jonahwilliams the method doesn't exist anymore. |
There is currently no test that verifies that the stream is compressed. This line of code: return contentsAsStream().cast<List<int>>().transform<List<int>>(gzip.encoder);should be abstracted out in a new method in If it is important that the compression level stay at level 1, then the |
That's true, but this PR does not introduce compression, and that there's no testing of it is a pre-existing issue not made worse by this PR.
That would take a very small and basically risk free change, turn it bigger and increase it's risk. |
|
Please see (5) under our Tree hygine polices here: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview. As instructed above in the automated message from fluttergithubbot, if you feel this PR needs an exemption from the policy, please at-mention hixie on this PR. Thanks! |
|
Ping @Hixie |
|
I spoke with Hixie about the procedure for getting an exception. He recommended that contacting him on the Flutter discord would be more effective. He's also working on updating the bot text. |
Description
When sending files to the device it is first compressed with gzip in an effort to make the whole thing go faster.
As detailed here: dart-lang/sdk#41048 gzip encoding is pretty slow, and in all but cases where the transfer speed is very slow, it would be better to spend less time compressing, even if it means sending more data.
This change - tested on flutter gallery on an android emulator on my google issue desktop - has the following characteristics:
Before this change the time spend transferring to device (via this mechanism) was (timings in ms):
(Note for reproduction: The 13.4 MB partial dill file is the dill generated when changing package flutters "lib/src/widgets/text.dart".)
After this change the times are:
For the initial transfer that's (difference at 95.0% confidence): -101.4 +/- 91.0318 (-6.37335% +/- 5.72167%) ---- i.e. almost unchanged.
For the partial dill that's (difference at 95.0% confidence): -302.8 +/- 20.4702 (-62.5361% +/- 4.22764%) ---- i.e. at lot faster.
Digging into why the initial transfer is almost not different:
The change for the partial dill file is consistent with the calculations on dart-lang/sdk#41048
Note (and again): This was tested on an emulator, a real device connected via either usb2, usb3, wifi or whatever else will probably behave differently. From the above though, I think the conclusion can be that it doesn't matter for the initial transfer, and unless the transfer speed is very slow, this change is for the better (I get that saving these 300 ms is not changing the fact that compiling the 13.5 MB file takes several seconds, but shaving of 300 ms is still something like an overall improvement of ~8% for the entire hot-reload).
Related Issues
dart-lang/sdk#41048
dart-lang/sdk#34001
Tests
No tests have been added or changed.