Skip to content

Link/cut tree for internal DomSlot for faster traversal - #4189

Draft
WorldSEnder wants to merge 14 commits into
yewstack:masterfrom
WorldSEnder:cut-link-dom-position
Draft

Link/cut tree for internal DomSlot for faster traversal#4189
WorldSEnder wants to merge 14 commits into
yewstack:masterfrom
WorldSEnder:cut-link-dom-position

Conversation

@WorldSEnder

Copy link
Copy Markdown
Member

Description

This prepares a change in the structure to a link/cut tree. We want clear ownership rules, where each DynamicDomSlot owns an internal node, the clones are only handles for it, but should not keep the slot alive.

Checklist

  • I have reviewed my own code
  • I have added tests

@WorldSEnder WorldSEnder changed the title remove Clone impl from DomPosition Link/cut tree for internal DomSlot for faster traversal Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit db88af9):

https://yew-rs-api--pr4189-cut-link-dom-positio-xkfeilrl.web.app

(expires Thu, 30 Jul 2026 19:15:16 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.458 ns      │ 2.553 ns      │ 2.462 ns      │ 2.466 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.555 ns      │ 2.999 ns      │ 2.562 ns      │ 2.572 ns      │ 100     │ 1000000000

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 291.251 295.779 291.948 1.358
Hello World 10 471.198 476.886 474.503 1.773
Function Router 10 30977.052 31381.939 31241.710 110.093
Concurrent Task 10 1006.504 1007.535 1007.216 0.365
Many Providers 10 1042.452 1102.741 1061.496 20.697

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 291.192 292.004 291.549 0.278
Hello World 10 458.559 462.531 460.395 1.701
Function Router 10 31566.432 32099.184 31853.847 165.184
Concurrent Task 10 1006.586 1008.159 1007.379 0.435
Many Providers 10 1031.203 1055.612 1043.756 7.833

This prepares a change in the structure to a link/cut tree.
We want clear ownership rules, where each DynamicDomSlot
owns an internal node, the clones are only handles for it, but
should not keep the slot alive.
@WorldSEnder
WorldSEnder force-pushed the cut-link-dom-position branch from d94d1b5 to 7e99014 Compare July 22, 2026 10:38
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.583 103.246 +2.663 +2.648%
boids 165.232 167.861 +2.629 +1.591%
communication_child_to_parent 94.031 96.627 +2.596 +2.760%
communication_grandchild_with_grandparent 106.415 109.041 +2.626 +2.468%
communication_grandparent_to_grandchild 102.730 105.357 +2.627 +2.557%
communication_parent_to_child 91.422 94.010 +2.588 +2.831%
contexts 106.681 109.221 +2.540 +2.381%
counter 86.600 89.264 +2.664 +3.076%
counter_functional 88.720 91.382 +2.662 +3.001%
dyn_create_destroy_apps 90.483 93.103 +2.619 +2.895%
file_upload 99.184 101.855 +2.672 +2.694%
function_delayed_input 95.025 97.688 +2.663 +2.802%
function_memory_game 168.904 171.423 +2.519 +1.491%
function_router 400.883 403.041 +2.158 +0.538%
function_todomvc 165.400 167.977 +2.576 +1.558%
futures 236.313 238.991 +2.678 +1.133%
game_of_life 100.983 103.651 +2.668 +2.642%
immutable 258.806 262.114 +3.309 +1.278%
inner_html 81.091 83.761 +2.670 +3.293%
js_callback 110.190 112.797 +2.606 +2.365%
keyed_list 176.195 178.789 +2.594 +1.472%
mount_point 84.510 87.175 +2.665 +3.154%
nested_list 113.095 115.713 +2.618 +2.315%
node_refs 92.025 94.618 +2.593 +2.817%
password_strength 1768.846 1771.485 +2.640 +0.149%
portals 93.920 96.551 +2.631 +2.801%
router 367.060 369.233 +2.174 +0.592%
suspense 114.389 116.937 +2.548 +2.227%
timer 88.832 91.528 +2.696 +3.035%
timer_functional 99.772 102.443 +2.671 +2.677%
todomvc 142.311 144.990 +2.680 +1.883%
two_apps 86.496 89.158 +2.662 +3.078%
web_worker_fib 136.824 139.456 +2.632 +1.924%
web_worker_prime 186.897 189.529 +2.632 +1.408%
webgl 83.232 85.908 +2.676 +3.215%

⚠️ The following examples have changed their size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.583 103.246 +2.663 +2.648%
boids 165.232 167.861 +2.629 +1.591%
communication_child_to_parent 94.031 96.627 +2.596 +2.760%
communication_grandchild_with_grandparent 106.415 109.041 +2.626 +2.468%
communication_grandparent_to_grandchild 102.730 105.357 +2.627 +2.557%
communication_parent_to_child 91.422 94.010 +2.588 +2.831%
contexts 106.681 109.221 +2.540 +2.381%
counter 86.600 89.264 +2.664 +3.076%
counter_functional 88.720 91.382 +2.662 +3.001%
dyn_create_destroy_apps 90.483 93.103 +2.619 +2.895%
file_upload 99.184 101.855 +2.672 +2.694%
function_delayed_input 95.025 97.688 +2.663 +2.802%
function_memory_game 168.904 171.423 +2.519 +1.491%
function_todomvc 165.400 167.977 +2.576 +1.558%
futures 236.313 238.991 +2.678 +1.133%
game_of_life 100.983 103.651 +2.668 +2.642%
immutable 258.806 262.114 +3.309 +1.278%
inner_html 81.091 83.761 +2.670 +3.293%
js_callback 110.190 112.797 +2.606 +2.365%
keyed_list 176.195 178.789 +2.594 +1.472%
mount_point 84.510 87.175 +2.665 +3.154%
nested_list 113.095 115.713 +2.618 +2.315%
node_refs 92.025 94.618 +2.593 +2.817%
portals 93.920 96.551 +2.631 +2.801%
suspense 114.389 116.937 +2.548 +2.227%
timer 88.832 91.528 +2.696 +3.035%
timer_functional 99.772 102.443 +2.671 +2.677%
todomvc 142.311 144.990 +2.680 +1.883%
two_apps 86.496 89.158 +2.662 +3.078%
web_worker_fib 136.824 139.456 +2.632 +1.924%
web_worker_prime 186.897 189.529 +2.632 +1.408%
webgl 83.232 85.908 +2.676 +3.215%

@WorldSEnder

Copy link
Copy Markdown
Member Author

@Madoshakalaka the cut tree forest impl is a bit dense. Apart from that, I am not so sure the code size costs are worth the performance. It should definitely save a bit of time in deeply nested things and I want to perf check this before a final judgement too. Thoughts?

@Madoshakalaka

Copy link
Copy Markdown
Member

wut, will have a look tomorrow!

@WorldSEnder

Copy link
Copy Markdown
Member Author

Removing the slab and going back to Rcs could be an avenue to remove a bit of bytes from the code section again. But I already dread borrowing and cloning these everywhere.

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