Skip to content

perf: despawn and playermap optimization - #877

Open
chocodev11 wants to merge 5 commits into
Steel-Foundation:better-systemsfrom
chocodev11:fix/despawn_persistent_mob
Open

chocodev11 wants to merge 5 commits into
Steel-Foundation:better-systemsfrom
chocodev11:fix/despawn_persistent_mob

Conversation

@chocodev11

Copy link
Copy Markdown
Contributor

Type of change

  • Block implementation
  • Item implementation
  • Command implementation
  • Entity implementation
  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Performance improvement
  • Chore / tooling

Description

  • check persistence mob before distance to player when despawning.
  • playermap now keeps its iteration order as a snapshot of player slots that is rebuilt only when a player is inserted or removed, so iter_players no longer locks, allocates, hashes or clones an arc per player, which made the nearest-player scan about 3x faster. (claude do the benchmark)

How this was tested

Screenshots / logs

Checklist

  • Code builds w/o errors or warnings
  • Self-reviewed the diff
  • Docs updated (if applicable)
  • No leftover debug code / comments

Classes / commands modified:

Additional notes

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Flint test report

Implemented tests: 820 total, 772 passed, 48 failed

Regressions

  • ❌ bamboo_stacking_on_stalk (missing from results)

Newly implemented blocks/items

None.

Workflow run · failure links to flint-viz are in the test log

Comment thread steel-core/src/entity/mob/mod.rs Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts with the base branch "master". Please resolve those so we can test out your changes.

@github-actions

Copy link
Copy Markdown

Conflicts have been resolved! 🎉

@chocodev11
chocodev11 requested a review from coco875 November 21, 2026 04:40
Comment on lines +189 to +191
let mut order = Vec::clone(order);
order.retain(|indexed| !Arc::ptr_eq(indexed, slot));
order

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really stupid question, but you copy every element first and when removed these elements afterwards.

Is it not better to create a new vec with the old length but empty and when copy when loop by hand and add all correct elements into the new vec.

because for me, you loop first to copy all elements and when loop again to remove elements. So why my tactic you only should loop once, or do I see something wrong here?

Also about how many elements are we talking here? which get's removed or added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhmm so i can change to your tatic but i shouldnt gain the performance much (<1% ig), abt the amount of element, it roughly the max-players value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but this is a simple thing to do and I like to improve things like this, because they improve and don't cost much rewrite work

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants