-
-
Notifications
You must be signed in to change notification settings - Fork 76
Per default refetch the chain tip at most every 20 seconds #211
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
Using the opshin-starter-kit as an example Before
After
This is a speed up from 40s to 7s and the script only builds a simple transaction! |
At the current state, every access to protocol params causes at least one chain tip fetch. Due to the potential delay of this request, often another protocol params fetch is triggered as well. This significantly (and mostly unnecessarily) slows down transaction building. This fix caches the chain tip for a default of 20 seconds (the average slot time), making sure that subsequent calls to _is_chain_tip_updated return without any delay, drastically speeding up tx building.
5804264
to
8b8269a
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #211 +/- ##
==========================================
- Coverage 85.60% 85.53% -0.07%
==========================================
Files 26 26
Lines 2882 2889 +7
Branches 693 694 +1
==========================================
+ Hits 2467 2471 +4
- Misses 305 308 +3
Partials 110 110
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it 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.
Nice! I can image how much queries this optimization will reduce :D
An optimal design would have a few threads that asynchronousmy fetch the chain tip, the protocol params, the epoch and such and fetch it. Then access to those values is instant and they are almost never outdated. |
The test failed. I had a fix but can't push to your fork. Could you pull the fix into your fork? |
Fix Ogmios test
Neat, multi-player PR |
At the current state, every access to protocol params causes at least one chain tip fetch. Due to the potential delay of this request, often another protocol params fetch is triggered as well.
This significantly (and mostly unnecessarily) slows down transaction building. This fix caches the chain tip for a default of 20 seconds (the average slot time), making sure that subsequent calls to _is_chain_tip_updated return without any delay, drastically speeding up tx building.