-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Experimental "React Fiber"-like Reconciler #471
Conversation
To test this, I used the following: struct RecursiveView: View {
let count: Int
init(_ count: Int) {
self.count = count
}
var body: some View {
if count == 0 {
Text("RecursiveView")
} else {
RecursiveView(count-1)
}
}
} Results after adding it to your demo: Current reconciler: 400 works, 500 overflows. |
@ezraberch That's cool, thanks for testing it out! Is that with or without the |
With. If I remove that flag, the breaking point changes to around 30 for current and 700 for new. |
Would fixing 3 remaining tests require any significant changes to this PR? Anyway, reviewing right now as it is. |
Sources/TokamakDOM/index.html
Outdated
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<title>Tokamak App</title> | ||
<script> | ||
window.Tokamak = { |
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.
Is there any benefit to having this snippet written in JS instead of Swift? Performance benefits for example?
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.
@carson-katri I assume you've addressed this with your benchmarks comment? Could still benefit with a code comment either making a reference to benchmarks or some other explanation.
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 actually wasn't able to test that. For now, I've rewritten that in Swift. It definitely simplifies things a bit.
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 love how well documented this is, amazing work! 👏
Just a couple of nits in terms of naming, code comments, and file headers.
Also, did you try adding benchmarks to TokamakStaticHTMLBenchmark
to compare how it performs when compared to the existing stack reconciler?
React Fiber
-like Reconciler
I added some benchmarks to compare the two reconcilers. Here are the results I got running it.
Also calculated the differences:
Edit: Ran it again with milliseconds as the time unit if that's easier to read:
|
Splendid! I think a slight regression in |
Tried a few other benchmarks, this time with just the
I'm sure better benchmarks could be created to push the reconcilers. I'm interested in the performance difference when rendering to the browser, as the |
I've fixed build issues, but I'm not seeing anything on the screen when running |
Thanks for the updates! There are still a few unresolved comments, and I've requested a review from the team if there are any active team members remaining who could also have a look in the meantime. |
The test failure is most probably a bug in |
Bug is fixed in swiftwasm/carton#350, I'm ready to merge that and tag a new version when approved. |
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.
Amazing! 👏
Demo code still needs to be restored, as far as I understand? I'd prefer that to be done before merging. |
This PR adds a new reconciler modeled after React Fiber. It has a few potential benefits over the current stack reconciler:
AnyView
. We can instead use aViewVisitor
to traverse the View tree without type-erasing all of the children.fiber/layout
branch, but it does not work all that well yet.We will need to test it to figure out if these are actually of any benefit.
This exists alongside the current
StackReconciler
class andRenderer
protocol asFiberReconciler
andFiberRenderer
. I'd like to get some feedback on this to know if its something that would be worth the effort, and whether or not I've overlooked anything major in the design.I have only tested it with very simple Views.
App
andScene
are not supported, as well as preferences. However, preferences may be simple to implement with this model as we traverse down then back up the tree in the main reconciler loop.