node-raylib icon indicating copy to clipboard operation
node-raylib copied to clipboard

generator: flatten structs & use refs better for more performance

Open konsumer opened this issue 3 years ago • 2 comments

@twuky found that flattening structs on in/out gains some major performance. Here are the metrics on my system (linux, RTX 3050):

current

Screenshot from 2022-02-22 13-02-17

proposed

On twuky's tests I get insanely good FPS:

method: DrawTexture, args: 4, bunnies: 14920
method: DrawTextureNew, args: 4, bunnies: 95750
method: DrawTextureNewWhite, args: 4, bunnies: 100820
method: DrawTextureShortInt, args: 6, bunnies: 1000
method: DrawTexturePointer, args: 4, bunnies: 1000
method: DrawTextureShortWhite, args: 5, bunnies: 89900
method: DrawTextureShort, args: 9, bunnies: 65430
method: DrawBunnyWhite, args: 2, bunnies: 101670
method: DrawBunny, args: 6, bunnies: 79460
method: DrawBunnyBuffer, args: 1, bunnies: 55580
method: DrawTextureFlat, args: 11, bunnies: 62720
method: DrawTextureFlatWhite, args: 7, bunnies: 78390
method: DrawTextureShortBuffer, args: 6, bunnies: 65410

It's not a totally fair comparison, in the sense that branch has other optimizations (which we should also add to the generator) but the flat thing by itself will help, and refs will also help. We should try to do both in the generated code.

konsumer avatar Feb 22 '22 21:02 konsumer

For more details on how the experimental benchmarks I wrote were implemented - reference https://github.com/RobLoach/node-raylib/issues/100#issuecomment-1046400083

Some documentation on what flattening arguments looks like in C++ and JS can be found in the raylib4 branch, in the generator docs: https://github.com/RobLoach/node-raylib/blob/raylib4/docs/generator/flattening_arguments.md

twuky avatar Feb 22 '22 21:02 twuky

Wow!

RobLoach avatar Feb 24 '22 05:02 RobLoach