Aliasing-motivated concurrency optimizations
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
Direzione di ricerca
Start with the test0-test4 examples in the issue, then read the linked LLVM, C++, and concurrency references to understand the aliasing and ordering claims. Done would require a project-level decision about whether these executions should be allowed or forbidden; the payload names no repository files or runnable tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The following tests capture some of the interactions between aliasing and concurrency.
While the optimizations below may introduce a data-race, any such execution is undefined due to aliasing violations: they'd need to access memory through a reference that's not derived from the &mut.
I don't see any immediate harm in these being allowed, but I found these being allowed by Rust and LLVM-IR interesting, to say the least.
The comments capture what I believe is the "status-quo", everyone should decide for themselves whether they think those executions should be allowed or forbidden:
pub fn test0(b: &mut u32){
loop {
let a = AtomicU32::from_mut(b);
if a.load(Ordering::Relaxed) != 0 { // may be downgraded to non-atomic access
break;
}
}
*b = 42;
}
pub fn test1(b: &mut u32) -> u32 {
let x = *b;
fence(Ordering::Release); // may be re-ordered above load; analogous for store-release
x
}
pub fn test2(b: &mut u32) {
*b = 42;
fence(Ordering::Release); // may be re-ordered above store; analogous for store-release
}
pub fn test3(b: &mut u32) {
fence(Ordering::Acquire); // analogous for load-acquire
*b = 42; // may be re-ordered above fence
}
pub fn test4(b: &mut u32) -> u32 {
fence(Ordering::Acquire); // analogous for load-acquire
*b // may be re-ordered above fence
}
The examples above are very simple and don't involve allocation APIs.
The following references include many other examples, some of which may be interesting to adapt to Rust.
Particularly interesting are those involving concurrency and "lifetime start"/"end" (memory being allocated/deallocated).
- Sung-Hwan Lee reported: https://github.com/llvm/llvm-project/issues/64188
- Hans Boehm: memory_order_relaxed and optimizations
- David Goldblatt: P3292
- Stephen Dolan: https://www.youtube.com/watch?v=cILLfXBBITg
- Lingua principale
- Nessun dato sulla lingua
- Stelle
- 760
- Fork
- 68
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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.
Altre issue di rust-lang/unsafe-code-guidelines
-
I-opsem-nominated
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
rust-lang/unsafe-code-guidelines#634 · 5 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
rust-lang/unsafe-code-guidelines#632 · 8 commenti · 1 reazione ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
rust-lang/unsafe-code-guidelines#631 · 7 commenti ·
-
I-opsem-nominated
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
rust-lang/unsafe-code-guidelines#630 · 1 reazione ·
Tutte le issue di rust-lang/unsafe-code-guidelines
Issue simili
-
bug core-lang
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Call-argument syntax diagnostic needs example spacing and removal of confusing trailing sentenceAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mw00/project-maya#1368 ·
I maintainer di solito rispondono entro 2 giorni
-
test(bind-json): legacy Solidity fixture requires an unavailable solc on Linux ARM64Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
foundry-rs/foundry#18828 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno