[ASDisplayNode] Convert isSynchronous to an Objective-C atomic BOOL.#88
Closed
appleguy wants to merge 1 commit into
Closed
[ASDisplayNode] Convert isSynchronous to an Objective-C atomic BOOL.#88appleguy wants to merge 1 commit into
appleguy wants to merge 1 commit into
Conversation
This reduces lock contention, and should also fix a very rarely seen deadlock.
Generated by 🚫 Danger |
Adlai-Holler
requested changes
Apr 30, 2017
Adlai-Holler
left a comment
Member
There was a problem hiding this comment.
Great! Let's standardize on using property names, instead of accessor names, with dot syntax, so self.isSynchronous -> self.synchronous OR [self isSynchronous].
Member
Author
|
Here's a very rough cut at what a better _atomicFlags setup might look like: https://gist.github.com/appleguy/9b7c325b1678d27312f33abaea21d2ce |
Member
Author
|
Closing in favor of #89 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reduces lock contention, and should also fix a very rarely seen deadlock.
See #64 for details.
@Adlai-Holler -- this is a case where I think a std::atomic would probably be better if we had a convenient access pattern. If we carried this pattern to other flags, the message send overhead would definitely become significant.
Although it's in the margin (most apps spend between 8-13% of all CPU time in objc_msgSend), for a core library it's great to keep that overhead as low as practical; BOOL flags seem like a possible opportunity to do something really efficient.
I'm also wondering if we could use a bitfield or something else more packed. It's not an issue for one BOOL, but I bet we'd get significant gains out of moving all the _flags to std::atomic bitfields if they were kept within 32 bits per field. We'd be able to avoid locking the mutex in many situations we do today, which would help not just CPU time but also contention / scheduler waiting.