Skip to content
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

Enable PartialEq for all virtual dom types #3206

Merged
merged 4 commits into from
Apr 4, 2023

Conversation

futursolo
Copy link
Member

@futursolo futursolo commented Apr 2, 2023

Description

This pull request enables partial eq on all virtual dom types, so re-render can be avoided if VNode matches.
Previously, VNode comparison always evaluate to false when VComp is present and this will result in a re-render for any Html that contains a VComp.
This pull request addresses this issue.
This pull request also fixes a regression introduced in #3050 where PartialEq is wrongly evaluated via pointer comparison.

Checklist

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

github-actions[bot]
github-actions bot previously approved these changes Apr 2, 2023
@futursolo futursolo added A-yew Area: The main yew crate breaking change labels Apr 2, 2023
@github-actions
Copy link

github-actions bot commented Apr 2, 2023

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

https://yew-rs-api--pr3206-enable-vcomp-vgpur25w.web.app

(expires Mon, 10 Apr 2023 03:03:12 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 104.200 104.200 0 0.000%
boids 174.138 174.459 +0.321 +0.185%
communication_child_to_parent 94.919 95.111 +0.192 +0.203%
communication_grandchild_with_grandparent 105.838 106.657 +0.819 +0.774%
communication_grandparent_to_grandchild 102.016 102.787 +0.771 +0.756%
communication_parent_to_child 92.246 92.436 +0.189 +0.205%
contexts 108.437 109.522 +1.086 +1.001%
counter 90.292 90.292 0 0.000%
counter_functional 90.622 90.622 0 0.000%
dyn_create_destroy_apps 93.165 93.165 0 0.000%
file_upload 104.141 104.141 0 0.000%
function_memory_game 166.490 167.780 +1.290 +0.775%
function_router 333.638 337.899 +4.262 +1.277%
function_todomvc 161.998 162.893 +0.895 +0.552%
futures 227.549 227.549 0 0.000%
game_of_life 110.437 110.437 0 0.000%
immutable 186.137 188.956 +2.819 +1.515%
inner_html 86.940 86.940 0 0.000%
js_callback 112.552 113.808 +1.256 +1.116%
keyed_list 200.876 201.074 +0.198 +0.099%
mount_point 90.052 90.052 0 0.000%
nested_list 113.540 114.392 +0.852 +0.750%
node_refs 97.100 97.293 +0.193 +0.199%
password_strength 1544.284 1544.477 +0.192 +0.012%
portals 98.089 98.559 +0.470 +0.479%
router 305.075 308.331 +3.256 +1.067%
simple_ssr 143.062 144.186 +1.123 +0.785%
ssr_router 370.452 374.711 +4.259 +1.150%
suspense 109.662 110.923 +1.261 +1.150%
timer 93.163 93.163 0 0.000%
todomvc 144.484 144.484 0 0.000%
two_apps 90.943 90.943 0 0.000%
web_worker_fib 154.885 154.885 0 0.000%
webgl 89.606 89.606 0 0.000%

⚠️ The following examples have changed their size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
contexts 108.437 109.522 +1.086 +1.001%
function_router 333.638 337.899 +4.262 +1.277%
immutable 186.137 188.956 +2.819 +1.515%
js_callback 112.552 113.808 +1.256 +1.116%
router 305.075 308.331 +3.256 +1.067%
ssr_router 370.452 374.711 +4.259 +1.150%
suspense 109.662 110.923 +1.261 +1.150%

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 371.489 371.815 371.622 0.105
Hello World 10 673.220 677.230 675.792 1.173
Function Router 10 2266.030 2316.237 2289.750 12.379
Concurrent Task 10 1007.006 1008.163 1007.731 0.391
Many Providers 10 1830.292 1926.574 1864.292 33.556

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 371.514 374.012 371.902 0.754
Hello World 10 712.275 719.286 716.550 2.210
Function Router 10 2307.271 2355.357 2336.511 16.809
Concurrent Task 10 1006.820 1008.407 1007.617 0.418
Many Providers 10 1773.505 1844.284 1802.089 18.035

@futursolo futursolo marked this pull request as draft April 2, 2023 15:54
Comment on lines -257 to +258
// 1 initial render + 3 update steps
assert_eq!(obtain_result_by_id("test-0"), "total: 4");
// 1 initial render + 1 magic
assert_eq!(obtain_result_by_id("test-0"), "total: 2");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates that this pull request is working in reducing unnecessary renders.

@futursolo
Copy link
Member Author

Unfortunately, this does increase the bundle size as it includes a eq method on each component.

@futursolo futursolo marked this pull request as ready for review April 3, 2023 03:24
@futursolo futursolo merged commit 934aedb into yewstack:master Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants