Slow wallet loading

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
rust
領域
performance

調査の方向性

Cache::hash から開始し、issue に記載されている profiler データと 4,607 個の更新ファイルを使って、legacy FS ストアの読み込み中にその呼び出しを追跡します。286,064 個のタイムスタンプを含むキャッシュで低速化を再現し、その後、wallet-status の検証を削除せずに wallet の読み込みが大幅に高速化されることを確認します。

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

説明

I'm running a testnet LWK wallet with the legacy FS store.
There are 2075 transactions in total and 4607 update files in the enc_cache folder.
Recently I noticed that the wallet loading became quite slow.
It now takes about 29 seconds to load the wallet in the release build.
I attached a profiler and saw that the bottleneck is in this line:

        let mut vec: Vec<_> = self.timestamps.iter().collect();
        vec.sort(); // This line takes most of the time, 29 seconds in my case
        vec.hash(state);

After I changed it to this (to prevent extra indirection):

let mut vec: Vec<(u32, u32)> = self.timestamps.clone().into_iter().collect();

It took about 18 seconds to load the wallet.

And after I commented out this code:

            if self.wollet_status() != update.wollet_status {
                return Err(Error::UpdateOnDifferentStatus {
                    wollet_status: self.wollet_status(),
                    update_status: update.wollet_status,
                });
            }

It took less than 2 seconds to load the wallet.

Here is my cache size at the end:
all_txs size: 2075
scripts size: 2118
heights size: 2118
unblinded size: 2118
timestamps size: 286064

Cache::hash is called 4607 times (once per an update file).
So in my case, LWK is sorting up to 286064 elements 4607 times on loading.
I think this should be fixed.

主要言語
Rust
スター
113
フォーク
64
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

Blockstream/lwk のほかの issue

Blockstream/lwk の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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