-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Optimise zio.stream.ZChannel#mapOutZIOPar code
#9556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c2d5245 to
4e1e8b0
Compare
3f48da0 to
577273f
Compare
similar change to those made in this PR #9383
577273f to
c6b8ca4
Compare
regiskuckaertz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm👌
| val permits = Semaphore.unsafe.make(n0)(Unsafe) | ||
| val failureRef = Ref.unsafe.make[Cause[OutErr1]](Cause.empty)(Unsafe) | ||
|
|
||
| val setFinalizer: UIO[Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a val. it won't save you any performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just to follow the same code pattern used in #9383
I think this val will be inlined at runtime, so yeah, there are no changes in terms of performances. It's esthetic
|
|
||
| permits | ||
| .withPermit( | ||
| latch.succeed(()) *> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can unsafely complete the promise with Exit.unit to avoid an allocation here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! See #9571
| f(outElem) | ||
| .catchAllCause(cause => | ||
| failureRef.update(_ && cause).unless(cause.isInterruptedOnly) *> | ||
| errorSignal.succeed(()) *> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit.unit here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! See #9571
…when possible Idea comes from @hearnadam's review in this PR: #9556
…when possible Idea comes from @hearnadam's review in this PR: #9556
…when possible Idea comes from @hearnadam's review in this PR: #9556
…when possible Idea comes from @hearnadam's review in this PR: #9556
…when possible Idea comes from @hearnadam's review in this PR: #9556
…when possible (#9571) * Add internal `Promise#succeedUnit` method to avoid `Exit` allocation when possible Idea comes from @hearnadam's review in this PR: #9556 * fmt * Review: Use `whenZIODiscard` when possible
Similar changes to those made in this PR #9383
The optimisations are less significant than in #9383 (No
Resulttrick optimisation for example) as the code isn't really more optimisable, I think