-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Increase threshold for usage of compute for utf8 decoding on large strings to 50 KB #64350
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 on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
That stopwatch is actually measuring UTF8 decode and JSON parse, but only UTF8 decode ran on an isolate. Locally it takes about 100 microseconds on 18 KB (the size of the flutter gallery asset manifest) |
if (data.lengthInBytes < 10 * 1024) { | ||
// 10KB takes about 3ms to parse on a Pixel 2 XL. | ||
// See: https://github.com/dart-lang/sdk/issues/31954 | ||
if (data.lengthInBytes < 50 * 1024) { |
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.
perhaps add a comment regarding "50 * 1024" number?
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
While this change LGTM, I wouldn't say that it fixes #36552, it only delayed the issue until AssetManifest.json is larger than 50KB. Since AssetManifest is only loaded once in the app lifetime, what if we could load AssetManifest without using |
Yeah, I agree this doesn't completely fix the issue. I'm not sure about always skipping compute because I could imagine the asset manifest causing a significant amount of jank if it were truly that big - but mostly due to JSON parsing. Another approach would be to revisit running code-generation to create a const map of the asset manifest |
…rings to 50 KB (flutter#64350) On a local benchmark, removing compute is faster than compute in both debug and release mode on a Pixel 4. On a MotoG4, a much larger text sample (800 Kb) takes 50 ms, so we cannot simple remove the limit. Increase to 50 Kb which should take at most a ms or two on an older device, and only microseconds on newerones.
…large strings to 50 KB (flutter#64350)" (flutter#64372) This reverts commit f07f412.
…rings to 50 KB (flutter#64350) On a local benchmark, removing compute is faster than compute in both debug and release mode on a Pixel 4. On a MotoG4, a much larger text sample (800 Kb) takes 50 ms, so we cannot simple remove the limit. Increase to 50 Kb which should take at most a ms or two on an older device, and only microseconds on newerones.
…large strings to 50 KB (flutter#64350)" (flutter#64372) This reverts commit f07f412.
Description
#36552
On a local benchmark, removing compute is faster than compute in both debug and release mode on a Pixel 4. Looking for more confirmation on other older phone types.
Debug:
314 ms load/parse asset manifest with compute
91 ms load/parse without compute
Release:
14 ms load/parse with compute
2 ms load/parse without compute
I measured perf by inserting a stopwatch/print: