-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Sped up reading with FlutterStandardCodec. #38327
Conversation
53d687a
to
54407e1
Compare
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 (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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 % nits
case FlutterStandardFieldFloat64Data: | ||
case FlutterStandardFieldList: | ||
case FlutterStandardFieldMap: | ||
case FlutterStandardFieldFloat32Data: |
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 don't remember exactly, does the compiler warn you if a new enum is added and a case is not handled in the switch statement?
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.
My point is this might cause mistakes if a new enum is added and this code is not updated. If there is no compiler warning, maybe we can add a comment, or use a different way to determine valid enums.
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 moved the check to be right next to the enum declaration and added a comment that it needs to be updated if it changes.
if (IsStandardType(type)) { | ||
*location += 1; | ||
return FlutterStandardCodecHelperReadValueOfType( | ||
location, data, type, ReadValue, ReadTypedDataOfType, user_data); | ||
} else { | ||
return ReadValue(user_data); | ||
} | ||
} |
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.
Can we have a unit test in the engine to test this? Basically making sure overriding Standard codec works?
(We have a test in framework, but it would be nice to catch potential bugs in the engine)
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.
good call, done
…117242) * e28b26e1d [linux] Allow overriding asset, ICU data path (flutter/engine#38296) * 35bdb8bfc Roll Skia from 9f728d78f10d to f549128104ba (1 revision) (flutter/engine#38319) * 97e246cb5 Roll Dart SDK from 358d0d1aa3e7 to 1dd5b1bf1099 (7 revisions) (flutter/engine#38320) * d9580a5e7 Migrate iOS text input plugin to use ARC (flutter/engine#38179) * c9e9fa5a9 Update web_sdk -> package test dependency to get updated package matcher (flutter/engine#38323) * a7ec07f13 [fuchsia] Manually roll Fuchsia Linux SDK. (flutter/engine#38324) * 61e95bacb Remove doc reference to the compute method (flutter/engine#38246) * 353d6949e make sure CanvasRecorder updates clip bounds methods (flutter/engine#38325) * 47a358c5e Started using FlutterEngineGroups by default on Android (flutter/engine#37822) * 7d8e10652 Bump github/codeql-action from 2.1.35 to 2.1.36 (flutter/engine#38210) * 8915b81d4 Update buildroot to b2ab6e1. (flutter/engine#38329) * 4fe620643 Revert "Roll Dart SDK from 358d0d1aa3e7 to 1dd5b1bf1099 (7 revisions) (#38320)" (flutter/engine#38331) * 2ff490c1e Roll Skia from f549128104ba to 5e69caecd166 (11 revisions) (flutter/engine#38333) * 22251857f Add missing include to FlutterThreadSynchronizer (flutter/engine#38337) * 467cfd7ef Roll Fuchsia Mac SDK from VEOIaacOA75U7PYyz... to KtItDj-MERuua77aS... (flutter/engine#38339) * 010f4ee7a Roll Fuchsia Linux SDK from zwfwHRSLdmV61hYqe... to urDNtEiHFAcBBhYe0... (flutter/engine#38340) * 773b43571 Sped up reading with FlutterStandardCodec. (flutter/engine#38327) * 70439f606 Roll Skia from 5e69caecd166 to 62f22c9c7d67 (3 revisions) (flutter/engine#38341) * bc1647f0d Roll the test package used by Web in preparation for a Dart 3 SDK roll (flutter/engine#38342) * cac228aff Roll Dart SDK from 358d0d1aa3e7 to 7b4d4ec3cad1 (14 revisions) (flutter/engine#38344) * 13ae6eb75 Revert "Started using FlutterEngineGroups by default on Android (#37822)" (flutter/engine#38351) * ed8063861 Add an explicit constraint on the matcher package version to ensure Dart 3 compatibility (flutter/engine#38352) * dcafebf44 Roll Skia from 62f22c9c7d67 to 1b1f53d77ced (1 revision) (flutter/engine#38343) * 6f6158580 Roll Fuchsia Mac SDK from KtItDj-MERuua77aS... to bn5VF1-xDf-wKjIw8... (flutter/engine#38348) * 0c00bc0a9 Remove 30fps cap from playgrounds (flutter/engine#38347) * 38340bb57 [Impeller] Fix SceneC crash for nodes with children (flutter/engine#38346) * 3a6b3f986 Roll Fuchsia Linux SDK from urDNtEiHFAcBBhYe0... to H6B0UgW07fc1nBtnc... (flutter/engine#38357) * 81b453535 Roll Skia from 1b1f53d77ced to 7b0a9d9a3008 (8 revisions) (flutter/engine#38358) * d91e20879 Port touch-based tests from embedder integration test (flutter/engine#38234)
* Sped up reading with FlutterStandardCodec. * added missing license diff * put the IsStandardType in the header so it's closer to where it should change * added unittest for subclassing codecs * fixed lints
…lutter#117242) * e28b26e1d [linux] Allow overriding asset, ICU data path (flutter/engine#38296) * 35bdb8bfc Roll Skia from 9f728d78f10d to f549128104ba (1 revision) (flutter/engine#38319) * 97e246cb5 Roll Dart SDK from 358d0d1aa3e7 to 1dd5b1bf1099 (7 revisions) (flutter/engine#38320) * d9580a5e7 Migrate iOS text input plugin to use ARC (flutter/engine#38179) * c9e9fa5a9 Update web_sdk -> package test dependency to get updated package matcher (flutter/engine#38323) * a7ec07f13 [fuchsia] Manually roll Fuchsia Linux SDK. (flutter/engine#38324) * 61e95bacb Remove doc reference to the compute method (flutter/engine#38246) * 353d6949e make sure CanvasRecorder updates clip bounds methods (flutter/engine#38325) * 47a358c5e Started using FlutterEngineGroups by default on Android (flutter/engine#37822) * 7d8e10652 Bump github/codeql-action from 2.1.35 to 2.1.36 (flutter/engine#38210) * 8915b81d4 Update buildroot to b2ab6e1. (flutter/engine#38329) * 4fe620643 Revert "Roll Dart SDK from 358d0d1aa3e7 to 1dd5b1bf1099 (7 revisions) (flutter#38320)" (flutter/engine#38331) * 2ff490c1e Roll Skia from f549128104ba to 5e69caecd166 (11 revisions) (flutter/engine#38333) * 22251857f Add missing include to FlutterThreadSynchronizer (flutter/engine#38337) * 467cfd7ef Roll Fuchsia Mac SDK from VEOIaacOA75U7PYyz... to KtItDj-MERuua77aS... (flutter/engine#38339) * 010f4ee7a Roll Fuchsia Linux SDK from zwfwHRSLdmV61hYqe... to urDNtEiHFAcBBhYe0... (flutter/engine#38340) * 773b43571 Sped up reading with FlutterStandardCodec. (flutter/engine#38327) * 70439f606 Roll Skia from 5e69caecd166 to 62f22c9c7d67 (3 revisions) (flutter/engine#38341) * bc1647f0d Roll the test package used by Web in preparation for a Dart 3 SDK roll (flutter/engine#38342) * cac228aff Roll Dart SDK from 358d0d1aa3e7 to 7b4d4ec3cad1 (14 revisions) (flutter/engine#38344) * 13ae6eb75 Revert "Started using FlutterEngineGroups by default on Android (flutter#37822)" (flutter/engine#38351) * ed8063861 Add an explicit constraint on the matcher package version to ensure Dart 3 compatibility (flutter/engine#38352) * dcafebf44 Roll Skia from 62f22c9c7d67 to 1b1f53d77ced (1 revision) (flutter/engine#38343) * 6f6158580 Roll Fuchsia Mac SDK from KtItDj-MERuua77aS... to bn5VF1-xDf-wKjIw8... (flutter/engine#38348) * 0c00bc0a9 Remove 30fps cap from playgrounds (flutter/engine#38347) * 38340bb57 [Impeller] Fix SceneC crash for nodes with children (flutter/engine#38346) * 3a6b3f986 Roll Fuchsia Linux SDK from urDNtEiHFAcBBhYe0... to H6B0UgW07fc1nBtnc... (flutter/engine#38357) * 81b453535 Roll Skia from 1b1f53d77ced to 7b0a9d9a3008 (8 revisions) (flutter/engine#38358) * d91e20879 Port touch-based tests from embedder integration test (flutter/engine#38234)
No functional change, just an improvement in 19% increase codec reading speed. The gains were using a CFData create function that avoids a copy for a temporary data object until it is converted to a string, avoiding some objc_msgSend, avoiding some retain/release, and avoiding the objc recursion if we know the next object we are reading can be read in C.
before:
![Screen Shot 2022-12-15 at 8 56 17 AM](https://user-images.githubusercontent.com/30870216/207963470-7d553547-0ff8-45a1-b1c6-1702b336343e.png)
after:
![Screen Shot 2022-12-15 at 12 40 04 PM](https://user-images.githubusercontent.com/30870216/207963442-0e7f9833-b8e3-4cbb-906c-8abcfbb3e4b5.png)
tests:
implementation of investigation @cyanglaz and I did on #37883
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.