bevyengine / bevyengine/bevy

Resource Capping for stress testing games

Open
#22,728 3 comments 0 reactions 0 assignees View on GitHub
A-Dev-Tools C-Feature S-Needs-Design-Doc X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Use Case
As a developer, I want to be able to artificially "cap" the hardware resources (CPU, GPU, RAM) available to my Bevy application.

Currently, Rust/Bevy will utilize all available hardware power. This makes it difficult to:
1. Test how a game performs on "bare-bones" or low-end hardware without owning the physical device.
2. Identify memory leaks or CPU bottlenecks early by setting "hard ceilings."
3. Validate that the game logic stays stable when resources are throttled.

## Proposed Solution
I propose a standardized way to define **Resource Constraints** during App initialization (and eventually via the Bevy Editor UI).

When these constraints are active, Bevy should:
* Limit the internal thread pool to the specified number of cores.
* Enforce GPU limits (VRAM, buffer sizes) via `WgpuLimits`.
* (Optional) Log a warning or "Stress Test Report" if the application attempts to exceed these limits.

### Suggested "Capping" Parameters:
| Category | Parameter | Description |
| :--- | :--- | :--- |
| **CPU** | `max_threads` | Limits the `ComputeTaskPool` and `AsyncComputeTaskPool`. |
| **Memory** | `max_system_ram` | Enforces a ceiling on heap allocation (via a custom allocator or tracking). |
| **GPU VRAM** | `max_vram_bytes` | Sets an artificial limit for texture and buffer allocations. |
| **GPU Buffers** | `max_buffer_size` | Limits the size of individual vertex/index/uniform buffers. |
| **Rendering** | `max_texture_dim` | Limits the resolution of textures the engine is allowed to load. |

## Integration with the Bevy Editor
This feature would be a perfect fit for the upcoming **Official Graphical Editor**.
* A "Performance Emulation" panel where developers can toggle presets like "Mobile," "Integrated Graphics," or "Handheld (Steam Deck)."
* Real-time logs that show exactly which system pushed the engine over its assigned budget.

## Alternatives Considered
* **OS-level tools:** Using `taskset` (Linux) or cgroups is possible but platform-dependent and hard to automate for CI/CD testing.
* **Manual WGPU config:** Developers can manually set `WgpuSettings`, but this is verbose and doesn't cover CPU or System RAM.

## Additional Context
Implementing this at the engine level ensures that Bevy remains the "superior" choice for developers who care about high-performance architecture and cross-platform stability.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start at Bevy App initialization and review the ComputeTaskPool, AsyncComputeTaskPool, WgpuSettings, and WgpuLimits entry points mentioned in the proposal. Establish which CPU, memory, GPU, and reporting constraints are feasible, then define a focused scope and validation approach before implementation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.