Skip to content

Pre-size hot path FastUtil collections in TrackerCtx and EntityCollisionCache - #892

Open
Smorki wants to merge 1 commit into
Winds-Studio:ver/26.2from
Smorki:perf/presize-hot-path-collections
Open

Pre-size hot path FastUtil collections in TrackerCtx and EntityCollisionCache#892
Smorki wants to merge 1 commit into
Winds-Studio:ver/26.2from
Smorki:perf/presize-hot-path-collections

Conversation

@Smorki

@Smorki Smorki commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

This PR provides sensible initial capacities for several ObjectArrayList instances in TrackerCtx and EntityCollisionCache.

Since these collections are frequently populated during async tracking and entity collision phases, pre-sizing them helps avoid repeated array growth and reduces allocation churn in these hot paths.

@Dreeam-qwq

Copy link
Copy Markdown
Member

Do you have any spark profiler that can show that we need to pre-size these lists?

@Smorki

Smorki commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Not right now ,but since these are hit frequently on hot paths, default resizes cause unnecessary allocation churn. ill run a quick load test with Spark in a few hours and share the profile here!

@Smorki

Smorki commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Here is the Spark profile from a local test with high entity density and constant movement:
https://spark.lucko.me/5bLBhRr0KG

It confirms that TrackerCtx and EntityCollisionCache are active hot paths. Pre-sizing these ObjectArrayList instances helps avoid allocation churn from repeated internal array growth.

@hayanesuru

hayanesuru commented Aug 25, 2026 via email

Copy link
Copy Markdown
Collaborator

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants