-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework pool metadata fetching to work using a bounded queue
This works by using a bounded queue as a 'seat allocator'. Requests are only emitted in an asynchronous thread when there's a seat at the table. On my machine, the total time is cut from ~320s to ~50s. It also guarantees that there are never more than N requests in flight and does a best effort at keeping the number of requests in flight at any time close to N (this works because the time needed to fetch requests to send from the database is much smaller than the time needed to actually send and process requests. There's one seemingly important yet subtle change in this PR with regards to the fetching strategy. From: ```hs when (null refs || null successes) $ do traceWith tr $ MsgFetchTakeBreak blockFrequency threadDelay blockFrequency ``` To: ```hs when (null refs) $ do traceWith tr $ MsgFetchTakeBreak blockFrequency threadDelay blockFrequency ``` So, as of now, the wallet pauses for a whole 20s when all requests to fetching metadata failed. I think the rationale was originally to prevent the wallet from just eating up CPU by trying to fetch only invalid pools... What this create in practice is simply more unnecessary delays. There's about 8.5K pool registrations currently on mainnet, and after a full sync, there are still ~2254 fetch attempts still-to-proceed... so that's a lot of occasions to get a `null successes` on a particular loop. There's already a backoff which comes with the fetch attempts which prevent the wallet from doing needless work anyway. With this little change, we should massively improve the time needed for updating metadata upon new registrations, such as the problem described in: input-output-hk/daedalus#2359
- Loading branch information
Showing
2 changed files
with
62 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters