Fusion
Fusion copied to clipboard
For-xyz rewrite
I've spent the last short while working on a rewrite for ForKeys/ForPairs/ForValues, consisting of the following:
- Fixes an issue with dependency captures when using
State:get()inside of theFor-xyzprocessor functions. - ForValues used to always re-use values unless they were a table, or the dependencies change, it has been reworked to have separate values for constants and objects, now working as follows:
- Added additional unit testing
- Reworked the existing logic to be more readable, and noticeably faster, with new vs old benchmarking as follows:
[+] ForKeys
.......................................................... NEW ... OLD
[+] ForKeys with blank input table ....................... 0.75 μs ... 1.24 μs
[+] ForKeys with changed input state - constant output ... 4.80 μs ... 6.86 μs
[+] ForKeys with changed input state - dynamic output .... 4.88 μs ... 3.93 μs
[+] ForKeys with changed input table - constant output ... 2.81 μs ... 4.03 μs
[+] ForKeys with changed input table - dynamic output .... 2.79 μs ... 4.18 μs
[+] ForKeys with input state - constant output ........... 2.36 μs ... 4.48 μs
[+] ForKeys with input state - dynamic output ............ 2.42 μs ... 4.48 μs
[+] ForKeys with input table - constant output ........... 1.79 μs ... 2.75 μs
[+] ForKeys with input table - dynamic output ............ 1.86 μs ... 3.07 μs
[+] ForPairs
.......................................................... NEW ... OLD
[+] ForPairs with blank input table ...................... 0.79 μs ... 1.22 μs
[+] ForPairs with changed input state - constant output .. 4.83 μs ... 6.24 μs
[+] ForPairs with changed input state - dynamic output ... 5.50 μs ... 7.19 μs
[+] ForPairs with changed input table - constant output .. 2.73 μs ... 3.53 μs
[+] ForPairs with changed input table - dynamic output ... 2.84 μs ... 4.10 μs
[+] ForPairs with input state - constant output .......... 2.18 μs ... 3.07 μs
[+] ForPairs with input state - dynamic output ........... 2.30 μs ... 3.51 μs
[+] ForPairs with input table - constant output .......... 1.86 μs ... 2.52 μs
[+] ForPairs with input table - dynamic output ........... 1.88 μs ... 2.77 μs
[+] ForValues
.......................................................... NEW ... OLD
[+] ForValues with blank input table ..................... 0.76 μs ... 1.16 μs
[+] ForValues with changed input state - constant output . 4.69 μs ... 6.06 μs
[+] ForValues with changed input state - dynamic output .. 5.15 μs ... 6.63 μs
[+] ForValues with changed input table - constant output . 2.69 μs ... 3.38 μs
[+] ForValues with changed input table - dynamic output .. 2.67 μs ... 3.93 μs
[+] ForValues with input state - constant output ......... 2.42 μs ... 3.19 μs
[+] ForValues with input state - dynamic output .......... 2.40 μs ... 3.53 μs
[+] ForValues with input table - constant output ......... 1.78 μs ... 2.43 μs
[+] ForValues with input table - dynamic output .......... 1.84 μs ... 2.73 μs
It might also be easier to look directly at the edited files instead of looking at the file diffs, you can view each file individually here:
- ForKeys: https://github.com/nottirb/Fusion/blob/for-xyz-rework/src/State/ForKeys.lua
- ForValues: https://github.com/nottirb/Fusion/blob/for-xyz-rework/src/State/ForValues.lua
- ForPairs: https://github.com/nottirb/Fusion/blob/for-xyz-rework/src/State/ForPairs.lua
It is also worth mentioning that some GC tests are failing, though bumping the time they were given fixed them. I have opted to not include time bumps on them in this PR though.
Sorry this took so long, between work, college, and a research position at my college it has taken a while. Please let me know if you see any issues. If you can come up with additional unit tests please let me know and I will implement them. Thanks!