Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Break CorePlugin apart into smaller, more modular plugins #7081

Closed
recatek opened this issue Jan 3, 2023 · 0 comments
Closed
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@recatek
Copy link
Contributor

recatek commented Jan 3, 2023

What problem does this solve or what need does it fill?

CorePlugin currently has three disjoint responsibilities. It registers basic reflection types, it sets up the default task pools, and it sets up the frame counting system. For tiny bevy builds for things like game servers that run at fixed rates in single-threaded environments (see Valorant's 128-Tick Servers), it may be desirable to opt-in and opt-out of these things individually by using only a subset of MinimalPlugins (e.g. use the frame counter, but not the threaded task pools).

What solution would you like?

Split CorePlugin into three plugins with more focused responsibilities -- thread pooling, basic type reflection registration, and frame counter setup. Possibly grouped into a CorePlugins PluginGroup.

What alternative(s) have you considered?

A tiny bevy app could re-implement any of these things on its own, but that would likely be less future proof and more sensitive to API breaking changes.

Additional context

My personal use case is a game server that replaces the default schedule's core stages (First, PreUpdate, ..., Last) with fixed-update-tick equivalents (see gist for setup). It occurred to me while writing this that I would like to, for example, opt out of task pools on a single-threaded VPS that only runs the game's simulation.

I think there's also a potential issue here where CorePlugin, due to its name and nature, invites further growth into a multi-responsibility monolith as the engine expands. As a fringe benefit, splitting this up early into more domain-focused mini-plugins would be good, I think, for maintaining a culture of modularity at the core level.

@recatek recatek added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 3, 2023
@bors bors bot closed this as completed in 329b71f Jan 5, 2023
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
…FrameCountPlugin`. (bevyengine#7083)

# Objective

- Fixes bevyengine#7081.

## Solution

- Moved functionality from kitchen sink plugin `CorePlugin` to separate plugins, `TaskPoolPlugin`, `TypeRegistrationPlugin`, `FrameCountPlugin`.  `TaskPoolOptions` resource should now be used with `TaskPoolPlugin`.

## Changelog

Minimal changes made (code kept in `bevy_core/lib.rs`).

## Migration Guide

- `CorePlugin` broken into separate plugins.  If not using `DefaultPlugins` or `MinimalPlugins` `PluginGroup`s, the replacement for `CorePlugin` is now to add `TaskPoolPlugin`, `TypeRegistrationPlugin`, and `FrameCountPlugin` to the app.

## Notes

- Consistent with Bevy goal "modularity over deep integration" but the functionality of `TypeRegistrationPlugin` and `FrameCountPlugin` is weak (the code has to go somewhere, though!).
- No additional tests written.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…FrameCountPlugin`. (bevyengine#7083)

# Objective

- Fixes bevyengine#7081.

## Solution

- Moved functionality from kitchen sink plugin `CorePlugin` to separate plugins, `TaskPoolPlugin`, `TypeRegistrationPlugin`, `FrameCountPlugin`.  `TaskPoolOptions` resource should now be used with `TaskPoolPlugin`.

## Changelog

Minimal changes made (code kept in `bevy_core/lib.rs`).

## Migration Guide

- `CorePlugin` broken into separate plugins.  If not using `DefaultPlugins` or `MinimalPlugins` `PluginGroup`s, the replacement for `CorePlugin` is now to add `TaskPoolPlugin`, `TypeRegistrationPlugin`, and `FrameCountPlugin` to the app.

## Notes

- Consistent with Bevy goal "modularity over deep integration" but the functionality of `TypeRegistrationPlugin` and `FrameCountPlugin` is weak (the code has to go somewhere, though!).
- No additional tests written.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
1 participant