-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
chore: simplify process_effects
#13297
Conversation
|
Did you run the bench on this to confirm the wins? |
I did, but more to confirm there were no regressions. It was basically noise as far as I could tell — by all means take a closer look on your machine if you want to be confident in the change |
Do we still need the branch effect in |
Tests fail without it. I guess the root component needs to be in a branch, because otherwise things like this will yield the wrong result
|
Okay so after benchmarking this against #13282 and also just the simple check before of if (has_dirty_children) current_effect.f ^= EFFECT_HAS_DIRTY_CHILDREN; However, there are probably other bigger changes to This line takes 81.2ms for the entire benchmark as is by far the most expensive line in this function. |
|
||
queued_root_effects.push(effect); | ||
effect.f |= EFFECT_HAS_DIRTY_CHILDREN; |
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.
This line is also super expensive, it's now 12ms, before the:
set_signal_status(effect, MAYBE_DIRTY);
was only 1.9ms
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 the design changes this PR brings, but it seems that mutating every signal as we traverse up is just really ineffective for performance. In fact it brings performance regressions over what we currently have on main
in regards to benchmarks. We also seem to spend far more time in process_effects
than before.
So I think we need rethink this implementation. Writes are far more expensive than reads, and I think this is reflected in #13282.
Follow-up to #13282 (review), alternative to #13282. This adds a new
EFFECT_HAS_DIRTY_CHILDREN
flag on effects which allows us to makeschedule_effect
andprocess_effects
more self-explanatory.Before,
schedule_effect
would set theMAYBE_DIRTY
flag on branches as a proxy for 'this branch has dirty children'. But that's imperfect — it means that we only bail out when we hit a branch, and it means that branches are regarded as potentially dirty even though that's impossible (they are nodes in the effect tree, but unlike other effects they themselves do not update).Using
MAYBE_DIRTY
as a proxy value also required some logic insideprocess_effects
that candidly I am not clever enough to comprehend. The code in this PR feels a good deal simpler, at least to me.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint