bevyengine / bevyengine/bevy

Create a `Scratch<T>` system param for the "reused `Local`" pattern

Open
#23,775 6 comments 0 reactions 0 assignees View on GitHub
A-ECS A-Rendering C-Usability D-Modest S-Ready-For-Implementation X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

Wow this makes quite the positive improvement in that benchmark! Nice!

As an aside, I would love a new system param which is like `Scratch` which is a local that automatically clears when the system runs. It feels so good to reuse those allocations, and this is exactly the motivation!

_Originally posted by @andriyDev in https://github.com/bevyengine/bevy/pull/23758#pullrequestreview-4093981466_

@JMS55 says:

> Would love this - I've been wanting something like this for a long time! Can't remember if I have an open issue for it.
> It should ideally also keep track of occupancy, and shrink when it's over-allocated for several frames.
> Iirc I have something like this implemented in the meshlet code, but manually, instead of a system param.

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing `Local` system parameter and the manually managed implementation in the meshlet code. Read how system parameters are defined and how those allocations are reused. Done should include a `Scratch`-like parameter that clears on each system run, tracks occupancy, and can shrink after repeated over-allocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.