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

Optimize ZIO.attempt #7920

Merged
merged 1 commit into from
Mar 21, 2023
Merged

Optimize ZIO.attempt #7920

merged 1 commit into from
Mar 21, 2023

Conversation

adamgfraser
Copy link
Contributor

We can make this slightly faster by only looking up the definition of a fatal error if an exception is thrown.

@adamgfraser
Copy link
Contributor Author

This does mean that if a fatal error does occur we need to execute one more workflow after that to get the definition of a fatal error so maybe this doesn't make sense.

@jdegoes
Copy link
Member

jdegoes commented Mar 14, 2023

I wonder if we should just intern it.

@adamgfraser
Copy link
Contributor Author

Isn't the problem that the definition of a fatal error is itself a regional setting stored in a FiberRef so for correctness we have to look it up at some point? We could move the whole thing into the runtime but I don't think it is worth it. In microbenchmarks ZIO.succeed is about 10% faster than ZIO.attempt right now and with this change that difference goes down to about 5%.

@jdegoes
Copy link
Member

jdegoes commented Mar 21, 2023

All right, sounds good to me.

@jdegoes jdegoes merged commit e920c19 into zio:series/2.x Mar 21, 2023
@adamgfraser adamgfraser deleted the attempt branch March 24, 2023 11:09
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.

None yet

3 participants