ElementsProject / ElementsProject/elements

elementsd shutdown seems unnecessarily slow for long-running nodes

Aperta
#1,207 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
1.2k
Fork
416
Merge medio
1g 23h
PR unite (30g)
15

Descrizione

I'm curious if other people are finding that elementsd shutdown takes forever when the node has been running for a very long time, or if this is somehow unique to my machine. It's possible this issue is somehow specific to mac or non-linux platforms; it's also possible it's been made worse by my memory-reducing fix.

What appears to be happening: during shutdown we manually unload the block index, and deallocate the entries, one at a time. This seems basically pointless -- all we're doing is manually freeing memory that will be freed anyway when the process exits. This does not seem to be slow if we've just started, but takes forever when run on a process that's been around for a long time. What I _suspect_ is happening is that the block index has been paged out to disk, and in clearing it we're paging it in, a bit at a time, as we access the entries in random order. Even at SSD speeds, paging in multiple gigabytes using random reads is going to take ages.

(The more problematic possibility is some kind of leak, but I don't see the process having particularly excessive memory usage -- any more than usual -- so I don't think this is it.)

If possible, it would be nice to stop wasting all this effort on shutdown. Assuming it's in fact wasted, one possible catch is the use of the same codepaths in test cases -- we may still need to cleanly delete objects there, if we have to create and destroy multiple block indices before ending the process.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia individuando il percorso di arresto che scarica manualmente l’indice dei blocchi e dealloca le relative voci, quindi confrontalo con il comportamento all’uscita del processo. Riproduci, se possibile, un arresto dopo un node in esecuzione da molto tempo e analizza i casi di test che creano e distruggono più indici dei blocchi. Il lavoro è completo quando evita il lavoro di arresto non necessario preservando al contempo l’eliminazione pulita nei casi in cui i test la richiedono.

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

Valutazione

Stack tecnologico
cpp
Ambito
backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.