Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only init managers when they are first accessed #410

Merged

Conversation

MSchmoecker
Copy link
Member

This initalizes managers in a static constructor instead of initialising all of them at the start. The first time a manager is accessed via a member like events or a singelton access from a mod, it will be initalized.

The advantage is that Jotunn will load much faster with a small mod count, as only the necessary managers are loaded and initalized. Also, if some part breaks after a Valheim update, only called managers are effected.
For a large modpack, there's practically no difference as most managers are used anyway. The startup time without additional mods drops from about 800ms to about 150ms, which finally makes Jotunn lighweight.

The only possible problem is that a manager might be initalized too late and certain patches won't apply. Although this is rather unlikely, as most is happening in the Awake or Start methods of mods anyway. After testing a small number of mods, no issues were found. Nevertheless, extended testing is needed.

@MSchmoecker MSchmoecker merged commit e28127b into Valheim-Modding:dev Sep 22, 2023
1 check passed
@MSchmoecker MSchmoecker deleted the feat/conditional-initalization branch August 2, 2024 07:05
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.

1 participant