yew icon indicating copy to clipboard operation
yew copied to clipboard

Agent v2

Open futursolo opened this issue 3 years ago • 2 comments

Description

This pull request consists of the following changes:

  • Adapts the Worker v2 format.
  • Agents are now managed via context providers.
  • Adds Task Agent (For each agent a single input and a single output is expected)
  • Adds Reactor Agent (For each agent, multiple inputs and multiple outputs are expected)
  • SSR support for memorised Tasks.

This pull request needs the following pull requests:

  • #2769
  • #2772

Questions to solve:

  • In Rust, a running asynchronous coroutine is also commonly named task. This may cause confusion to users. I do not have a better name for this, so I am open to suggestions to an alternative name than task.

Still missing:

  • tests
  • documentation

Checklist

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

futursolo avatar Jul 03 '22 05:07 futursolo

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 102.400 102.400 0 0.000%
boids 175.517 175.517 0 0.000%
communication_child_to_parent 95.192 95.192 0 0.000%
communication_grandchild_with_grandparent 108.853 108.853 0 0.000%
communication_grandparent_to_grandchild 105.512 105.512 0 0.000%
communication_parent_to_child 92.666 92.666 0 0.000%
contexts 110.855 110.854 -0.002 -0.002%
counter 89.184 89.184 0 0.000%
counter_functional 89.898 89.898 0 0.000%
dyn_create_destroy_apps 92.216 92.216 0 0.000%
file_upload 103.502 103.502 0 0.000%
function_memory_game 174.346 174.346 0 0.000%
function_router 352.358 352.358 0 0.000%
function_todomvc 163.306 163.306 0 0.000%
futures 227.728 227.728 0 0.000%
game_of_life 112.343 112.343 0 0.000%
immutable 188.890 188.890 0 0.000%
inner_html 85.984 85.984 0 0.000%
js_callback 112.964 112.964 0 0.000%
keyed_list 201.191 201.191 0 0.000%
mount_point 89.182 89.182 0 0.000%
nested_list 114.456 114.456 0 0.000%
node_refs 96.135 96.135 0 0.000%
password_strength 1583.067 1583.067 0 0.000%
portals 98.212 98.212 0 0.000%
router 318.345 318.345 0 0.000%
simple_ssr 143.629 143.629 0 0.000%
ssr_router 389.573 389.573 0 0.000%
suspense 118.691 118.691 0 0.000%
timer 91.778 91.778 0 0.000%
timer_functional 100.289 100.289 0 0.000%
todomvc 143.661 143.661 0 0.000%
two_apps 89.890 89.890 0 0.000%
web_worker_fib 154.500 138.492 -16.008 -10.361%
web_worker_prime N/A 190.053 N/A N/A
webgl 88.500 88.500 0 0.000%

⚠️ The following example has changed its size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
web_worker_fib 154.500 138.492 -16.008 -10.361%

github-actions[bot] avatar Jul 03 '22 05:07 github-actions[bot]

Size Comparison

⚠️ The following example has changed its size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%) web_worker_fib 153.862 180.933 +27.070 +17.594%

This is partially due to the migration from struct components to function components.

I have produced a copy from both the master branch and the agent-v2 branch with agent related code removed and the size has increased for about 13KB.

Still need to reduce on bundle size impact by the new agent design.

futursolo avatar Jul 03 '22 07:07 futursolo

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 392.740 392.965 392.830 0.081
Hello World 10 679.083 716.051 691.071 9.492
Function Router 10 2181.041 2205.149 2191.581 7.298
Concurrent Task 10 1005.668 1007.770 1006.997 0.711
Many Providers 10 1566.308 1634.042 1583.505 21.070

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 392.738 393.056 392.913 0.119
Hello World 10 685.198 693.142 688.173 2.252
Function Router 10 2166.906 2204.736 2190.616 10.098
Concurrent Task 10 1006.418 1007.982 1007.204 0.428
Many Providers 10 1555.789 1614.216 1574.858 16.574

github-actions[bot] avatar Jul 29 '23 14:07 github-actions[bot]

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

https://yew-rs-api--pr2773-agent-v2-89fbe0ir.web.app

(expires Sat, 09 Sep 2023 09:10:04 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

github-actions[bot] avatar Aug 10 '23 13:08 github-actions[bot]

We should have a struct components example too

I think it is fine with without struct component examples. Just like the tutorial is switched to all function components, we should continue to promote users to use function components.

futursolo avatar Sep 02 '23 09:09 futursolo

I'm wondering if there's a way to have an async function that is run inside a worker and the result of it can be .awaited on the main thread?

Isn't that the oneshot worker / agent?

https://github.com/rustwasm/gloo/blob/master/examples/markdown/src/lib.rs#L5

futursolo avatar Sep 18 '23 08:09 futursolo