-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Optimize SEL search efficiency #1055
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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.
😎 Seems reasonable to me! Thanks @zhongwuzw !
cc @rnystrom - any reason you can think of not to do this?
Source/Internal/IGListAdapterProxy.m
Outdated
@@ -12,30 +12,34 @@ | |||
#import <IGListKit/IGListAssert.h> | |||
|
|||
/** | |||
Define messages that you want the IGListAdapter object to intercept. Pattern copied from | |||
https://github.com/facebook/AsyncDisplayKit/blob/7b112a2dcd0391ddf3671f9dcb63521f554b78bd/AsyncDisplayKit/ASCollectionView.mm#L34-L53 | |||
Define messages that you want the IGListAdapter object to intercept. |
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.
let's keep the original comment.
Source/Internal/IGListAdapterProxy.m
Outdated
sel == @selector(scrollViewDidEndDragging:willDecelerate:) || | ||
sel == @selector(scrollViewDidEndDecelerating:) | ||
); | ||
static NSSet<NSString *> *sels; |
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.
let's spell-out selectors
@zhongwuzw has updated the pull request. View: changes |
Generated by 🚫 Danger |
This makes sense to me, though I'm curious @zhongwuzw did you do any instrumentation on the efficiency of this? Just curious what the cost of the linear pointer equality checks vs acquiring a lock + lookup is against each other? I ask b/c even though this is straightforward, I'm skeptical about making changes w/out evidence that it's actually better. |
@rnystrom , 👍 , honestly, I did not test it before, just based on my theoretical knowledge. After your comment, I tested like below, The output:
Conclusion:
|
nice 😎 |
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.
Awesome, thanks so much for running the test! I'd be happy to accept an update reordering to the most-used selectors.
@zhongwuzw has updated the pull request. View: changes |
@rnystrom , I found the main performance overhead is |
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.
@rnystrom is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Changes in this pull request
Optimize
SEL
search efficiency, reduced the time complexity from O (n) to O (1).Not need tests.
Checklist
CHANGELOG.md
for any breaking changes, enhancements, or bug fixes.