-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Configurable Runtime #2772
Configurable Runtime #2772
Conversation
Visit the preview URL for this PR (updated for commit 6cd8c64): https://yew-rs-api--pr2772-local-runtime-8kie5tce.web.app (expires Sun, 04 Sep 2022 14:20:13 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
✅ None of the examples has changed their size significantly. |
SSR Benchmark Example: https://github.com/yewstack/yew/runs/7166129506?check_suite_focus=true#step:7:386 This benchmark will continue to fail until master has a benchmark present. |
I have updated the examples to process requests within Yew Runtime instead of the default tokio runtime. This increases performance significantly for Function Router Results in a 4 core Debian VMBefore (e117d3f)
After (9453ba7)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it took so long to get to this PR
Can you also explain/document why this is needed? Is it to allow future support for other runtimes?
Also, how does it tie with #2839?
type SpawnTask = Box<dyn Send + FnOnce()>; | ||
|
||
thread_local! { | ||
static TASK_COUNT: RefCell<Option<Arc<AtomicUsize>>> = RefCell::new(None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use Arc<AtomicUsize>
for a thread local? I think Cell
(or Rc<Cell>
) should do the job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a task is spawned with spawn_pinned
, the task count is increased from the thread that spawns the task. This allows the task count to be increased before the task spawner receives the task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The reason why a configuration runtime is needed is still unclear to me. Can you explain that?
This allows users to set their own number of threads.
This exposes |
Description
This pull request adds a
Runtime
type to make the runtime configurable.Checklist