🐛 Backend on Koios is slow to start on preview

オープン
#4,274 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発

調査の方向性

Start with CacheWarmerService.onModuleInit and CacheService.refresh to trace startup warming and in-flight requests. Then inspect the Koios provider methods loadDirectory, loadUpdates('all'), loadDRepInfo, and loadAggregates. Done means startup listens before the first warm completes, concurrent requests share that warm, DRep directory data is reused per tip, and concluded actions avoid new summary calls.

索引モデルが issue の本文から書いたものです。

説明

🐛 Bug
Area

Other (backend, Koios provider)

Domain

Custom setup: govtool-backend v2.1.0-alpha.2, GOVTOOL_CHAIN_DATA_PROVIDER=koios, GOVTOOL_KOIOS_NETWORK=preview

Steps to reproduce
  1. Start govtool-backend on Koios with network preview.
  2. Wait for it to listen on port 9999.
Actual behavior

The backend does not listen, not even for its health check, until the first snapshot warm finishes. On preview this takes much longer than on mainnet.

Expected behavior

The backend listens immediately and the warm runs in the background.

Cause

CacheWarmerService.onModuleInit awaits a full DRep and proposal snapshot before Nest listens, and on Koios that snapshot scales badly:

  • DReps: readAll reads 500 rows per page, but each Koios dreps.list call re-reads all of /drep_list and /drep_updates before slicing its page, so the cost grows with pages × collection size.
  • Proposals: loadAggregates makes one /proposal_voting_summary call per action, concluded ones included.

Preview is about 10× mainnet. Per-request latency is not the problem: preview answered as fast as mainnet.

Public Koios mainnet preview
DReps / certificates 1,687 / 3,583 15,283 / 23,390
Governance actions 158 1,552
Requests for the DRep snapshot ~56 ~1,490
/proposal_voting_summary calls 158 1,552
Suggested change
  1. Don't block startup: in CacheWarmerService.onModuleInit, fire the first refresh without awaiting it. Have CacheService.refresh store its in-flight promise like getOrSet does, so requests that arrive during the warm wait on it instead of starting a second full read.
  2. Read the directory once per snapshot: in the Koios provider, memoise loadDirectory, loadUpdates('all') and loadDRepInfo per chain tip. This cuts preview's DRep snapshot from ~1,490 requests to ~290.
  3. Skip concluded actions: their tallies are final, so keep them by action id and call /proposal_voting_summary only for live actions.

1 fixes startup. 2 and 3 shrink the warm, which also re-runs on every new block.

主要言語
HTML
スター
22
フォーク
28
平均マージ
19時間 45分
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IntersectMBO/govtool のほかの issue

IntersectMBO/govtool の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。