Skip to content

feat!: decouple world abstractions, improve domain boundaries#529

Open
makspll wants to merge 7 commits intomainfrom
feat/decouple-world-abstractions
Open

feat!: decouple world abstractions, improve domain boundaries#529
makspll wants to merge 7 commits intomainfrom
feat/decouple-world-abstractions

Conversation

@makspll
Copy link
Copy Markdown
Owner

@makspll makspll commented Mar 28, 2026

Summary

The bevy_mod_scripting_bindings crate is bigger than it needs to, it would be ideal to have the ability to extend the world guard in separate crates, this PR is one step towards that.

I extracted the "cached" registry components into something less typed so that I could pull out bevy_mod_scripting_world which doesn't know about these, and instead alot of the functionality is pushed into bevy_mod_scripting_bindings, via the new WorldExtensions trait.

I also removed ReflectAccessId in favor of WorldAccessRange making the world crate a bit more opinionated on what kind of accesses exist

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 28, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  benches/benchmarks.rs  95% smaller
  crates/bevy_mod_scripting_core/src/extractors.rs  81% smaller
  crates/bevy_mod_scripting_bindings/src/function/from.rs  75% smaller
  crates/bevy_mod_scripting_bindings/src/script_value.rs  70% smaller
  crates/bevy_mod_scripting_bindings/src/function/into.rs  58% smaller
  crates/bevy_mod_scripting_derive/src/derive/debug_with_type_info.rs  57% smaller
  crates/bevy_mod_scripting_functions/src/core.rs  56% smaller
  crates/bevy_mod_scripting_core/src/pipeline/machines.rs  56% smaller
  crates/bevy_mod_scripting_bindings/src/function/from_ref.rs  55% smaller
  crates/bevy_mod_scripting_bindings/src/globals/core.rs  54% smaller
  crates/bevy_mod_scripting_bindings/src/function/namespace.rs  54% smaller
  crates/bevy_mod_scripting_bindings/src/function/into_ref.rs  50% smaller
  crates/bevy_mod_scripting_display/src/printer/mod.rs  50% smaller
  crates/bevy_mod_scripting_bindings/src/path/mod.rs  49% smaller
  crates/bevy_mod_scripting_bindings/src/docgen/info.rs  47% smaller
  crates/bevy_mod_scripting_bindings/src/globals/mod.rs  44% smaller
  crates/bevy_mod_scripting_bindings/src/function/script_function.rs  43% smaller
  crates/bevy_mod_scripting_bindings/src/reference.rs  40% smaller
  crates/bevy_mod_scripting_core/src/handler.rs  36% smaller
  crates/bevy_mod_scripting_display/src/impls/std.rs  34% smaller
  crates/languages/bevy_mod_scripting_lua/src/lib.rs  33% smaller
  crates/bevy_mod_scripting_core/src/commands.rs  29% smaller
  crates/testing_crates/script_integration_test_harness/src/lib.rs  28% smaller
  crates/bevy_mod_scripting_core/src/context.rs  26% smaller
  crates/bevy_mod_scripting_display/src/impls/bevy_ecs.rs  22% smaller
  crates/languages/bevy_mod_scripting_rhai/src/lib.rs  20% smaller
  crates/bevy_mod_scripting_core/src/script_system.rs  15% smaller
  crates/bevy_mod_scripting_display/src/lib.rs  13% smaller
  crates/bevy_mod_scripting_bindings/src/error.rs  12% smaller
  crates/bevy_mod_scripting_bindings/src/script_component.rs  10% smaller
  crates/testing_crates/script_integration_test_harness/src/test_functions.rs  6% smaller
  crates/bevy_mod_scripting_bindings/src/schedule.rs  5% smaller
  crates/bevy_mod_scripting_bindings/src/query.rs  3% smaller
  crates/bevy_mod_scripting_core/src/lib.rs  1% smaller
  crates/bevy_mod_scripting_core/src/error.rs  1% smaller
  Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_bindings/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_bindings/src/access_map.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/allocator.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/reflection_extensions.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/world.rs  0% smaller
  crates/bevy_mod_scripting_bindings/src/world_extensions.rs  0% smaller
  crates/bevy_mod_scripting_core/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_core/src/pipeline/mod.rs  0% smaller
  crates/bevy_mod_scripting_display/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_display/src/impls/bevy_asset.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/bevy_platform.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/bevy_reflect.rs  0% smaller
  crates/bevy_mod_scripting_display/src/impls/parking_lock.rs  0% smaller
  crates/bevy_mod_scripting_functions/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_world/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_world/src/access_map.rs  0% smaller
  crates/bevy_mod_scripting_world/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_world/src/world.rs  0% smaller
  crates/bindings/bevy_a11y_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_animation_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_asset_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_camera_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_color_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_core_pipeline_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_ecs_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_gizmos_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_gltf_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_image_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_input_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_input_focus_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_light_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_math_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_mesh_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_pbr_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_picking_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_post_process_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_reflect_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_render_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_scene_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_sprite_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_sprite_render_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_text_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_time_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_transform_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_ui_bms_bindings/Cargo.toml Unsupported file format
  crates/bindings/bevy_ui_render_bms_bindings/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_lua/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs  0% smaller
  crates/languages/bevy_mod_scripting_rhai/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_rhai/src/bindings/reference.rs  0% smaller
  crates/testing_crates/script_integration_test_harness/Cargo.toml Unsupported file format
  xtask/templates/bindings_crate.toml.tera Unsupported file format

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

