branchrust_reboot/main/pool_mtcancel
26 Commits over 61 Days - 0.02cph!
Clean: redefine UseMutexPool variable as separate ClientVar and ServerVar instead of merged ConsoleVar
- Codegen
Former doesn't show 2 options in console
Tests: booted into craggy and checked suggestions
Bugfix: add a fuzzy check to prevent Pool read-write head desync causing lots of misses+spills
Surprisingly, it's about 15-25% faster than before fix in MT scenarios, but expectedly slower by 10% in ST (still faster than og Pool)
https://files.facepunch.com/danielprihodko/1b1011b1/WyJ3SUYrMB.png
Tests: ran SpillageRunaway unit test 10 times, booted into Playground 4 times - no debug messages about misses/spills. botted 2k procgen world and checked print_memory
Update(tests): change spill tests assertions to permit writed head to run ahead of read head
Tests: ran unit tests
Update(tests): add a synthetic test to cause pool spill runaway
- moved other spillage tests to Unit namespace and merge into 1 test
Made it to fail consistently at 4 consume threads
Tests: ran tests
Debug: add a bit of logging to track down why fuzzy Pool can spill aggressively
- added a couple temporary perf tests to stress test it
Tests: botted into Playground, ran my temp tests
Bugfix: Implement Pool.Reset and ResetMaxUsageCounter
Tests: booted into craggy and stopped a couple times with Skip Domain Reload active
Merge: from fuzzy_circularbuffer
Chosing this implementation
Update(tests): add a couple tests
- Perf: AllocDeallocMPSCAtomicCounter
- Unit: TestAllocWhenEmpty, TestFreeWhenFull
Tests: ran tests
Update(tests): add 4, 8, 16, 32 task scenarios (previously was just 32) for pool perf tests
Tests: ran perf tests
Update(tests): expand AllocDeallocMTShortLived to optionally simulate busywork
We're never going to be just slamming the pool(or if we do - we shouldn't as that's overhead). This makes the test closer to real world.
Tests: ran perf test
Clean(tests): consolidate pool create-spilled code into Utils.MeasureAndPrint
Tests: ran perf tests
Cherrypick from pool_mt/circularbuffer - test improvements
Update(tests): add a couple more perf tests
- AllocDeallocMT -> AllocDeallocMTLongLived (biases Get, then Free operations), Avg: 3.56901ms
- AllocDeallocMTShortLived - fetches and returns to pool immediately (to evenly spread pressure), Avg: 3.01974ms
- AllocDeallocMPSC - simulates multiple-producers-single-consumer (emulates network write thread under jobs 2) Avg: 12.20773ms
All cases - 32 tasks doing 1k allocs
Tests: ran perf tests
Update(tests): AllocDeallocMT perf test scope annotations
Tests: ran perf test
Bugfix: ensure Pool.Fill keeps items in use valid
Tests: ran unit tests
Optim: rewrite Pool to use ConcurrentBag(many mutexes) instead of single mutex
Fails unit tests, but not going to focus on fixing it just yet - want to make it faster first.
ST avg: 0.88781ms
MT avg: 3.1281ms
Tests: ran perf tests
Update(tests): add TestMTPressure unit test
Wrote it cause my ConcurrentBag based pool is misbehaving
Tests: ran new unit test
Update(tests): pool now has a runtime switch to disable editor-only safety logic, so that perf is more apples-to-apples
ST avg: 1.0358ms
MT avg: 13.6264ms
Tests: ran perf tests
Update(tests): add simple pool perf tests (ST & MT)
ST avg: 1.29925ms for 10k alloc-deallocs
MT avg: 21.16116ms for 1k alloc-deallocs per task, 32 tasks
Tests: ran tests
Update: move Utils Measure routines to Facepunch.System.Tests
- also make it auto-referenced
Tests: compiles