yew icon indicating copy to clipboard operation
yew copied to clipboard

Cleanup ImplicitClone related stuff in the examples

Open cecton opened this issue 2 years ago • 5 comments

Description

What does this PR do?

  1. Use more cheap-to-clone types in the examples
  2. Some examples got impacted by #3453 (the removal of ToHtml), I fixed them so we can use reference where it makes sense (I added a few IntoPropValue on cheap-to-clone types)
  3. Updated implicit-clone to the latest version
  4. Optimized ChildrenRenderer memory allocations by using Rc

Changes did on the side:

  1. In order to get some example working, I had to change NodeSeq to use IArray. This is good because it is more optimized for memory allocations too
  2. Slightly improve the API of VChild to easily get a ref mut inside its properties object (just for convenience!)

Related to #3453

Checklist

  • [x] I have reviewed my own code
  • [x] I have added tests

cecton avatar Nov 01 '23 17:11 cecton

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.47 ns       │ 3.034 ns      │ 2.473 ns      │ 2.486 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.778 ns      │ 2.97 ns       │ 2.783 ns      │ 2.791 ns      │ 100     │ 1000000000

github-actions[bot] avatar Nov 01 '23 17:11 github-actions[bot]

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

https://yew-rs-api--pr3508-cleanup-implicit-clo-xpmvce0a.web.app

(expires Sun, 26 Nov 2023 10:10:39 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

github-actions[bot] avatar Nov 01 '23 17:11 github-actions[bot]

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 289.308 290.260 289.563 0.272
Hello World 10 477.933 500.649 481.669 6.983
Function Router 10 1595.919 1625.613 1603.911 8.295
Concurrent Task 10 1005.827 1007.602 1006.562 0.529
Many Providers 10 1137.344 1190.735 1149.246 16.474

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 289.470 290.042 289.685 0.179
Hello World 10 493.324 507.555 500.525 5.299
Function Router 10 1625.657 1644.951 1633.711 6.780
Concurrent Task 10 1005.268 1006.699 1006.241 0.472
Many Providers 10 1109.017 1125.740 1118.954 5.153

github-actions[bot] avatar Nov 01 '23 17:11 github-actions[bot]

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 100.268 100.273 +0.006 +0.006%
boids 173.785 174.488 +0.703 +0.405%
communication_child_to_parent 92.743 92.832 +0.089 +0.096%
communication_grandchild_with_grandparent 105.757 105.876 +0.119 +0.113%
communication_grandparent_to_grandchild 101.017 101.087 +0.070 +0.070%
communication_parent_to_child 89.086 89.167 +0.081 +0.091%
contexts 105.992 106.008 +0.016 +0.015%
counter 86.119 86.798 +0.679 +0.788%
counter_functional 86.507 87.036 +0.529 +0.612%
dyn_create_destroy_apps 88.983 89.560 +0.576 +0.648%
file_upload 99.992 100.283 +0.291 +0.291%
function_memory_game 172.397 173.153 +0.756 +0.438%
function_router 348.657 349.524 +0.867 +0.249%
function_todomvc 161.174 161.901 +0.728 +0.451%
futures 229.063 229.293 +0.229 +0.100%
game_of_life 110.172 110.262 +0.090 +0.082%
immutable 185.438 188.971 +3.532 +1.905%
inner_html 79.895 79.894 -0.001 -0.001%
js_callback 109.505 110.298 +0.793 +0.724%
keyed_list 199.575 200.350 +0.774 +0.388%
mount_point 82.785 82.786 +0.001 +0.001%
nested_list 113.885 116.348 +2.463 +2.163%
node_refs 90.323 90.403 +0.080 +0.089%
password_strength 1750.117 1750.190 +0.073 +0.004%
portals 93.461 94.175 +0.714 +0.764%
router 317.558 318.463 +0.905 +0.285%
simple_ssr 140.308 141.102 +0.794 +0.566%
ssr_router 385.899 386.830 +0.931 +0.241%
suspense 115.714 116.436 +0.722 +0.624%
timer 88.605 88.947 +0.342 +0.386%
timer_functional 97.970 98.859 +0.890 +0.908%
todomvc 141.336 142.071 +0.735 +0.520%
two_apps 85.824 85.826 +0.002 +0.002%
web_worker_fib 134.758 135.361 +0.604 +0.448%
web_worker_prime 184.959 184.998 +0.039 +0.021%
webgl 82.503 82.505 +0.002 +0.002%

⚠️ The following examples have changed their size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
immutable 185.438 188.971 +3.532 +1.905%
nested_list 113.885 116.348 +2.463 +2.163%

github-actions[bot] avatar Nov 01 '23 17:11 github-actions[bot]

@kirillsemyonkin now I think the benchmark results look good. Not a big improvement but not a lost either except maybe on the "baseline" but that's probably normal.

cecton avatar Nov 06 '23 11:11 cecton