🐰 Bencher Report

Branchfeat/decouple-world-abstractions
Testbedlinux-gha

🚨 4 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
conversions/Mut::fromLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
512.06 ns
(+483.17%)Baseline: 87.81 ns
113.47 ns
(451.27%)

conversions/Ref::fromLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
667.33 ns
(+690.72%)Baseline: 84.40 ns
111.53 ns
(598.37%)

conversions/ScriptValue::Reference::from_intoLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
33.18 ns
(+30.93%)Baseline: 25.34 ns
29.04 ns
(114.23%)

resource/access LuaLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
5.95 µs
(+56.95%)Baseline: 3.79 µs
4.47 µs
(133.02%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
component/access Lua📈 view plot
🚷 view threshold
3,649.10 ns
(-30.74%)Baseline: 5,268.87 ns
8,182.42 ns
(44.60%)
component/access Rhai📈 view plot
🚷 view threshold
9,952.30 ns
(+7.87%)Baseline: 9,226.34 ns
11,545.95 ns
(86.20%)
component/get Lua📈 view plot
🚷 view threshold
3,232.80 ns
(+3.85%)Baseline: 3,112.99 ns
3,530.89 ns
(91.56%)
component/get Rhai📈 view plot
🚷 view threshold
8,694.20 ns
(+10.44%)Baseline: 7,872.25 ns
10,037.40 ns
(86.62%)
conversions/Mut::from📈 view plot
🚷 view threshold
🚨 view alert (🔔)
512.06 ns
(+483.17%)Baseline: 87.81 ns
113.47 ns
(451.27%)

conversions/Ref::from📈 view plot
🚷 view threshold
🚨 view alert (🔔)
667.33 ns
(+690.72%)Baseline: 84.40 ns
111.53 ns
(598.37%)

conversions/ScriptValue::List📈 view plot
🚷 view threshold
435.35 ns
(+15.25%)Baseline: 377.75 ns
461.30 ns
(94.37%)
conversions/ScriptValue::Map📈 view plot
🚷 view threshold
1,294.30 ns
(+12.26%)Baseline: 1,152.97 ns
1,495.26 ns
(86.56%)
conversions/ScriptValue::Reference::from_into📈 view plot
🚷 view threshold
🚨 view alert (🔔)
33.18 ns
(+30.93%)Baseline: 25.34 ns
29.04 ns
(114.23%)

conversions/Val::from_into📈 view plot
🚷 view threshold
266.59 ns
(-12.80%)Baseline: 305.72 ns
466.75 ns
(57.12%)
function/call 4 args Lua📈 view plot
🚷 view threshold
1,984.90 ns
(+1.63%)Baseline: 1,953.10 ns
2,058.90 ns
(96.41%)
function/call 4 args Rhai📈 view plot
🚷 view threshold
1,570.60 ns
(+6.93%)Baseline: 1,468.79 ns
1,655.76 ns
(94.86%)
function/call Lua📈 view plot
🚷 view threshold
404.87 ns
(+1.64%)Baseline: 398.35 ns
458.46 ns
(88.31%)
function/call Rhai📈 view plot
🚷 view threshold
433.78 ns
(-3.15%)Baseline: 447.88 ns
532.93 ns
(81.40%)
loading/empty Lua📈 view plot
🚷 view threshold
1,018,200.00 ns
(-25.80%)Baseline: 1,372,161.00 ns
2,222,731.39 ns
(45.81%)
loading/empty Rhai📈 view plot
🚷 view threshold
1,335,700.00 ns
(-21.82%)Baseline: 1,708,560.00 ns
2,774,345.23 ns
(48.14%)
math/vec mat ops Lua📈 view plot
🚷 view threshold
9,643.10 ns
(-4.09%)Baseline: 10,054.31 ns
11,610.77 ns
(83.05%)
math/vec mat ops Rhai📈 view plot
🚷 view threshold
8,563.00 ns
(-6.95%)Baseline: 9,202.64 ns
10,028.15 ns
(85.39%)
query/10 entities Lua📈 view plot
🚷 view threshold
21,450.00 ns
(-6.00%)Baseline: 22,819.20 ns
28,265.76 ns
(75.89%)
query/10 entities Rhai📈 view plot
🚷 view threshold
31,327.00 ns
(+5.77%)Baseline: 29,616.80 ns
33,838.87 ns
(92.58%)
query/100 entities Lua📈 view plot
🚷 view threshold
44,800.00 ns
(+0.85%)Baseline: 44,421.00 ns
54,893.66 ns
(81.61%)
query/100 entities Rhai📈 view plot
🚷 view threshold
46,458.00 ns
(+7.10%)Baseline: 43,379.90 ns
49,094.38 ns
(94.63%)
query/1000 entities Lua📈 view plot
🚷 view threshold
287,180.00 ns
(+2.82%)Baseline: 279,306.00 ns
352,304.20 ns
(81.51%)
query/1000 entities Rhai📈 view plot
🚷 view threshold
207,480.00 ns
(+10.06%)Baseline: 188,523.00 ns
231,258.10 ns
(89.72%)
reflection/10 Lua📈 view plot
🚷 view threshold
5,419.40 ns
(-3.52%)Baseline: 5,616.95 ns
6,113.90 ns
(88.64%)
reflection/10 Rhai📈 view plot
🚷 view threshold
15,114.00 ns
(+0.97%)Baseline: 14,969.00 ns
16,390.18 ns
(92.21%)
reflection/100 Lua📈 view plot
🚷 view threshold
44,967.00 ns
(-4.47%)Baseline: 47,069.30 ns
51,577.35 ns
(87.18%)
reflection/100 Rhai📈 view plot
🚷 view threshold
705,380.00 ns
(+2.83%)Baseline: 685,961.00 ns
811,858.94 ns
(86.88%)
resource/access Lua📈 view plot
🚷 view threshold
🚨 view alert (🔔)
5,950.50 ns
(+56.95%)Baseline: 3,791.23 ns
4,473.48 ns
(133.02%)

resource/access Rhai📈 view plot
🚷 view threshold
9,455.40 ns
(+9.75%)Baseline: 8,615.19 ns
10,851.85 ns
(87.13%)
resource/get Lua📈 view plot
🚷 view threshold
2,524.90 ns
(-5.17%)Baseline: 2,662.67 ns
3,189.29 ns
(79.17%)
resource/get Rhai📈 view plot
🚷 view threshold
8,372.00 ns
(+12.40%)Baseline: 7,448.09 ns
9,543.50 ns
(87.72%)
🐰 View full continuous benchmarking report in Bencher

@makspll
Copy link
Copy Markdown
Owner Author

makspll commented Mar 28, 2026

Hmm not sure why the benches are alerting, when running locally this shows as an improvement, at least in the Mut::from benchmark:
image

@makspll
Copy link
Copy Markdown
Owner Author

makspll commented Mar 28, 2026

Claiming access for example looks to have sped up (probably because of the change from a dictionary to a list):
image

@makspll makspll closed this Mar 28, 2026
@makspll makspll reopened this Mar 28, 2026
@makspll makspll closed this Mar 28, 2026
@makspll makspll reopened this Mar 28, 2026
@makspll makspll closed this Mar 28, 2026
@makspll makspll reopened this Mar 28, 2026
@makspll makspll closed this Mar 28, 2026
@makspll makspll reopened this Mar 28, 2026
@makspll makspll closed this Mar 29, 2026
@makspll makspll reopened this Mar 29, 2026
@makspll makspll closed this Mar 29, 2026
@makspll makspll reopened this Mar 29, 2026
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