It depends on your specific use case. Sometimes the overhead of parallelism 
overshadows the performance gains. The rule of thumb for any language is to 
first identify bottlenecks in your code through profiling and optimize 
accordingly. 

For a concrete example, a while ago I was created a program with Clojure 
which interprets 3D game assets in one format and re-exports them to 
another format. I needed to run this on thousands of files. After 
profiling, I found that parallelizing the conversion process for one asset 
was a red herring as I could barely saturate one thread before it finished. 
So instead of parallelizing the internals of the conversion process, I 
found it was much more efficient (and less complex) to just run the 
conversion process in parallel on many assets at the same time. This meant 
I could scale the import/export procedure linearly with CPUs, and it was 
incredibly simple to do with Clojure out of the box without increasing the 
complexity of the program at all. 

I know this is a relatively obvious use of parallelism, but my point is 
that while sometimes it's tempting to try to parallelize things all the way 
down my experience has taught me that parallelism is often more important 
at the I/O boundaries of your program, whatever that may be. 

On Sunday, April 17, 2016 at 5:23:32 PM UTC-4, JvJ wrote:
>
> Orders of magnitude?  Is it even worth running things in parallel in this 
> case?
>
> On Sunday, 17 April 2016 07:20:30 UTC-7, tbc++ wrote:
>>
>> The cost of creating that extra collection will be vastly overshadowed by 
>> the cost of running pmap. pmap involves the use of several locks, and 
>> thread co-ordination primitives, these will most likely be orders of 
>> magnitude more expensive than an extra allocation. 
>>
>> Timothy
>>
>> On Sun, Apr 17, 2016 at 12:38 AM, JvJ <kfjwh...@gmail.com> wrote:
>>
>>> Perhaps I should have rephrased.  I meant calling it in such a way that 
>>> the result is a hash map.
>>>
>>> I know I could do something like:
>>>
>>> (into a (pmap f a))
>>>
>>> This will give the same result, but there's an extra collection in there 
>>> that I'm not sure is necessary.
>>>
>>>
>>> On Saturday, 16 April 2016 20:15:51 UTC-7, Alex Miller wrote:
>>>>
>>>> You can call pmap on hash maps!
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> “One of the main causes of the fall of the Roman Empire was that–lacking 
>> zero–they had no way to indicate successful termination of their C 
>> programs.”
>> (Robert Firth) 
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to