Skip to content

raid-survival: server scans every target per zombie and sends zombie state every tick #19

Open

Description

@Exeloo

Description

raid-survival's server does work per zombie that does not depend on the zombie, every tick (60 per second). Both come from the original game and were kept as they were by the remake (#18).

  • Each zombie's behaviour calls gatherAttackable (zombie-ai.ts#L47, defined at #L134): two indexed zipper queries, three component lookups and new objects and arrays per player and building. With Z zombies that is 2Z queries and about Z × (players + buildings) objects per tick, although the targets are the same for every zombie.
  • A zombie chasing a player or building sets needsBroadcast on every tick (zombie-ai.ts#L120), so it sends a zombieState message to every client every tick even when its velocity did not change. broadcast also queries every Client on each message (broadcast.ts#L11).

Evidence

Traced from the code by the performance review; not measured. The question to settle it: the tick time at the largest wave of zombie-wave.system.ts with several clients, before and after.

Expected

Gather the targets once per tick and pass them to each behaviour; send a zombie's state only when its velocity or target changes (as the pong servers' syncMoves does); collect the client ids once per tick.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions