python / python/mypy

Sqlite writes limit parallel scaling

Abierto
#21,235 9 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

parallel checking performance
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

I measured time spent in sqlite operations when running the mypy_parallel benchmark. When using 8 workers, sqlite writes were over 10x slower compared to using just 1 worker, likely because only one worker can be writing at any time. This seems to be one of the main sources of limited parallel scaling on macOS at least.

Here are some ideas which might help:

  1. Instead of writing cache files in each worker, send them via IPC and have the main process write everything.
  2. Use a separate extra cache file per worker, and the main process will copy per-worker cached data to the main database. Every worker reads from the main database.
  3. Use a separate extra cache file per worker, and somehow allow each worker to read from the right database but always write to their own database.
  4. Shard the database -- have 1 (non-exclusive) database per worker, and use module name based hash to choose the target database for both reading and writing.

Next steps:

  • Measure on Linux as well
  • Prototype some of the ideas and measure impact (at least ones that are easy enough to implement)

cc @ilevkivskyi

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Comienza reproduciendo el benchmark mypy_parallel y midiendo el tiempo de escritura de SQLite con uno y ocho workers en macOS y Linux. Después, revisa los cuatro enfoques propuestos para escribir la caché y crea prototipos de los candidatos más sencillos. Se considerará terminado cuando se comuniquen mediciones comparables y el impacto en la escalabilidad en paralelo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python, sqlite
Área
databases, performance
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.