This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-22
Channels
- # announcements (88)
- # autochrome-github (2)
- # babashka (26)
- # beginners (5)
- # biff (2)
- # cider (73)
- # clj-kondo (4)
- # cljsrn (6)
- # clojure (54)
- # clojure-art (3)
- # clojure-europe (73)
- # clojure-germany (5)
- # clojure-new-zealand (1)
- # clojure-nl (13)
- # clojure-norway (16)
- # clojure-uk (8)
- # clojurescript (73)
- # conjure (1)
- # core-async (10)
- # cursive (17)
- # datahike (51)
- # datalevin (21)
- # datomic (4)
- # emacs (2)
- # events (3)
- # fulcro (35)
- # honeysql (6)
- # introduce-yourself (1)
- # jackdaw (3)
- # jobs (1)
- # leiningen (4)
- # lsp (3)
- # malli (17)
- # off-topic (60)
- # other-languages (5)
- # pathom (17)
- # pedestal (3)
- # polylith (19)
- # portal (2)
- # practicalli (1)
- # rdf (14)
- # reitit (3)
- # releases (1)
- # reveal (9)
- # sci (1)
- # shadow-cljs (26)
- # spacemacs (17)
- # sql (4)
- # testing (10)
- # tools-build (6)
- # tools-deps (16)
- # vim (9)
I stumbled over an implementation detail in core.async
that puzzles me. We have pipeline
and pipeline-blocking
, with the latter being documented as “Like pipeline, for blocking operations.“. However, they seem to have exactly the same implementation:
• Both delegate to pipeline*
, passing a type
argument with :compute
for pipeline
and :blocking
for pipeline-blocking
• In pipeline*
, :compute
and :blocking
are treated the same: (case type (:blocking :compute) … :async …)
Has that been changed since the original intention? Or is that to allow future optimizations?
As far as I remember, pipeline
will execute the xform in go
-blocks, whilst pipeline-blocking
executes it in thread
-blocks
I thought so as well, but it does not. Both pipeline
and pipeline-blocking
will spin off thread
s to do the work:
https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L549
Huh... Checked again, and it seems the impl I used to see is gone.
Seems to have been changed here: https://github.com/clojure/core.async/commit/3429e3e1f1d49403bf9608b36dbd6715ffe4dd4f
> • Release 0.5.527 on 2019.11.12 > ◦ … > ◦ Fix use of blocking op and thread constraints in `pipeline` - will now match `pipeline-blocking` in using N cached threads.
OK, there seems to have been a good reason to do so 😉
Using go-blocks for CPU is a bad idea so pipeline
fixed that oversight.
Theoretically, you can't have more threads running than CPU cores, therefor it makes sense for CPU threads to be used in a pool the size of available processors. Blocking IO, on the other hand, can take as many threads as you have memory available
These impls may diverge again in the future