Skip to content

Conversation

makspll
Copy link
Owner

@makspll makspll commented Aug 29, 2025

Summary

Removes ContextLoadingSettings and instead moves its innards into a ScriptingPluginConfiguration<P> struct,
which can be accessed via P::readonly_config(world.id())

This should:

  • further simplify HandlerCtxt bringing us closer to a world where we can put it in an Arc
  • Speed up access to these configs, as they generally don't need to be a resource, and are only ever written to at app startup time

Migration Guide

Switch all references of ContextLoadingSettings to P::readonly_config(world.id()).

@makspll makspll changed the title refactor: add world local plugin config, remove ContextLoadingSettings resource refactor: add world-local static plugin config, remove ContextLoadingSettings resource Aug 29, 2025
@makspll makspll requested a review from Copilot August 29, 2025 23:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the configuration system by removing the ContextLoadingSettings resource and replacing it with a world-local static plugin configuration system. The change simplifies HandlerCtxt and improves performance by avoiding resource lookups for configuration that is only set at app startup.

  • Introduces ScriptingPluginConfiguration<P> with thread-local storage accessed via P::readonly_config(world.id())
  • Removes ContextLoadingSettings resource and related code throughout the codebase
  • Updates all configuration access patterns to use the new static configuration system

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/script_tests.rs Forces single-threaded test execution to avoid thread-local storage issues
crates/testing_crates/test_utils/src/test_plugin.rs Adds static plugin config macro usage
crates/languages/bevy_mod_scripting_rhai/src/lib.rs Adds static plugin config macro and required imports
crates/languages/bevy_mod_scripting_rhai/Cargo.toml Adds bevy_platform dependency
crates/languages/bevy_mod_scripting_lua/src/lib.rs Adds static plugin config macro and required imports
crates/bevy_mod_scripting_core/src/script/script_context.rs Adds imports for new config system
crates/bevy_mod_scripting_core/src/lib.rs Updates trait bounds and plugin initialization logic
crates/bevy_mod_scripting_core/src/handler.rs Removes context loading settings parameter and uses static config
crates/bevy_mod_scripting_core/src/extractors.rs Removes ResScope and related context loading settings code
crates/bevy_mod_scripting_core/src/event.rs Adds imports for new config system
crates/bevy_mod_scripting_core/src/context.rs Removes ContextLoadingSettings and updates loaders to use static config
crates/bevy_mod_scripting_core/src/config.rs New file implementing the static plugin configuration system
crates/bevy_mod_scripting_core/src/commands.rs Updates script loading to use static config instead of handler context
crates/bevy_mod_scripting_core/src/bindings/world.rs Adds world ID access methods
crates/bevy_mod_scripting_core/src/bindings/script_system.rs Updates dynamic handler to use static config
crates/bevy_mod_scripting_core/src/bindings/schedule.rs Adds imports for new config system
crates/bevy_mod_scripting_core/src/asset.rs Updates asset handling to use static config instead of resource

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

makspll and others added 2 commits August 30, 2025 00:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

🐰 Bencher Report

Branchrefactor/world-local-plugin-config
Testbedlinux-gha

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
component/access Lua📈 view plot
⚠️ NO THRESHOLD
3,523.30 ns
component/access Rhai📈 view plot
⚠️ NO THRESHOLD
5,563.10 ns
component/get Lua📈 view plot
⚠️ NO THRESHOLD
2,181.70 ns
component/get Rhai📈 view plot
⚠️ NO THRESHOLD
4,298.50 ns
conversions/Mut::from📈 view plot
⚠️ NO THRESHOLD
80.39 ns
conversions/Ref::from📈 view plot
⚠️ NO THRESHOLD
76.17 ns
conversions/ScriptValue::List📈 view plot
⚠️ NO THRESHOLD
295.62 ns
conversions/ScriptValue::Map📈 view plot
⚠️ NO THRESHOLD
886.95 ns
conversions/ScriptValue::Reference::from_into📈 view plot
⚠️ NO THRESHOLD
25.89 ns
conversions/Val::from_into📈 view plot
⚠️ NO THRESHOLD
275.31 ns
function/call 4 args Lua📈 view plot
⚠️ NO THRESHOLD
1,532.90 ns
function/call 4 args Rhai📈 view plot
⚠️ NO THRESHOLD
1,340.60 ns
function/call Lua📈 view plot
⚠️ NO THRESHOLD
225.07 ns
function/call Rhai📈 view plot
⚠️ NO THRESHOLD
454.49 ns
loading/empty Lua📈 view plot
⚠️ NO THRESHOLD
54,151.00 ns
loading/empty Rhai📈 view plot
⚠️ NO THRESHOLD
306,170.00 ns
math/vec mat ops Lua📈 view plot
⚠️ NO THRESHOLD
6,734.30 ns
math/vec mat ops Rhai📈 view plot
⚠️ NO THRESHOLD
5,859.20 ns
query/10 entities Lua📈 view plot
⚠️ NO THRESHOLD
17,948.00 ns
query/10 entities Rhai📈 view plot
⚠️ NO THRESHOLD
18,538.00 ns
query/100 entities Lua📈 view plot
⚠️ NO THRESHOLD
38,491.00 ns
query/100 entities Rhai📈 view plot
⚠️ NO THRESHOLD
30,754.00 ns
query/1000 entities Lua📈 view plot
⚠️ NO THRESHOLD
245,120.00 ns
query/1000 entities Rhai📈 view plot
⚠️ NO THRESHOLD
160,810.00 ns
reflection/10 Lua📈 view plot
⚠️ NO THRESHOLD
5,329.10 ns
reflection/10 Rhai📈 view plot
⚠️ NO THRESHOLD
15,223.00 ns
reflection/100 Lua📈 view plot
⚠️ NO THRESHOLD
46,407.00 ns
reflection/100 Rhai📈 view plot
⚠️ NO THRESHOLD
718,030.00 ns
resource/access Lua📈 view plot
⚠️ NO THRESHOLD
3,175.80 ns
resource/access Rhai📈 view plot
⚠️ NO THRESHOLD
5,079.60 ns
resource/get Lua📈 view plot
⚠️ NO THRESHOLD
1,834.60 ns
resource/get Rhai📈 view plot
⚠️ NO THRESHOLD
3,853.00 ns
🐰 View full continuous benchmarking report in Bencher

@makspll makspll enabled auto-merge (squash) August 29, 2025 23:50
@makspll makspll disabled auto-merge August 29, 2025 23:50
@makspll makspll enabled auto-merge (squash) August 29, 2025 23:50
@makspll makspll merged commit 5dd665a into main Aug 30, 2025
21 checks passed
@makspll makspll deleted the refactor/world-local-plugin-config branch August 30, 2025 00:18
@github-actions github-actions bot mentioned this pull request Aug 25, 2025
@github-actions github-actions bot mentioned this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant