mtg-graph: cut /diagnostics latency by collapsing its Neo4j round trips
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 39/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- neo4j, python
- Ambito
- backend, databases, performance
Direzione di ricerca
Start in services/mtg-graph/src/deck_lab/diagnostics.py and read diagnose() and the listed query callers; compare the seven sequential Neo4j queries and trace the unaccounted gap around deck_theme_breakdown. Profile DECK_CARD_TYPES and DECK_CARD_RESOURCES before and after any rewrite, and update the monkeypatches in tests/test_diagnostics.py and tests/test_api_tracing.py. Done means a comparable trace shows the endpoint well under 100 ms, with before and after numbers posted on the issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tracking issue for speeding up POST /api/graph/diagnostics (diagnose() in services/mtg-graph/src/deck_lab/diagnostics.py).
Baseline
Trace 3eae5143f2b97765f1412bffd26b77d7 (91-card deck, cache miss): 194 ms end to end, 169 ms in the mtg-graph endpoint. The mtg side (session, identity, account, proxy) adds only ~4 ms.
Seven Neo4j queries run sequentially, all UNWIND $rows … MATCH (c:Card {oracle_id}) over the same deck, together ~133 ms:
| ms | query | caller |
|---|---|---|
| 20.1 | DECK_CARDS |
fetch_deck |
| 17.7 | DECK_CARD_RESOURCES (BROADER*0..) |
deck_card_resources |
| 12.9 | DECK_CARD_ROLES |
deck_card_roles |
| 43.2 | DECK_CARD_TYPES |
deck_card_types |
| 9.0 | DECK_ROLE_WEIGHTS |
deck_role_weights |
| 16.2 | DECK_PRODUCED |
deck_resource_balance |
| 14.0 | DECK_WANTED |
deck_resource_balance |
Plus a ~25 ms gap with no query between DECK_CARD_ROLES and DECK_CARD_TYPES.
Even the trivial DECK_ROLE_WEIGHTS costs 9 ms, which points at per-query overhead (round trip, planning, record decoding in the Python driver) rather than work in the database. Fewer round trips is the lever. Moving to Postgres was considered and rejected: the bottleneck is not the engine, and the rest of mtg-graph relies on PARENT_OF*0.. / BROADER*0.. traversals, so a split would mean keeping two stores in sync from ingest.
Tasks
- Derive the three aggregate queries in Python (~39 ms, low risk)
deck_role_weights:sum(weight * qty)per role fromcard_roles, whichdiagnose()already holdsDECK_PRODUCED: cards and names per expanded resource, fromresources_by_card[*]["produces"]+cardsDECK_WANTED: readsCARES_ABOUTwithout hierarchy expansion, unlikeresources_by_card["cares_about"]. HaveDECK_CARD_RESOURCESalso return the direct cares-about set, then derive locally- Keep
build_diagnosticspure; update the monkeypatches intests/test_diagnostics.pyandtests/test_api_tracing.py
- Rewrite
DECK_CARD_TYPESwith pattern comprehensions instead of three chainedOPTIONAL MATCH … collect/WITHstages; check withPROFILEbefore and after. Same check forDECK_CARD_RESOURCES - Run the remaining per-card fetches concurrently, or as one query (
fetch_deck, resources, roles, types depend only ondeck): either aThreadPoolExecutor(wall time = slowest query instead of the sum) or a single combined per-card query (one round trip, oneMATCHper card) - Find the ~25 ms gap: add a span around
deck_theme_breakdown(and the eminence/cEDH steps) or profile with py-spy, then decide whether it needs work - (optional) Materialize hierarchy closures at ingest (e.g. expanded
PRODUCES/CARES_ABOUTedges or list properties) so per-deck reads need no*0..traversal. Only if the steps above leave the resource queries dominant
Done when
A new trace for a comparable deck shows the endpoint well under 100 ms, with the before/after numbers posted here.
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 1
- Merge medio
- 9h 39m
- PR unite (30g)
- 144
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di myOmikron/code
-
wayfinder:task
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
wayfinder:task
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
myOmikron/code#102 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di myOmikron/code
Issue simili
-
backend bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
geolens-io/geolens#3568 ·
I maintainer di solito rispondono entro 1 giorno
-
area:docs documentation good first issue priority:low
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
rtk-ai/rtk#4900 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
API: `tsc.exe` opens a visible console window on Windows when the parent process has no consoleAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/TypeScript#65083 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
bug p2 platform:web triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno