fix: reduce D1 reads for summary candidates - #76
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
messageの集約走査からchannelの状態列参照へ変更しました。summary_pendingとチャンネル別の件数・先頭・末尾をD1トリガーで保持します。想定される効果
5分ごとの候補取得は
channel表だけを読み、全チャンネルの未要約messageを毎回COUNT/MIN/MAXしなくなります。代わりに、メッセージ追加時と最大200件の処理済み確定時に状態更新が発生します。
検証
cargo fmt --all -- --checkworkers/tests/summary_state.shcargo test --workspace --all-features(88件成功)cargo clippy --workspace --all-targets --all-features -- -D warningscargo check --manifest-path workers/Cargo.toml --target wasm32-unknown-unknownローリングデプロイ上の注意
migration → Worker → app の順で適用します。
旧appと新Workerが重なる短い期間は同じ範囲を再処理する可能性がありますが、未処理メッセージを欠落させない設計です。