FiberTaskingLib
FiberTaskingLib copied to clipboard
Use an atomic bitfield for m_freeFibers instead of an array of atomic<bool>
The idea being that we can use less atomic memory fetches / memory thrashing.
Another approach would be to still use the array of atomic
Thus, GetNextFreeFiberIndex() would first query the prng in order to get the start index, and then it would search from startIndex and loop around to startIndex - 1. (the current behavior iterates from 0 to m_fiberPoolSize)
No significant difference in run time of tests.
First three runs are with the new code. Last three are original code:
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 4.1932906
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 3.9279423
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 4.2488083
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 3.9117287
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 4.2749436
PS T:\Programming_Projects\ftl\FiberTaskingLib\build\x64-Release\tests> Measure-Command { .\ftl-test.exe }
TotalSeconds : 3.955665
Closing as Not Worth the Extra Code Complexity.
Memory saving is minimal. Benchmark shows basically zero speed difference