Packed/sparse representations
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 107
- Avg merge
- 2h
- Merged PRs (30d)
- 6
Description
It might be useful/fun to allow certain components to be stored per archetype in ways other than a flat array. For example, a bool component might be stored in a packed bitfield, and a bool component which is nearly always false might benefit from sparse encoding. This could be pursued with something like:
trait Container<T> { /* ... */ }
struct Array<T>(Box<[T]>);
impl<T> Container<T> for Array { /* ... */ }
trait Component<T: Container<Self> = Array<T>>: Send + Sync + Sized + 'static {}
impl<T: Send + Sync + 'static> Component<Array<T>> for T {}
This preserves the "It Just Works" behavior for typical cases, while allowing specialized implementations as needed. The proposed definition of Array would break up the currently monolithic Archetype allocations; in the event that this compromises performance, an allocator abstraction could be introduced to allow multiple containers to share a single memory region.
The most obviously useful nonstandard container, a bitfield, would require container-specific smart pointer types in place of references. This will be difficult to accomplish without GATs, so it's probably best to wait their arrival before developing this concept further.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by reading the Archetype allocation design and the proposed Container and Component traits, then determine whether alternate per-archetype representations can preserve the default behavior and support the described bitfield or sparse cases; done would require an agreed design and validation of its performance and reference-model constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100