2,081 Commits over 518 Days - 0.17cph!
Optim: TriggerParent.TickMode 1 - use cached water and ladder results in UsePlayerUpdateJobs 2 env
- codegen
This should allow us to skip ~30% of the overall runtime. Can be disabled via TriggerParent.UsePlayerV2Shortcuts 0 (defaults to 1)
Tests: none, will check tomorrow once brain is fresh
Optim: TriggerParent.TickMode 1 - avoid unnecessary entity lookups in RunClippingChecks
Microoptim, but why not
Tests: none, trivial change
Optim: TriggerParent.TickMode 1 - skip RunClippingChecks for entities that failed RunCheckForObjUnderFeet
Tests: none, trivial change
Clean: remove a couple TODOs
Was worried about a bug, but deeper scrutiny think the code is correct
Tests: none, trivial change
Clean: refactor TriggerParent.ShouldParentEntitiesJobs
- Added profiling scopes
No functional changes. This makes data flow easier to track and manage, and helps visualizing stages in perf snapshots.
Tests: built a long-boat in tickmode 1, spawend 6 players on it, went to edit mode and back, jumped on-and-off as it was moving
Bugfix: Add missing Native collection disposal in GamePhysics
Audited all of GamePhysics, looks to be the only cases that slipped in
Tests: unit tests + built a boat with tickmode 1
Optim: use persistent buffers for TriggerParent::RunCustomJobsQueue
- codegen
Tests: with tickmode 1 - built a boat, jumped on-off
Clean: rip out tickmode 1 and 2, rename Jobs mode as tickmode 1
- codegen
Out of all versions it's fastest, so only going to continue with it vs baseline 0
Tests: compiles
Merge: from triggerparentdelayedexit_optim
- Bugfix: properly cleanup TriggerParent and TriggerParentDelayedExit to avoid invalid invokes running
Tests: built & finished a boat, jumped around while moving, put it into edit, finished, jumped around - no errors, no extra invokes
Bugfix: properly clean-up TriggerParent and TriggerParentDelayedExit when it gets disabled
Reimplements intents of `139965`.
Tests: built & finished a boat, jumped around while moving, put it into edit, finished, jumped around - no errors, no extra invokes
Merge: from triggerparentdelayedexit_optim
- Bugfix: mitigate double trigger exit call on TriggerParent
- Bugfix: TriggerParentDelayedExit leaving invalid invokes when editing already existing boat
Tests: built a boat, spawned a player on it, edited - no more errors, no extra invokes running
Undo of Undo:
139927 (merge: from triggerparentdelayedexit_optim)
Will apply the fixes on top with merge
Bugfix: TriggerParentDelayedExit - skip entity-delay logic when trigger gets disabled
This left invalid invokes running when editing existing player boat, inflating the perf cost
Tests: edited existing boat, checked profiler - saw no perf samples gor persistent queue
Bugfix: early out when double-remove happens
Not sure why yet, but saw the same with double-add before, so going to replicate. Also noticed that we can be tracked, but have null-entitycontents, which leads to wasted Invokes, adding overhead - checking
Tests: built boat, spawned npc, went to edit mode - no more errors
Undo: `139927` (merge: from triggerparentdelayedexit_optim)
Merge: from triggerparentdelayedexit_optim
- Optim: triggerparent.tickmode 0-3 (0 default) - various implementations for TriggerParent.OnTick execution, can be switched at runtime.
Tests: unit tests + building a boat, jumping around on it, trying going under it and climbing ladders and stairs.
Update: Codegen
Tests: ran "check compile errors"
Optim: in tickmode 3, run OverlapOBB and TraceRealm queries in parallel
Should help in many-boats-players scenarios, in theory
Tests: built a boat and jumped around as it was moving
Bugfix: SelectNearestNHitsJob - ensure we emit an end if we couldn't select requested number of hits
- Added couple early returns to avoid div by 0 issues
Tests: rode a boat with tickmode 3
Update: initial full version of TriggerParent.ShouldParentEntitiesJobs
inlines ToClipping so that we can batch OverlapOBB, but doesn't batch expensive-but-rare checks - need to see if we need this during playtest
Tests: built a boat, finished it, enabled tickmode 3, tried jumping on/off the boat
Update: Added GamePhysics.OverlapOBBs
- added basic consistency unit test: TestOverlapOBBsConsistency
Tests: ran unit test
Bugfix: GamePhysics.TraceRealmRays now considers non-entity hits as valid
- fix build failures in CLIENT only mode
- also added option to specify whether to run water query or not
Tests: ran unit tests(C+S and C separately) - they pass
Tests: rework GamePhysicsTests.TraceRealms to work in C+S and C modes
No longer permitting running S realm tests in C editor (as that created impossible spawn scenarios)
Tests: ran unit test in both modes
Tests: add TestTraceRealmRays unit test
Shows that there's a bug with TraceRealmRays - will submit next
Tests: ran unit tests
Optim: Use burst to generate sort jobs
Despite replacing previous optim, saves us another 0.1ms on top of it (4.25ms -> 4.15ms avg for 2k rays). Left a comment that we need alloc-free tasks to optim further(scheduling sort jobs is expensive, but thread safe).
Tests: ran unit tests
Optim: manually kick off sort jobs to worker threads when enough is accumulated
On a 2k TestTraceRays gives us 0.15ms (4.25ms -> 4.4ms). Building jobs using burst might be faster though, gonna try that next.
Tests: ran unit tests
Bugfix: ensure we free counts array only after all sorting jobs are done
Tests: ran unit tests (though they didn't catch it before)
Tests: reduce ray count for Perf.TestTraceRay/-s to 2k
8k is too much, hangs serial rays. 2k is already very bad (3.4s avg per run for serial, 7.1ms for batched)
Tests: reran tests
Tests: Add TraceRay/-s perf tests
The numbers of serial vs batched are a bit too crazy(128 rays: 7.5ms vs 0.3ms; 1024: 716ms vs 2.2ms), but looks like managed sort is too costly. Need to investigate the 8k batched hang(5min+ )
Tests: ran the perf tests
Tests: add perf tests for TraceRaysUnsorted and TraceAllUnordered(radius == 0)
At 128 rays perf is same, at 8k we get 25% faster without water checks/41% faster with water. Need to profile deeper if we get more wins
Tests: ran the new tests
Clean: reorganize GamePhysics tests into Unit child class
Prep for Perf unit tests.
Tests: ran all relevant tests, discovered we forgot to implement 1 fully - chasing up separately
Update: made GamePhysics.TraceRays return guaranteed nearest hits
- added fast path for TraceRays with maxHits == 1
- Added tests for TraceRaysUnordered, rewrote test for TraceRays to be more thorough
Tests: ran unit tests
Update: started on ShouldParentEntitiesJobs (incorrect name)
- Simplified ShouldParentEntities (also incorrectly named)
Converted CheckForObjUnderFeet to burst jobs, need to do IsClipping internals next (needs a bunch more on the GamePhysics side)
Tests: none, not ready
Update: GamePhysics.TraceRays now supports ignore entities
- Added TraceRealmRays (not unit tested, will do that tomorrow)
- Added unit tests for TraceRays
- TraceRays skips sorting if maxHitsPerTrace is less than 2
Tests: unit tests
Update: hook up PersistentObjectQueue as well
- consolidate work scheduling to AddTo-/RemoveFromActiveTriggers
- fixed an exception when unity sends 2 OnTriggerEnter for 1 entity (not sure how, but TriggerBase handled it already)
Just the most complicated version left - custom queue with jobs
Tests: jumped on and off from moving boat
Update: hooked up the crude queue, added server var
- partial codegen (Grid<T> borkage)
- Fixed a couple bugs with invalid tracking on TriggerParents in StableObjectCache
Can move on to other queue impls
Tests: craggy, toggled default and batched mode
WIP: TriggerParent managed queue, no batching, no burst
Still need to implement using PersistentObjectWorkQueue and experiment with batched-burst queries and compare all, as this version should have a bit more overhead due to bookkeeping.
Tests: none, not plugged in
Merge: from networkcache_stalegroup
- Bugfix for vanishing child entities (l-ike drybox on rhib)
Tests: spawned rhib, teleported far then back after pause, paused again - all parts stayed in place
Bugfix: fix missing child entities (like drybox on rhib) by invalidating network cache on netgroup change
Previously if parent moved it would update the network group of the hierarchy, but only parent would have it's cache invalidated. This meant that it was possible for child to be with a netgroup outside of network range, while parent is in network range.
Tests: on Craggy, took rhib and drove it from E4 to a row above E0, teleported back to E4, waited for boat to stream out, teleported to boat and waited a bit - it stayed in place (previously drybox would disappear)
Merge: from randomize_junkpile_checkempty
- minor optim to load balance JunkPile::CheckEmpty
Tests: looted one on craggy, saw it disappear
Update: JunkPile.CheckEmpty now have a 5 second randomness
Tests: looted a junkpile on craggy, flew away, waited and got back - it was gone
Merge: from procpop_debug
- Bugfix: fix DensitySpawnPopulation prefab pool being starved out, resulting in failed spawn attempts
- Optim: DensitySpawnPopulation early exits if it reached prefab population target isntead of continuing to try to spawn
- New: spawn.report now contains info about failed iterations and how many entities it recently spawned
- New: spawn.dump_map <pop> [count] which simulates spawns and generates pngs indicating general spawn area and attempted spawns. Pngs in <server_ident>/debug.
Tests: 4.5k procgen in editor - server started with full junkpile pop, simulated spawn gave better numbers
Update: dump_map exports to identity/debug/ folder
- client buildfixes
Tests: built all modes in editor, ran dump_map on craggy
Optim: DensitySpawnPopulation - stop trying to spawn prefabs when used up available prefabs
This eliminates a lot of wastefull attempts
Tests: while at full population, ran dump_map with 1000 items to fill - reported 0 attempts
Bugfix: DensitySpawnPopulation - avoid weighted prefab pool starvation
Bug from 2022 - we never checked if prefab instantiation ever failed, as it has it's own internal checks
Tests: ran spawn.report - saw that junkpiles population was full after boot. deleted junkpiles pop then immediately simulated spawning - saw green pixels, got the count