streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Fix zipWith to work concurrently according to the stream type

Open harendra-kumar opened this issue 6 years ago • 5 comments
trafficstars

zipWith and zipWithM currently work serially. They should instead work according to the stream type. For example, if the stream type is Async then they can zip multiple pairs concurrently out of order. For testing, one use case of this is mentioned in #100 .

The fix is simple, we need to use consM to build the stream, just like we do in concurrent mapM. We will just have to test it, that it works as expected.

cc @naushadh

harendra-kumar avatar Dec 07 '18 14:12 harendra-kumar

I suppose this is complementary to the existing zipAsyncWith?

naushadh avatar Dec 09 '18 23:12 naushadh

zipAsyncWith makes sure that the actions from both the streams being zipped are executed concurrently, once it has the two items to zip, then it uses zipWith to zip the two items. So only one zip happens at a time. In case of ahead/async streams we can have multiple zips going on at the same time.

harendra-kumar avatar Dec 10 '18 03:12 harendra-kumar

@adithyaov if this is fixed then you can close it.

harendra-kumar avatar Apr 19 '21 15:04 harendra-kumar

Reopened by #1125, the commit was reverted by e09428332cb7a12effc52c5ad9c89dd6bcb36504.

harendra-kumar avatar Jun 22 '21 07:06 harendra-kumar

We can possibly have zipConcurrentlyWithM for concurrent zipping. We should leave zipWith(M) alone as they break existing code.

adithyaov avatar Feb 02 '22 20:02 adithyaov