Skip to content

[ASDisplayNode] Convert isSynchronous to an Objective-C atomic BOOL.#88

Closed
appleguy wants to merge 1 commit into
masterfrom
synchronous
Closed

[ASDisplayNode] Convert isSynchronous to an Objective-C atomic BOOL.#88
appleguy wants to merge 1 commit into
masterfrom
synchronous

Conversation

@appleguy

Copy link
Copy Markdown
Member

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.

This reduces lock contention, and should also fix a very rarely seen deadlock.
@appleguy appleguy self-assigned this Apr 30, 2017
@appleguy
appleguy requested review from Adlai-Holler and maicki April 30, 2017 00:11
@ghost

ghost commented Apr 30, 2017

Copy link
Copy Markdown
1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

@Adlai-Holler Adlai-Holler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Let's standardize on using property names, instead of accessor names, with dot syntax, so self.isSynchronous -> self.synchronous OR [self isSynchronous].

@appleguy

Copy link
Copy Markdown
Member Author

Here's a very rough cut at what a better _atomicFlags setup might look like:

https://gist.github.com/appleguy/9b7c325b1678d27312f33abaea21d2ce

@appleguy

Copy link
Copy Markdown
Member Author

Closing in favor of #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants