-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 ZEnvironment #8828
Comments
/bounty $1500 for a notably faster implementation of ZEnvironment that takes advantage of its unique usage patterns, and a benchmark proving this (with before / after results in PR). Ping @kyri-petrou |
💎 $1,500 bounty • ZIOSteps to solve:
Additional opportunities:
Thank you for contributing to zio/zio! Add a bounty • Share on socials
|
Thanks I'll give it a go 👍 |
💡 @kyri-petrou submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
🎉🎈 @kyri-petrou has been awarded $1,500! 🎈🎊 |
ZEnvironment is implemented atop existing data structures, which are not optimized for environment usage patterns.
A custom ZEnvironment can achieve significantly better performance by taking advantage of the following facts:
Scope
, are routinely stored in nearly every environment. This suggests a register-based hybrid design could be useful to accelerate performance for the services that are nearly always used in every ZIO application.One idea that could be explored (not to imply it is the best): append-only arrays with atomic reference for writer index, and snapshot int for reader index (see how appending a single element is implemented in
Chunk
for the idea). One array stores tags, the other, services. You lookup by traversing the array in reverse order, respecting the snapshot index so you don't read more than your copy is supposed to know about. Another idea: a linked list, where later ZEnvironment points to earlier ZEnvironment (I think this will be great at reusing structure, but poor at lookup performance due to cache locality issues).The text was updated successfully, but these errors were encountered: