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

Improve performance of ZQuery#run #497

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

kyri-petrou
Copy link
Collaborator

The current performance of ZQuery#run if fairly bad, since it does quite a few things:

  1. Creates a Scope and closes it
  2. Modifies 2 FiberRefs and reverts them

While the cost of run is amortised on large queries, it can become very noticeable when running simple queries.
This PR improves its performance by ~500-600x by:

  1. using lower level ZIO methods to handle interruption and addition/deletion of FiberRefs
  2. implementing a very lightweight alternative to Scope without all the bells and whistles. This is more than adequate for the usage in zio-query as its only usage is to store potential failures during ZQuery.acquireRelease

@kyri-petrou kyri-petrou merged commit 64b1799 into zio:series/2.x Jul 10, 2024
21 checks passed
@kyri-petrou kyri-petrou deleted the improve-run-performance branch July 10, 2024 11:46
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.

1 participant