Skip to content

Update to cats-effect 1.0 and use Timer as necessary for IO - #2814

Merged
echeipesh merged 2 commits into
masterfrom
feature/cats-effect-1.0
Oct 12, 2018
Merged

echeipesh merged 2 commits into
masterfrom
feature/cats-effect-1.0

Conversation

@moradology

Copy link
Copy Markdown
Contributor

This brings cats-effect to 1.0, which should be faster and have a more stable API going forward.

@moradology
moradology requested a review from echeipesh October 3, 2018 17:02
@moradology moradology changed the title Use Timer as necessary for IO uses Use Timer as necessary for IO Oct 3, 2018

@echeipesh echeipesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good, needs CQs


val results = (rows flatMap elaborateRow flatMap rowToBytes map retire)
.join(threads)
val results = (rows flatMap elaborateRow flatMap rowToBytes flatMap retire)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be a join(threads) equivalent? i was not sure, that's why decided to make it clear, to keep things simple.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or probably it's a 1.0 feature for sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantically equivalent, I believe so, but we lose some parallelism here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We loose some parallelism? What do you mean? You mean that the behaviour would differ significantly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moradology don't you want to use explicit .parJoin(threads) instead of a flatMap on the last step?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit val cs: ContextShift[IO] = IO.contextShift(ec)
(index map readRecord)
        .parJoin(threads)
        .compile
        .toVector
        .unsafeRunSync.flatten

@moradology moradology Oct 4, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We certainly can, I just wasn't sure people would be pleased with extra implicits flying around without significant/obvious performance wins.

For the sake of argument, why not
((first map second).parJoin(threads) map third).parJoin(threads) where possible?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moradology no, it is a question for you, as you introduced this change, i was just asking :D

Comment thread project/Dependencies.scala
@moradology
moradology force-pushed the feature/cats-effect-1.0 branch from 0c18b7c to 2677f7a Compare October 3, 2018 21:04
@pomadchin pomadchin mentioned this pull request Oct 4, 2018
21 tasks done
@pomadchin

pomadchin commented Oct 4, 2018 •

Copy link
Copy Markdown
Member

@pomadchin pomadchin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of the join step should be reverted, as it creates a significant performance loss.
All old joins should be replaced with a new parJoin.

.join(threads)
val results = rows
.map(elaborateRow)
.parJoin(threads)

@pomadchin pomadchin Oct 4, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w0000t, i think

(rows flatMap elaborateRow flatMap rowToBytes map retire).parJoin(threads)

would be enough! It's already tested and benchmarked long ago, so probably you can just replace all joins with parJoins.

.join(threads)
rows
.map(elaborateRow)
.parJoin(threads)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here, no needs in so many parJoins :D

@pomadchin pomadchin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moradology
moradology force-pushed the feature/cats-effect-1.0 branch from 4cb1a3d to a47773d Compare October 4, 2018 16:52

@pomadchin pomadchin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we need to bump fs2 up to 1.0.0: https://github.com/functional-streams-for-scala/fs2/releases/tag/v1.0.0 and cats up to 1.4.0

@moradology
moradology force-pushed the feature/cats-effect-1.0 branch from fce0693 to 333054d Compare October 8, 2018 18:02
@pomadchin pomadchin added this to the 2.1 milestone Oct 12, 2018
@echeipesh
echeipesh merged commit f9f2ef5 into master Oct 12, 2018
echeipesh pushed a commit that referenced this pull request Oct 12, 2018
* cats-core 1.4.0
* cats-effect 1.0.0
* fs2 1.0.0
@echeipesh echeipesh changed the title Use Timer as necessary for IO Update to cats-effect 1.0 and use Timer as necessary for IO Oct 12, 2018
@echeipesh
echeipesh deleted the feature/cats-effect-1.0 branch June 15, 2019 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants