tags:

views:

58

answers:

1

If I pmap a function onto a sequence how far ahead will the sequence be realised in parallel If I have a single thread reading from a sequence being produced in parallel?

will this be different if I wrap it in a seque:

(seque 30 (pmap do-stuff (range 30000)))

vs.

(pmap do-stuff (range 30000))
A: 

pmap provides no guarantees of how far ahead it will read on it's input sequence - presumably, not too much farther than what it needs to do its calculation.

(seque 30 ...) will realize and cache up to 30 elements from pmap's output sequence. That must logically be at least the first 30 from the input sequence. How far beyond that I can't say without looking at the implementation of pmap, which you probably ought not to depend upon.

I'm curious why you need to know this. The details of when a function executes, particularly in a pmap, are something you usually want abstracted away. If it's curiosity, great. But if you're depending on some side effect of the do-stuff function, you're Doing It Wrong(tm).

levand
curriosity mostly :)
Arthur Ulfeldt