wildnux
wildnux

Reputation: 448

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

Upvotes: 6

Views: 756

Answers (1)

Derek Slager
Derek Slager

Reputation: 13851

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

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

Upvotes: 2

Related Questions