Comments (4)
Also Rust coupled both IO and a task parallelism in the past and decided to avoid that:
https://github.com/aturon/rfcs/blob/remove-runtime/active/0000-remove-runtime.md
https://github.com/rust-lang/rfcs/blob/master/text/0230-remove-runtime.md
from weave.
An idea on how to play well with Asyncdispatch or Chronos or any future async/await library.
They all offer a poll()
function that runs their event loop.
We can add a field pollHook*: proc() {.nimcall, gcsafe.}
on each worker.
It would be setup by setPollingFunction(_: typedesc[Weave], poll: proc() {.nimcall, gcsafe.})
before Weave initialization (at first, can be relaxed later).
Then we modify loadBalance()
, sync()
, syncScope()
to interleave pollHook
calls before and after executing a task.
Note that loadBalance()
is called in-between each parallelFor
iterations:
- If loop is fine-grained, even if it's executed on the main thread, there are plenty of opportunities to handle IO event.
- If there is no hook, the
if not pollHook.isNil:
is very predictable and should be costless - If there is a hook, the syscalls to handle the IO event will probably slow down fine-grained parallelism a lot and also completely flush the CPU caches with data loaded by the kernel. This is bad, there are some ways to "mitigate" that:
- Document the tradeoff
- Only install the hook on the main thread, so that worker threads are not polluted
- Give the option to install the hook on either the main thread or all thread.
Note that worker threads will sleep if they have no tasks, but it does not make sense for them to try to handle IO events without a task.
A potential issue is that a task can be migrated or for a parallel loop, it can even be split and then executed on 2 different threads, i.e. are the async libraries using {.threadvar.}
to manage some global state? Because that will not work.
from weave.
RFC #132 and its implementation with Weave as an independent background service is probably a better path forward #136
from weave.
See https://github.com/weavers-guild/weave-io
from weave.
Related Issues (20)
- background processing some submits go missing
- windows aligned_alloc in allocs.nim have different params order compared to docs and malloc.h
- [Request] Optional per-thread startup procedure HOT 1
- `blockUntilAny` equivalent
- GC Boehm Error with more than 8 threads HOT 2
- parallelFor has arguments that do not fit in the parallel tasks data buffer HOT 9
- a plea for an easier to understand error message HOT 3
- Recent Nim makes Weave crash HOT 8
- affinity_posix should get this patch (for Android/Termux)
- @mratsim
- Cache misses (much) worse for page-aligned (e.g. power of two) accesses
- Raytracing example doesnt compile with threads HOT 1
- UX: auto-transform captured seq to ptr UncheckedArray behind the scenes HOT 3
- functions with no arguments fail parsing HOT 1
- Is there a manual or tutorial for weave? HOT 2
- Weave doesn't compile on MacOS with arm64 HOT 2
- Error: undeclared identifier: 'gebb_ukernel_int_x86_AVX512' HOT 2
- Feature Request: Cores as init parameter, respect core perf levels
- Vastly simplify and accelerate memory management. HOT 1
- Use Lnear Congruential Generator to generate work-stealing permutation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weave.