mtg-graph: cut /swaps latency by running suggest()'s candidate channels concurrently
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- backend, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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/wantedand 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_TUTORSon the role node.MATCH (c:Card) WHERE NOT c.is_land AND EXISTS { (c)-[:FILLS_ROLE]->(:Role {name: 'tutor'}) }checks every card. Start fromMATCH (:Role {name: 'tutor'})<-[:FILLS_ROLE]-(c:Card)instead._TUTOR_TO_NONLANDis shared withDECK_TUTOR_COUNT, which is deck-anchored and fine as it is. CheckCHANNEL_FIXINGtoo (MATCH (c:Card) WHERE c.is_land AND … CONTAINS, same full-scan shape, not in this trace). Confirm withPROFILEbefore and after. - Stop fetching the deck twice.
suggest_swapsfetchesfetch_deck/deck_card_roles/deck_card_resources(44 ms), thendiagnose()fetches the same three again (61 ms). Letdiagnose()take them as input. Careful:apply_discountandapply_play_ratesmutatecardsin place. - Stop computing combos twice.
suggest_swapscallsdeck_combos(41 ms), andsuggest()submits it again (72 ms, overlapped but still load). Hand the result over the waydiagnostics=reportalready is.MATCH (k:Combo) RETURN count(k)also runs twice, and theRECOMMENDSpresence check three times for the same commander. - Find the ~56 ms gap between the combo query and
suggest()(likelyscore_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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 0
- Forks
- 1
- Merge medio
- 9 h 39 min
- PR fusionados (30 d)
- 144
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de myOmikron/code
-
wayfinder:task
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
wayfinder:task
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
myOmikron/code#102 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
ready-for-agent
Dificultad 4/5 3-5 días Aptitud para principiantes 39/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
Los mantenedores suelen responder en 1 día
Todos los issues de myOmikron/code
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
area:plugins area:security area:skills bug has repro
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
anthropics/claude-code#105911 ·
Los mantenedores suelen responder en 1 día
-
[ko] Translate /team into KoreanAbiertodocumentation good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
dev-five-git/devup-ui#879 ·
Los mantenedores suelen responder en 11 días
-
openspec-apply-change skill: when blocked, may select a ready artifact unrelated to missingArtifactsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Fission-AI/OpenSpec#2165 ·
Los mantenedores suelen responder en 1 día
-
🐞 bug 🧐 unconfirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Tencent/tdesign-vue-next#7032 · 1 comentario ·
Los mantenedores suelen responder en 1 día