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

Caching sorted script extensions and mod load order #311

Closed
KANAjetzt opened this issue Jun 30, 2023 · 1 comment
Closed

Caching sorted script extensions and mod load order #311

KANAjetzt opened this issue Jun 30, 2023 · 1 comment
Labels
enhancement New feature or request performance
Milestone

Comments

@KANAjetzt
Copy link
Member

KANAjetzt commented Jun 30, 2023

Currently, two of the heaviest parts of loading mods are being executed even when there are no changes to the installed mods. This results in unnecessary processing and delays in mod loading.

To improve performance, I suggest implementing a caching mechanism for the sorted script extensions and mod load order.

Load Order

# Sort mod_load_order by the importance score of the mod
ModLoaderStore.mod_load_order = _ModLoaderDependency.get_load_order(ModLoaderStore.mod_data.values())

Script Extensions

# Couple the extension paths with the parent paths and the extension's mod id
# in a ScriptExtensionData resource
static func handle_script_extensions() -> void:
var script_extension_data_array := []
for extension_path in ModLoaderStore.script_extensions:
if not File.new().file_exists(extension_path):
ModLoaderLog.error("The child script path '%s' does not exist" % [extension_path], LOG_NAME)
continue
var child_script = ResourceLoader.load(extension_path)
var mod_id: String = extension_path.trim_prefix(_ModLoaderPath.get_unpacked_mods_dir_path()).get_slice("/", 0)
var parent_script: Script = child_script.get_base_script()
var parent_script_path: String = parent_script.resource_path
script_extension_data_array.push_back(
ScriptExtensionData.new(extension_path, parent_script_path, mod_id)
)
# Sort the extensions based on dependencies
script_extension_data_array = _sort_extensions_from_load_order(script_extension_data_array)
# Inheritance is more important so this called last
script_extension_data_array.sort_custom(InheritanceSorting, "_check_inheritances")
# Load and install all extensions
for extension in script_extension_data_array:
var script: Script = apply_extension(extension.extension_path)
_reload_vanilla_child_classes_for(script)

@KANAjetzt KANAjetzt added enhancement New feature or request performance labels Jun 30, 2023
@KANAjetzt KANAjetzt added this to the v6.2.0 milestone Jun 30, 2023
@KANAjetzt KANAjetzt modified the milestones: v6.2.0, v6.1.0 Jul 1, 2023
@KANAjetzt
Copy link
Member Author

closed by #314

@KANAjetzt KANAjetzt modified the milestones: v6.1.0, v6.0.3 Jul 3, 2023
@KANAjetzt KANAjetzt mentioned this issue Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

No branches or pull requests

1 participant