python / python/mypy

Sqlite writes limit parallel scaling

Aperta
#21,235 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

parallel checking performance
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il benchmark mypy_parallel e misurando il tempo di scrittura di SQLite con uno e otto worker su macOS e Linux. Poi esamina i quattro approcci proposti per la scrittura della cache e realizza prototipi dei candidati più semplici. Il lavoro sarà considerato completato quando saranno riportate misurazioni comparabili e l'impatto sulla scalabilità parallela.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, sqlite
Ambito
databases, performance
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.