Try to avoid SetLastError in win/systhrd.inc:SysRelocateThreadvar.
While investigating why threadvars are so slow in general and in particular how much heap.inc
is affected I found that SetLastError
is not entirely trivial. On my computer, avoiding it like this saves 3 ns out of 9 per RelocateThreadVar
, which when compiling pp.pas
adds up to a total of 150 ms (compiler calls 20M GetMem
+ 20M FreeMem
, each accesses a threadvar) out of 8 s.
(Not handling the last error at all is even better though... is #10205 (closed) / 6c5471f3 still even a thing?)