Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 251
wildnux Avatar asked Oct 17 '14 18:10

wildnux


1 Answers

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

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

like image 102
Derek Slager Avatar answered Sep 20 '22 19:09

Derek Slager