Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

mtg-graph: cut /swaps latency by running suggest()'s candidate channels concurrently

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

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

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

評価

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

調査の方向性

Start with services/mtg-graph/src/deck_lab/cuts.py and suggestions.py; trace how suggest_swaps passes data to diagnose() and suggest(), then inspect the combo prefetch pattern in suggestions.py. Use the provided trace timings to prioritize concurrent candidate channels and duplicate fetches, and PROFILE the tutor and fixing queries before and after. Done means a comparable /swaps trace is well under 500 ms with before and after numbers posted on the issue.

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

説明

ready-for-agent

Tracking issue for speeding up POST /api/graph/swaps (suggest_swaps in services/mtg-graph/src/deck_lab/cuts.py, which calls suggest() in suggestions.py). Related: #383 covers the diagnose() part that /swaps also runs.

Baseline

Trace …50f33b (70-card deck): 2193 ms end to end, all of it in mtg-graph. 1890 ms of that is suggest(), whose candidate-channel queries run sequentially:

ms query
609 CHANNEL_TUTORS (graph.py), scans every Card
272 resource channel (PRODUCES→BROADER*0..→Resource {name: want.resource})
266 role channel (FILLS_ROLE)
201 theme channel (FITS_THEME)
148 typal channel (IS_TYPE|MAKES_TYPE|CARES_ABOUT_TYPE)
124 name channel
115 EDHREC RECOMMENDS
33 + 6 text types, deck tutor count

Together ~1.77 s. Before suggest() there are another ~270 ms: the deck fetches, diagnose() (see #383), combos, and a ~56 ms gap with no query.

Tasks

  • Run the candidate channels concurrently. They only read diagnostics/wanted and each fills its own pool, so wall time can drop from the sum to the slowest one. Reuse the pattern of the existing combo prefetch (_SPELLBOOK_POOL.submit(contextvars.copy_context().run, …), suggestions.py) so the trace spans stay parented. Each call already opens its own session from the shared driver.
  • Anchor CHANNEL_TUTORS on the role node. MATCH (c:Card) WHERE NOT c.is_land AND EXISTS { (c)-[:FILLS_ROLE]->(:Role {name: 'tutor'}) } checks every card. Start from MATCH (:Role {name: 'tutor'})<-[:FILLS_ROLE]-(c:Card) instead. _TUTOR_TO_NONLAND is shared with DECK_TUTOR_COUNT, which is deck-anchored and fine as it is. Check CHANNEL_FIXING too (MATCH (c:Card) WHERE c.is_land AND … CONTAINS, same full-scan shape, not in this trace). Confirm with PROFILE before and after.
  • Stop fetching the deck twice. suggest_swaps fetches fetch_deck/deck_card_roles/deck_card_resources (44 ms), then diagnose() fetches the same three again (61 ms). Let diagnose() take them as input. Careful: apply_discount and apply_play_rates mutate cards in place.
  • Stop computing combos twice. suggest_swaps calls deck_combos (41 ms), and suggest() submits it again (72 ms, overlapped but still load). Hand the result over the way diagnostics=report already is. MATCH (k:Combo) RETURN count(k) also runs twice, and the RECOMMENDS presence check three times for the same commander.
  • Find the ~56 ms gap between the combo query and suggest() (likely score_cuts / upgrade_candidates): add spans or profile, then decide.
  • (optional) Materialize the resource hierarchy closure at ingest (also listed in #383). Once the channels run concurrently, the resource channel's reverse BROADER*0.. expansion over the whole corpus is likely the slowest query.

Done when

A new trace of /swaps for a comparable deck is well under 500 ms, with the before/after numbers posted here.

主要言語
TypeScript
スター
0
フォーク
1
平均マージ
9時間 39分
マージ済み PR(30日)
144

環境構築

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

はじめの一歩

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

myOmikron/code のほかの issue

myOmikron/code の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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