This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-12
Channels
- # announcements (2)
- # beginners (36)
- # boot (6)
- # calva (2)
- # cider (18)
- # clj-kondo (1)
- # cljdoc (2)
- # cljs-dev (2)
- # clojure (130)
- # clojure-boston (1)
- # clojure-brasil (3)
- # clojure-czech (1)
- # clojure-europe (11)
- # clojure-italy (4)
- # clojure-losangeles (37)
- # clojure-nl (9)
- # clojure-seattle (2)
- # clojure-sweden (8)
- # clojure-uk (23)
- # clojurescript (13)
- # core-async (21)
- # cursive (13)
- # data-science (6)
- # datomic (12)
- # emacs (36)
- # figwheel-main (9)
- # fulcro (76)
- # juxt (2)
- # keechma (18)
- # leiningen (4)
- # off-topic (13)
- # pedestal (37)
- # re-frame (21)
- # reitit (2)
- # shadow-cljs (78)
- # spacemacs (23)
- # sql (13)
- # tools-deps (25)
- # uncomplicate (4)
- # unrepl (1)
- # vim (27)
Any idea why thread is slower than go blocks
That is a meaningless question
@alexmiller what am I missing?
Everything? I’m not even sure where to start
This code is nonsensical. Starting from an actual meaningful problem would be a good first step.
I am trying to come up with a simple code snippet that demonstrates how go blocks work
thread and go are for different purposes, and that is a more meaningful decision dimension than perf
I know that
My purpose is didactic
Then start from a meaningful problem
I did that
What is it?
Writing in parallel to a db
We’ll go blocks shouldn’t block, so that’s a bad problem to demonstrate go blocks
I don’t know how to help you
Can you think of a simple way to demonstrate that go blocks don’t have a perfomance hit?
Spawn threads is slower then "spawn" go blocks
(time
(dotimes [i 1e6]
(async/go i)))
"Elapsed time: 476.882375 msecs"
=> nil
(time
(dotimes [i 1e6]
(async/thread i)))
"Elapsed time: 1285.235322 msecs"
As Alex said, it isn't irrelevant, once they have different proposes and on both proposes, the performance implications arent related with "spawn" cost.Go blocks are a process and communication tool. They are about organizing the running parts of your program. Performance is not imo a concern that enters that equation