Repository navigation
Avoid root dirty delta for shared state events - #6841
FarhanAliRaza merged 34 commits into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Merging this PR will improve performance by 4.79%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Confidence Score: 4/5
[Medium impact] Changes how shared state computes dirty variables after updates. The PR is not yet safe to merge because discarded resolution failures can leave dirty state and refreshed caches behind, and unchanged router-dependent computed values are still emitted. SummaryThe PR changes linked/shared-state patching to invalidate only computed variables that depend on router data instead of dirtying the router fields themselves.
Reviews (35) · Last reviewed commit: "Make the link case of the delta test rel..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
hey @masenf The state-dirty cleanup changes and regression tests are now implemented, including descendant cleanup when delta resolution fails. Most CI checks are passing, but reflex-install-and-init is failing. Could you confirm whether that failure is infrastructure-related or requires a code change? Once it passes, could you please review the latest commit? |
masenf
left a comment
There was a problem hiding this comment.
patch breaks delta calculation for computed vars in shared state that depend on root state.
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
hey @MANsef could you please review the latest commit? |
|
hey @masenf please take a look!! |
Replace the tests of the snapshot and rollback machinery with tests of what a client receives: the shared change and the router readers computed for its own tree, without the unchanged router, whether the event links the state or not; a router change made by the event itself; a synced storage value. The link case fails here: linking still sends the unchanged router.
_patch_state marked the root's router fields dirty to recompute the computed vars that read them. The fields themselves had not changed, but they stayed dirty and were sent with every event of a linked client. Mark their readers dirty instead, and leave the root's dirty vars alone. This replaces the snapshot and rollback of the whole tree, and the storage sync bookkeeping it needed, with one call.
The redis lock queue and app name validation test changes do not concern linked-state deltas. Restore them to main.
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Summary
Tests
uv run --frozen pytest tests/units/test_state.py::test_linked_state_event_does_not_dirty_root_state -quv run --frozen pytest tests/units/test_state.py::test_linked_state_event_does_not_dirty_root_state tests/units/test_state.py::test_router_var_dep tests/units/test_state.py::test_computed_var_depends_on_parent_non_cached tests/units/test_state.py::test_async_computed_var_get_state -quv run --frozen pytest tests/units/test_state.py -quv run --frozen pre-commit run --files reflex/istate/shared.py tests/units/test_state.py news/6841.bugfix.mdCloses #6392