perf: 100 awake idle NPCs cost ~2 ms of frame more than the bare swap (Oxide) #13
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by stage 9's performance check (D306,
rnt.costintools/RunicNpcTest.cs). The org lead's call on 2026-10-06: update the cost warning with today's numbers, log this as an optimisation fix, and keep going. Not a v1.0.0 blocker.The numbers
How much 100 NPCs raise the median server frame over the same session's empty server. 6000 map (seed 981448696), the other rig stopped. Rust 25681086, Oxide 2.0.7801, Carbon 2.0.262. "Harness" is stage 1's bare swapped scientist (
rnh.cost), measured in the same session.Where to look
What RunicNPC adds to every think of an awake NPC, beyond Rust's own
base.Think:RunicNpcBrain.Think: every 2 s,PlayerWithin(the sleep check),Reground→OffMeshReason(a navmesh sample and more),CheckEscortand the tether check.Fight(...)on every think, even with no faction settings:HuntsOf,brain.FightingAPlayer()(a loop over memory targets),KitTickwhen the profile uses kit items, and the Stopwatch around it.IAISenses/IAIAttackmembers (IsTarget,GetBestTarget, …), which Rust calls on every sense.Profile one think at a time (a Stopwatch around each part, reported by
rnpc.status), then cut what dominates. Re-measure withrnt.cost 60andrnt.cost 40 idle, and with stage 1'srnh.cost 60in the same session as the reference.Done when
Awake idle on Oxide is within 1 ms of the bare swap in the same session, and the cost warning (
CostWarning, now 3 ms idle awake, 0.5 ms asleep, 9 ms fighting per 100) is lowered to match.