RFC: Performance improvement in `lean_mark_persistent` and `lean_mark_mt`

Aperta
#16,374 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #16375 di @zgrannan — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Ambito
performance

Direzione di ricerca

Start with src/runtime/object.cpp around lean_mark_persistent and inspect the corresponding lean_mark_mt implementation. Review the linked implementation and benchmark results, then check the existing runtime tests and benchmark suite for coverage of persistent marking. Done means both paths preserve correct object marking and the benchmark confirms the reported instruction reduction; linked pull request #16375 is closed and unmerged.

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

Descrizione

lean_mark_persistent implements a worklist loop where each iteration pops an object o and:

  1. checks !lean_is_scalar(o) && lean_has_rc(o);
  2. if the check succeeds, runs lean_internal_set_rc(o, 0) and pushes all of o's children onto the worklist.

I think we can improve performance by moving the check and the update to the push:

  • only pushing a child c if !lean_is_scalar(c) && lean_has_rc(c), and
  • calling lean_internal_set_rc(c, 0) just before adding it to the worklist

This has two benefits:

  • fewer buffer operations, since scalars and already-persistent objects are never added to the buffer;
  • the worklist never holds the same object twice.

I've implemented this change here, applying the same restructuring to lean_mark_mt. Running the benchmark suite locally I get 0.96% drop in build//instructions.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
19h 8m
PR unite (30g)
421

Preparare l'ambiente

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.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su Performance

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.