-
-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Replace ParsedPath
with custom ReferencePath
, support Map
and Set
references with arbitrary types
#491
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Branch | feat/overhauled-references |
Testbed | linux-gha |
Click to view all benchmark results
Benchmark | Latency | Benchmark Result nanoseconds (ns) (Result Δ%) | Upper Boundary nanoseconds (ns) (Limit %) |
---|---|---|---|
component/access Lua | 📈 view plot 🚷 view threshold | 3,666.20 ns(-10.61%)Baseline: 4,101.16 ns | 4,731.86 ns (77.48%) |
component/access Rhai | 📈 view plot 🚷 view threshold | 5,592.50 ns(-5.95%)Baseline: 5,946.04 ns | 6,310.98 ns (88.62%) |
component/get Lua | 📈 view plot 🚷 view threshold | 2,381.90 ns(-4.10%)Baseline: 2,483.72 ns | 2,786.35 ns (85.48%) |
component/get Rhai | 📈 view plot 🚷 view threshold | 4,221.90 ns(-5.43%)Baseline: 4,464.28 ns | 4,839.05 ns (87.25%) |
conversions/Mut::from | 📈 view plot 🚷 view threshold | 94.78 ns(+6.69%)Baseline: 88.84 ns | 96.13 ns (98.60%) |
conversions/Ref::from | 📈 view plot 🚷 view threshold | 91.22 ns(+4.58%)Baseline: 87.22 ns | 96.46 ns (94.56%) |
conversions/ScriptValue::List | 📈 view plot 🚷 view threshold | 374.86 ns(+9.04%)Baseline: 343.77 ns | 462.81 ns (81.00%) |
conversions/ScriptValue::Map | 📈 view plot 🚷 view threshold | 975.99 ns(-9.99%)Baseline: 1,084.29 ns | 1,228.61 ns (79.44%) |
conversions/ScriptValue::Reference::from_into | 📈 view plot 🚷 view threshold | 27.77 ns(+3.18%)Baseline: 26.91 ns | 30.06 ns (92.39%) |
conversions/Val::from_into | 📈 view plot 🚷 view threshold | 264.57 ns(-12.78%)Baseline: 303.34 ns | 361.77 ns (73.13%) |
function/call 4 args Lua | 📈 view plot 🚷 view threshold | 1,692.60 ns(-10.10%)Baseline: 1,882.78 ns | 2,118.77 ns (79.89%) |
function/call 4 args Rhai | 📈 view plot 🚷 view threshold | 1,409.10 ns(-6.56%)Baseline: 1,507.98 ns | 1,650.40 ns (85.38%) |
function/call Lua | 📈 view plot 🚷 view threshold | 234.67 ns(-5.72%)Baseline: 248.91 ns | 272.91 ns (85.99%) |
function/call Rhai | 📈 view plot 🚷 view threshold | 442.97 ns(-2.69%)Baseline: 455.20 ns | 537.69 ns (82.38%) |
loading/empty Lua | 📈 view plot 🚷 view threshold | 791,080.00 ns(+67.08%)Baseline: 473,471.80 ns | 1,636,227.73 ns (48.35%) |
loading/empty Rhai | 📈 view plot 🚷 view threshold | 942,470.00 ns(+32.38%)Baseline: 711,922.00 ns | 1,628,241.01 ns (57.88%) |
math/vec mat ops Lua | 📈 view plot 🚷 view threshold | 6,863.30 ns(-13.32%)Baseline: 7,917.52 ns | 9,360.95 ns (73.32%) |
math/vec mat ops Rhai | 📈 view plot 🚷 view threshold | 6,262.90 ns(-8.62%)Baseline: 6,853.37 ns | 7,672.49 ns (81.63%) |
query/10 entities Lua | 📈 view plot 🚷 view threshold | 19,684.00 ns(-7.13%)Baseline: 21,194.20 ns | 24,114.59 ns (81.63%) |
query/10 entities Rhai | 📈 view plot 🚷 view threshold | 19,203.00 ns(-8.64%)Baseline: 21,018.40 ns | 22,992.81 ns (83.52%) |
query/100 entities Lua | 📈 view plot 🚷 view threshold | 40,027.00 ns(-7.41%)Baseline: 43,232.30 ns | 46,883.04 ns (85.38%) |
query/100 entities Rhai | 📈 view plot 🚷 view threshold | 31,540.00 ns(-8.87%)Baseline: 34,611.50 ns | 37,910.99 ns (83.19%) |
query/1000 entities Lua | 📈 view plot 🚷 view threshold | 245,530.00 ns(-12.81%)Baseline: 281,589.00 ns | 325,308.44 ns (75.48%) |
query/1000 entities Rhai | 📈 view plot 🚷 view threshold | 162,140.00 ns(-5.95%)Baseline: 172,406.00 ns | 189,660.23 ns (85.49%) |
reflection/10 Lua | 📈 view plot 🚷 view threshold | 5,534.90 ns(-12.34%)Baseline: 6,314.29 ns | 7,088.64 ns (78.08%) |
reflection/10 Rhai | 📈 view plot 🚷 view threshold | 14,858.00 ns(-6.67%)Baseline: 15,920.50 ns | 17,003.84 ns (87.38%) |
reflection/100 Lua | 📈 view plot 🚷 view threshold | 47,685.00 ns(-10.19%)Baseline: 53,094.10 ns | 58,752.47 ns (81.16%) |
reflection/100 Rhai | 📈 view plot 🚷 view threshold | 712,240.00 ns(-9.04%)Baseline: 782,997.00 ns | 856,341.64 ns (83.17%) |
resource/access Lua | 📈 view plot 🚷 view threshold | 3,291.90 ns(-9.77%)Baseline: 3,648.51 ns | 4,151.56 ns (79.29%) |
resource/access Rhai | 📈 view plot 🚷 view threshold | 5,131.80 ns(-5.74%)Baseline: 5,444.06 ns | 5,814.85 ns (88.25%) |
resource/get Lua | 📈 view plot 🚷 view threshold | 1,847.40 ns(-11.38%)Baseline: 2,084.63 ns | 2,405.74 ns (76.79%) |
resource/get Rhai | 📈 view plot 🚷 view threshold | 3,836.30 ns(-3.70%)Baseline: 3,983.77 ns | 4,261.57 ns (90.02%) |
That should do it for map and set references |
Map
and Set
refernecesParsedPath
with custom ReferencePath
, support Map
and Set
references with arbitrary types
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ReferencePath
andReferencePart
structs, which serve as alternatives toParsedPath
from bevy. These do not make assumptions about the pointed to type, i.e.IntegerAccess
versusFieldAccess
, allowing for more flexibility, and removing the need for underscores like_1
in accessing tuples and tuple structs.Adds Map and Set support to references. (Except for mutable references into sets, which apparently don't have Reflection support 🤷)
Note this allows refing into maps and sets with arbitrary types (say custom structs) but functions still only support string Key'ed HashMaps
Why
Bevy reflection paths are not particularly well suited to this crate, they make the assumption that the consumer knows the structure of your types, which in the case of scripting is not always the case. Ideally the path system should be flexible, and forgivable, while also allowing any kind of access into your types.
Bevy currently does not support Maps or Sets in
ParsedPath
, which historically meant that you were stuck usingmap_get
bindings and pass by value semantics (no modifying the upstream values by reference).With this change, consumers will be able to:
Map
typesMap
types with arbitrary values (see tests)Set
types (but not modify, due to other reflection limitations)Migration Guide
Replace accesses to tuple structs, and tuples containing underscores, i.e. instead of
my_tuple._1
usemy_tuple[1]