_Py_atomic_add_*_relaxed
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Feature or enhancement
Proposal:
I would like to add relaxed variants of the _Py_atomic_add functions.
The existing add operations are sequentially consistent, which is stronger (and on ARM, measurably more expensive) than necessary for uses like statistics counters and unique ID allocation, where the add must be atomic but does not need to order surrounding memory accesses.
Personally, I'd like to be able to use this in the CinderX JIT, but there are quite a few other places I found in the existing CPython codebase that could benefit from this set of functions:
- the GC young.count allocation counter, which is purely heuristic and is already read with relaxed loads
- lru_cache hit/miss statistics; the counters are already read with relaxed loads
- the dict shared-keys incref which may only run while the caller already keeps the keys alive, and the final decref provides the ordering needed to free them
- the module index allocator and the asyncio task name counter, where only uniqueness of the returned value matters
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-155630
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Esamina prima le funzioni _Py_atomic_add esistenti e la PR collegata gh-155630, quindi confronta i casi d’uso elencati per contatori e allocator con la loro necessità di atomicità senza ordinamento degli accessi circostanti. Il lavoro è completato quando le varianti relaxed di add supportano i casi d’uso previsti senza indebolire il comportamento atomico richiesto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- performance
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100