Compare commits

...
Author SHA1 Message Date
Ludovic MarieandClaude Opus 5.5 e76ac94aab Mobs: hand the ticked mob list back, not a copy of it
tick_creature_entities takes self.mobs out for the mob loop and appended it
back to the then empty list: Vec::append on an empty Vec copies every Mob
into a fresh buffer. With a server's 2000 mobs that is a multi-megabyte
allocation (mimalloc's huge-page path, madvise) and a memmove each tick,
1.5 % of the tick thread in a 60-player profile. Nothing adds to self.mobs
during the loop, so the list now moves back; the append stays for the case
where something did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 15:57:32 +01:00
+7 -1
View File
@@ -853,7 +853,13 @@ impl Game<'_> {
bindings.retain(|id, _| live.contains(id));
host.mob_players = bindings;
}
self.mobs.append(&mut mobs);
// The ticked list goes back whole: appended to an empty list, a
// server's thousands of mobs were copied into a new buffer each tick.
if self.mobs.is_empty() {
self.mobs = mobs;
} else {
self.mobs.append(&mut mobs);
}
self.died = died;
// ... and entity event 60 goes out as it is: the poof.
for (id, at, width, height) in gone {