Make tick smoothers multithreaded #990
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.