(defn sum [numbers]
(reduce + numbers))
(def numbers (into [] (range 0 100000000)))
(time (sum numbers))
The above was the code that was ran.
Simply adding up a lot of numbers.
This line was executed in the repl multiple times:
(time (sum numbers))
Each time it almost gets all cores fully running.
Looking at jvisualvm, there were not a lot of threads created.
But this code used all 12 of the hyperthreads that were available on my 6 core laptop.
What was happening behind the scene that made this possible?
Thanks to the comments.
It has to do with the size of the range.
On my laptop, when it's around 70 million numbers, all is fine.
When it gets around 80 millions, the heap size grows a lot, the time taken grows very significantly, and all cores get to work. And visual vm shows more GC activity was happening.
So the comments above are probably right, it has to do with GC.