Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#384 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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

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

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.

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de myOmikron/code

Todos los issues de myOmikron/code

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.