[Core] Make object id more performant by IXLLEGACYIXL · Pull Request #1957 · stride3d/stride (original) (raw)
PR Details
the to string in object id has an array which allocates memory, using span would remove it
Description
im not sure if that is even wanted.
problem is with the new byte[] which could be made a span but assemblyprocessor is netstandard2.0 so it doesnt detect the new string(span) so i have to use cast to readonly span
the benchmark is here
Method | Count | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|---|
OldToString | 100 | 3.371 us | 0.0389 us | 0.0478 us | 2.0981 | 17.19 KB |
NewToString | 100 | 3.348 us | 0.0662 us | 0.0587 us | 1.0490 | 8.59 KB |
WithNewStringAndSpan | 100 | 3.161 us | 0.0196 us | 0.0164 us | 1.0490 | 8.59 KB |
OldToString | 200 | 7.602 us | 0.2865 us | 0.8448 us | 4.2038 | 34.38 KB |
NewToString | 200 | 7.535 us | 0.1491 us | 0.2573 us | 2.0905 | 17.19 KB |
WithNewStringAndSpan | 200 | 6.345 us | 0.1081 us | 0.1367 us | 2.0981 | 17.19 KB |
OldToString | 2000 | 63.012 us | 1.0263 us | 0.9600 us | 41.9922 | 343.75 KB |
NewToString | 2000 | 64.608 us | 1.2845 us | 2.6528 us | 20.9961 | 171.88 KB |
WithNewStringAndSpan | 2000 | 61.151 us | 1.1198 us | 0.9926 us | 20.9961 | 171.88 KB |
so memory allocation is halfed and object id is frequently called
performance wise it doesnt do too much
would the assemblyprocessor be 2.1 then the "faster" way with new string(span) could be chosen but im not sure why the assemblyprocessor is netstandard2.0 and not netstandard2.1
Motivation and Context
halfing the allocation in a frequently called method
Types of changes
- Docs change / refactoring / dependency upgrade
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
Checklist
- My change requires a change to the documentation.
- I have added tests to cover my changes.
- All new and existing tests passed.
help
idk how that works with the assembly processor, as this file is referenced by it so i think it doesnt need a commit?
a test of it would be good, if a bigger project opens it and it works then it should work, i couldnt make projects fail with that
i had to repair in stride.core.targets the assemblyprocessor path as i cant buid else stride anymore, this is not inlcuded in that PR but should be considered that someone with normal stride can build it