Predicate moves: pipeline destination Raft proposals and batch KV writes

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go

調査の方向性

worker/predicate_move.go の batchAndProposeKeyValues から始め、CleanPredicate バリアの後にその proposeAndWait フローを追います。次に populateKeyValues と、その posting.TxnWriter の使用箇所を調べます。完了条件は、上限付きの提案を実行中のままにでき、EOF が確認される前にすべてを待機し、共有された MoveTs の書き込みによって KV ごとに 1 つの管理トランザクションを作成せずに済むことです。

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

説明

Stale

Current behavior

The destination side of a predicate move funnels all streamed data through the destination group's Raft, one chunk at a time. batchAndProposeKeyValues (worker/predicate_move.go) accumulates 32MB of KVs, then calls proposeAndWait and blocks until that chunk is replicated to quorum, written to the Raft WAL, and applied on the leader before the next chunk is proposed. The apply path (populateKeyValues -> posting.TxnWriter) opens one badger transaction per KV, so a 32MB chunk of small posting lists commits tens of thousands of individual managed transactions.

Net effect: every byte moved is written roughly 6x on the destination group (Raft WAL plus badger, times 3 replicas), and throughput is bounded by one quorum round trip per 32MB chunk. The report in #9784 works out to about 0.35 MB/s on-disk (20GB in roughly 16 hours).

Proposed change

Two contained optimizations in the receive path:

  1. Pipeline the proposals. After the initial CleanPredicate barrier, chunks are order-independent: badger's stream framework partitions key ranges so keys are disjoint, and every KV is written at the same version (MoveTs). Keep a bounded number of proposals in flight (4-8) and wait for all of them before acking EOF.
  2. Batch the writes. All KVs in a move share the same commit timestamp, so populateKeyValues can write them through shared transactions or a write batch instead of one CommitAt per KV.

Plausibly a 4-8x improvement for changes confined to batchAndProposeKeyValues and populateKeyValues.

Context

Surfaced while fixing #9784 (size-aware move timeout). That fix stops large moves from being cancelled but does not make them faster.

Jira: DGR-308 (https://istari.atlassian.net/browse/DGR-308)

主要言語
Go
スター
21.8k
フォーク
1.6k
平均マージ
11日 7時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

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

dgraph-io/dgraph のほかの issue

dgraph-io/dgraph の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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