Make tick smoothers multithreaded#990
Conversation
|
I'd like to get this in but given the significant amount of change and complexity I do not want to merge this over official files. There's not enough dev time to move-around to verify/maintain all of these changes. As mentioned via DM though, I still do want to see this in so you can benefit from them, as well anyone else that wishes to try these changes out. We talked about wrapping everything in a define. Can you wrap the original files in a preprocessors please then make a new file for each you modified in a subfolder... eg: FishNet/Components/Smoothing/TickSmoother.cs //original and in your files wrap in the preprocessors |
|
All done, I guess @FirstGearGames |
|
merged! |
Tick Smoothing: execution refactor (single-thread -> jobified)
This PR changes how the existing tick smoothing runs: from per-object, main-thread execution to a centralized jobified pipeline in
TickSmoothingManager. The core smoothing idea remains the same; the implementation/dispatch model is different.Key differences (before vs after)
Before: each
TickSmootherControllersubscribed toTimeManagerand ran smoothing on the main thread.After: the controller only
Register/Unregisters; all event wiring (OnUpdate/OnPreTick/OnPostTick, RTT, prediction replay) and execution are handled inTickSmoothingManager.Before: per-object state lived in controller/smoother instances.
After: state is stored in the manager as indexed Native/SoA containers (masks like
canSmooth/useOwner/objectReconciling/..., realtime interpolation/multipliers, move-rates, snapshots, and a per-indexTickTransformPropertiesqueue).Multithreading approach: work is expressed as explicit job chains with
JobHandledependencies (no per-object main-thread loops).IJobParallelForTransformoverTransformAccessArray(_graphicalTaa,_targetTaa,_trackerTaa).IJobParallelForwith batching (ComputeBatchSizebased onJobsUtility.JobWorkerCount).Dispatch pattern: “payload + executeMask”. Jobs populate payload arrays (move, discard, set rates, snap, teleport, enqueue/clear, replay modify), and subsequent jobs apply only entries where
executeMask != 0.Tick buffer: the per-object tick buffer is now job-friendly via
StripedRingQueue<TickTransformProperties>(one ring queue per index/stripe). Queue trimming (limits + required headroom over interpolation) is performed inDiscardExcessive...as part of job chains.Phase breakdown (job chains)
OnPreTickPreTickMarkJob→ discard → teleport (and queue clear) →PreTickCaptureGraphicalJob→Complete()OnPostTickCaptureLocalTargetJob→PostTickCaptureTrackerJob→PostTickJob(produces snap/enqueue payloads)Complete()OnUpdateUpdateJob(move payload) →MoveToTargetJob(moves graphical; may trigger set rates/multiplier/clear) →Complete()RTT / prediction replay
ModifyTransformPropertiesafter prediction replay.Additional changes
MovementSettings.UseLocalSpaceto select local/world space for position/rotation smoothing..asmdefdependencies for Jobs/Burst/Mathematics/Collections.