feat: Granular tracking of stale references
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- compilers
調査の方向性
issueではファイルもテストも特定されていません。まず、提案で言及されているTypeScript-to-WGSL参照の生成と、既存の消費検証作業を追跡してください。元の値が変更された可能性がある場合に参照へアクセスできなくなり、不変の引数の使用は引き続き有効であれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
}
- 主要言語
- TypeScript
- スター
- 3.3k
- フォーク
- 141
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 72
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
software-mansion/TypeGPU のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
software-mansion/TypeGPU#3276 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
software-mansion/TypeGPU#3219 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
texture.write(VideoFrame) uses the padded coded size instead of the visible size対応中かも @RaphaelFakhri が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
software-mansion/TypeGPU#3213 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
software-mansion/TypeGPU#3008 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
software-mansion/TypeGPU#2948 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
software-mansion/TypeGPU の issue をすべて見る
似ている issue
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
hemi-earn
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vetro-protocol/vetro-monorepo#1043 ·
メンテナーはふだん 1 日以内に返信
-
stage 2: bare names resolve against PATH differently from the shell (empty and relative entries)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
STRML/omp-classifier#206 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
atlassian-labs/mermaid-diagrams-viewer#188 ·
メンテナーはふだん 1 日以内に返信
-
dashboard enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Olanetsoft/agent-lookout#225 ·
メンテナーはふだん 1 日以内に返信