ecs: struct components in GPU accessors, packed u64/u128 fields, and the cost of staged archetype moves
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 38/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- typescript, wasm
- Domaine
- backend, performance
Piste de recherche
Start with src/interface/gpu/accessors.ts and layoutOf to see how struct layouts are handled, then trace row and kernel access to component values and their change stamping. Check the existing benchmark and profiling entry points, including src/perftest/birth.ts, for the packed-field and command-encoding costs. Done means documenting current u64/u128 support and lane change behavior, with measurements that compare packed and separate fields and define the requested accessor support.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Found while consolidating a voxel renderer's per-entity data (the mecs app, @adobe/ecs 0.3.2). Two things to verify or add, and the measurements that motivate them.
Why
Each voxel carries denormalized, derived values as separate components: a look (color 4×f32, metallic/roughness 2×f32, emission 3×f32, fade f32, refraction 2×f32) and a shade (exposure u32, occlusion 2×u32, sunlight u32). They are written by different systems at different times, so a voxel is born in four stages (spawn, then +cell, +look, +shade), each a move to another archetype, and each wakes the changes finalizers that watch those components. They are read only by render systems.
Measured with real components, 14,000 voxels, no finalizers or indexes (src/perftest/birth.ts in mecs):
| birth | per voxel |
|---|---|
spawn, then three add stages |
~1.7 µs |
| spawn with everything at once | ~0.95 µs |
So the three extra moves cost about 0.75 µs a voxel before any finalizer runs. Packing each group into one component removes two of the moves and 40 to 48 bytes of columns a voxel.
1. GPU accessors for struct components
accessorsOf (src/interface/gpu/accessors.ts) accepts only a scalar or a tuple of 2 to 4 same-typed scalars. A struct component, or a mixed tuple, is rejected ("isn't a scalar or a tuple of two to four scalars of one type"), although layoutOf already places structs for the storage rules. We can pack by hand into Vec4.U32 and unpack in WGSL, but the fields then have no names or types on either side.
Request: let an accessor name a struct component, either as a WGSL struct return or as one accessor per field (fn name_field(row) -> T), reading only the words of the fields used.
2. Packed bit fields: u64 and u128, and their cost
For the shade group (exposure 6 bits, occlusion 48, sunlight 30: 84 bits) and the look group, the natural representation is a few adjacent u32 words with bit fields. Please check, and state what holds today:
- Whether a
U64scalar (or a documented pair/quad of adjacent u32 lanes treated as a U128) can be declared, and how it reads and writes withoutBigIntin a row system, in akernel: truesystem, and in the wasm kernel. - The cost of a bit-field read-modify-write of one field of a 3×u32 component in a kernel row system, against the same field as its own
U32component. If the packed form is not about as fast, where does it lose (extra loads, a write-back of all lanes, change stamping of the whole component)? - Whether a write to one lane of a tuple component stamps
changedfor the whole component (it seems to), and what that means for a GPU upload of a chunk when only one field changed.
3. Aside: command encoding
In a profile of a 14,000-voxel fall (add fallPosition, spawn voxels, despawn fallers) encodeValue/leafValue/element, the encoding of each command's JS value object into the command buffer, was the largest single line in the ECS's own time (~15 ms of ~176). A bulk path (spawnMany(archetype, count, fill), or per-column writes from a row system for components the entity already has) would avoid the per-entity object. Related: #259.
Happy to share the benchmarks and profiles.
- Langage dominant
- TypeScript
- Étoiles
- 12
- Forks
- 8
- Merge moyen
- 9 h 2 min
- PR mergées (30 j)
- 25
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de adobe/data
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 57/100
Les mainteneurs répondent en général sous 1 jour
-
ecs: let kernels issue commands through helpers (component lists, symbol-keyed values, void helpers)Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
Les mainteneurs répondent en général sous 1 jour
-
createLazy: wrap nested service groups and accept partial (subset) schemasPeut-être pris @krisnye l’a pris il y a 2 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 8/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de adobe/data
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
langchain-ai/langchainjs#12157 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
activescott/home-infra-k8s-flux#511 ·
Les mainteneurs répondent en général sous 1 jour
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
lingdojo/kana-dojo#33753 · 1 commentaire · 5 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
android:player
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
follow-up needs-triage S3: minor
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
manaflow-ai/cmux#38032 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour