Slow ZeroStruct call

Isn't the fact that when you create a brand new arena via VirtualAlloc the reason it was so slow?
As the very first time you touch the page the Windows COW system would be forced to map the page for real
and at the end of the sim you ditch the memory again

Would be easy to test...
Call ZeroStruct twice and only time the second call

Edited by jeringa on
Or first write a 0 byte to the first address per allocated page in the arena and then time the clear.

Though a better way to fix that would be to let the thread keep an initialized arena and pass it down when the task with memory is executed.

aka let the thread hold the arena which puts it in a perfect position to be reused by the next task which needs memory.

Edited by ratchetfreak on
Yeah, that is a good point - it could be that the VirtualAlloc call doesn't take much time but it's page faulting in the ZeroAlloc because Windows hasn't mapped it yet, which would argue I should have gone ahead and done the test of having threads have their own scratch arena... we should try that on the next stream.

- Casey