feat: Granular tracking of stale references
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- compilers
Direzione di ricerca
Nell’issue non sono identificati file né test. Inizia tracciando la generazione dei riferimenti TypeScript-to-WGSL e il lavoro esistente sulla verifica del consumo menzionato nella proposta. Il lavoro è completato quando i riferimenti diventano inaccessibili dopo che il valore originale potrebbe essere stato mutato, mentre l’uso di argomenti immutabili rimane valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
There has been TypeScript behavior that we have overlooked up until now that has to do with references:
const Boid = d.struct({
pos: d.vec3f,
vel: d.vec3f,
});
function main() {
'use gpu';
const boid = Boid();
// getting a reference to the boid's position
const boidPos = boid.pos;
// replacing the `pos` property of the boid with a new vector
boid.pos = d.vec3f(1, 2, 3);
// returning the `x` coordinate of the vector that was once
// the boid's position
return boidPos.x;
}
We'd expect the result of main() to be 0, since we haven't actually updated the x coordinate of the existing boid.pos, rather we replaced that vector with an entirely new one, making boidPos no longer point to the actual value of boid.pos (they drifted out of sync).
We generate the following WGSL:
struct Boid {
pos: vec3f,
vel: vec3f,
}
fn main() -> f32 {
var boid = Boid();
let boidPos = (&boid.pos);
boid.pos = vec3f(1, 2, 3);
return (*boidPos).x;
}
In the generated WGSL, boidPos is a pointer to boid.pos, meaning it always reflects the up-to-date value of boid.pos, making the result of calling main() be 1.
Stale reference tracking
@cieplypolar's insight is that we can use a sort of borrow checker (like we were planning to do for consumption verification) to invalidate stale references. Essentially, as soon as it's determined that boid (the original value) could have been mutated by an instruction, boidPos would become invalidated and unaccessible.
struct Boid {
pos: vec3f,
vel: vec3f,
}
fn main() -> f32 {
var boid = Boid();
let boidPos = (&boid.pos);
boid.pos = vec3f(1, 2, 3); // <- accessing the original invalidates the aliases
return (*boidPos).x; // 🚫 `boidPos` is a stale reference
}
I believe there is a way to do this statically without introducing too much complexity to the system.
[!NOTE]
To be continued...
function main() {
'use gpu';
const boid = Boid();
// boid
//
const boidPos = boid.pos;
// boid
// |
// | (.pos)
// |
// boidPos
randomFunction(boid) // <- arguments are immutable, so this is okay
blackBox(d.ref(boid)); // <- could mutate `boid`
// boid
// |
// | (.pos)
// |
// ☠️ boidPos
return boidPos.x; // 🚫 `boidPos` is a stale reference
}
function main() {
'use gpu';
const boid = Boid();
// boid
//
const boidPos = boid.pos;
// boid
// |
// | (.pos)
// |
// boidPos
const boidVel = boid.vel;
// boid
// | \
// | (.pos) \ (.vel)
// | \
// boidPos boidVel
blackBox(d.ref(boid)); // <- could mutate `boid`
// boid
// | \
// | (.pos) \ (.vel)
// | \
// ☠️ boidPos ☠️ boidVel
return boidPos.x; // 🚫 `boidPos` is a stale reference
}
- Lingua principale
- TypeScript
- Stelle
- 3.3k
- Fork
- 140
- Merge medio
- 3g 8h
- PR unite (30g)
- 72
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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.
Altre issue di software-mansion/TypeGPU
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
software-mansion/TypeGPU#3276 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
software-mansion/TypeGPU#3219 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
texture.write(VideoFrame) uses the padded coded size instead of the visible sizeForse già presa @RaphaelFakhri l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
software-mansion/TypeGPU#3213 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
software-mansion/TypeGPU#3008 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
software-mansion/TypeGPU#2948 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di software-mansion/TypeGPU
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
gnosis/gnosis_vpn#661 ·
I maintainer di solito rispondono entro 1 giorno
-
content-freshness: staleOwnedContent doc comments still say 'complete receipt' (follow-up to #7912)Apertatriage:bug-verified
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
fix: reject sourceStorage/packagedStorage bucket that differs from the stack default (fail loud)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Eyevinn/open-videocore#1300 ·
I maintainer di solito rispondono entro 1 giorno
-
nextjs-tracking
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
cloudflare/vinext#4390 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
kubernetes-sigs/headlamp#8175 ·
I maintainer di solito rispondono entro 2 giorni