-
Notifications
You must be signed in to change notification settings - Fork 39
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
Multithreading? #9
Comments
I lean towards "no" for all of that, for simplicity's sake. |
From everything I know about React. If the codebase is written well enough, and Few seems to be, multi-threading should be fairly trivial to implement, for the diffing part. Plus in Swift, there are GREAT tools for multithreading. |
I'm not sure anything involving multithreading is ever trivial 😄 I'm not convinced that the tradeoffs in complexity are worth it. I think we'd need some concrete cases where performance suffers to motivate this. |
@joshaber I just saw Few today, so I don't know how complicated it to implement. I have a lot of experience with React. With React, Pete Hunt was able to trivially move all the React code to a different thread. The only problem with that approach was that preventDefault couldn't be called on UI events. Now perhaps, it is not important enough, and it is much more complicated to actually implement in Swift native code. But, I think that for larger apps, performance will become a bottleneck eventually, and multithreading could avoid that problem entirely. Few is amazing, and very promising. I think it should reach for the maximum potential. Perhaps, its too early to work on a power feature like multithreading, but don't write it off for the future! |
Note also that multithreading is not always a simple gain in performance. Sometimes the overhead involved in concurrency (and especially synchronization) can dominate the program, to where it's slower than if it were single-threaded. |
(Just for context, when I last talked to some of the folks working on Components one of the big motivations for multithreading was text layout with non-English languages.) |
Threading is hard. The interesting thing is that React Native and ComponentKit have two totally different approaches to multithreading:
After we open source these two I would love to be part of the conversation about what Few should do for threading. |
@adamjernst Very interesting insights. I have personal experience with React.js. In that case, all the JS operation do run on a single javascript thread, but as javascript is extremely async, the UI is never actually blocked. All the state and model updates in React are now async as well. I don't know about componentKit. But you said I said that multithreading is a worthy goal earlier. This has all been informed by my experience of React.js |
@adamjernst If you had access to immutable data structures in ObjC++, with structural sharing, like those that exist in JS (not used in React currently either) and used those to represent your component tree, would you be able to update part of the component tree without a complete re-render? |
@mrjjwright No. The two things that allow you to do scoped subtree updates:
|
Yes React enforces those 2 rules well and from what I understood from Ari Grant’s talk so does Components. So I am still surprised that above you said that Components can’t currently handle scoped tree updates, but I am thinking it is because you can't mutate the component tree at all while with React they have a system appears immutable but is actually mutable via the internal ref system. |
Should we allow component state to be changed from a background thread? Should it do realization, layout, or diffing on a background thread?
The text was updated successfully, but these errors were encountered: