Skip to content
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

Minor optimizations for ZPure's runloop #1474

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

kyri-petrou
Copy link
Contributor

I came across a few things in the ZPure runloop that could be optimized since it was initially rewritten about a year ago.

Main changes:

  1. Since there's only 1 flag type, remove Flag and replace it with ClearLogOnError in order to avoid pattern matching on the flag type in the runloop
  2. Use return Left(err) instead of throwing an exception and catching it later. This is more optimized as the C2 compiler doesn't optimize branches when an exception is thrown (even if it doesn't fill stack-traces). We saw this previously in ZIO where we used to throw an exception for yielding in the runloop (which was then replaced by returning null instead)
  3. Remove a few redundant intermediate vals (which we previously needed just to call .asInstanceOf on).

@kyri-petrou kyri-petrou requested a review from a team as a code owner February 10, 2025 01:50
@kyri-petrou kyri-petrou merged commit 90ea08c into zio:series/2.x Feb 10, 2025
20 checks passed
@kyri-petrou kyri-petrou deleted the optimize-zpure-runloop branch February 10, 2025 03:47
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.

2 participants