Why is the threadpool for core.async in clojure created with fixed thread pool of # of cores times 2 plus 42?
Asked Answered
G

1

6

The threadpool implementation in core.async clojure library uses a FixedThreadPoolExecutor of size = # of cores * 2 + 42.

(defonce the-executor
  (Executors/newFixedThreadPool
    (-> (Runtime/getRuntime)
        (.availableProcessors)
        (* 2)
        (+ 42))
    (conc/counted-thread-factory "async-dispatch-%d" true)))

Is there a reason to use these numbers (# of cores times 2 plus 42) in particular? Is this optimal for all devices? I just want to know how did rich hickey (and contributors) settled with these numbers.


Thank you nullptr.

Here is the discussion for those who are interested: http://clojure-log.n01se.net/date/2013-08-29.html#15:45a

Gervase answered 17/10, 2014 at 18:26 Comment(1)
That algorithm was introduced here. You might try asking the author.Poisoning
C
2

Some discussion at the link below, but it's basically arbitrary.

https://groups.google.com/d/msg/clojure/mT-r3EDeC74/dvaFqHnAZxgJ

Confound answered 17/10, 2014 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.