⚡ Three System-Level Optimizations
1. CriticalSection — Spin-First Lock Acquisition
WoW uses many short-held locks for internal synchronization (Lua state, sound, network buffers). When a lock is contended, EnterCriticalSection immediately enters a kernel wait — an expensive ~10-15 microsecond context switch.
Fix: New EnterCriticalSection hook:
TryEnterCriticalSection()— instant, no kernel transition- If fails: spin 32 iterations with
_mm_pause(yield to SMT sibling) - If still fails: real
EnterCriticalSectionkernel wait
Most WoW locks are held for microseconds — the spin-first approach avoids kernel transitions for the vast majority of lock acquisitions.
2. SetFilePointer → SetFilePointerEx
WoW uses the legacy 32-bit SetFilePointer API with awkward dual-return error handling. Internally, Windows redirects this to SetFilePointerEx anyway.
Fix: Direct redirect to SetFilePointerEx — cleaner code path, one fewer API layer.
3. GlobalAlloc/GlobalFree — mimalloc for Fixed Allocations
WoW uses GlobalAlloc for clipboard operations and some legacy data paths. GMEM_FIXED allocations are plain memory blocks.
Fix: Route GMEM_FIXED allocations through mimalloc. GMEM_MOVEABLE stays on the original heap (required for GlobalLock/GlobalUnlock semantics).
Summary
| Feature | Before | After |
|---|---|---|
| Lock contention | Immediate kernel wait | Spin-first, then kernel |
| File seeking | Legacy 32-bit API | Direct 64-bit path |
| GlobalAlloc (fixed) | Windows heap | mimalloc |
All optimizations are pure Win32/runtime — zero addon/Lua impact.
Full Changelog
v2.0.9...v2.1.0