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

Reducing RAM usage #91

Open
PerplexedPeach opened this issue Jul 3, 2023 · 3 comments
Open

Reducing RAM usage #91

PerplexedPeach opened this issue Jul 3, 2023 · 3 comments

Comments

@PerplexedPeach
Copy link

This extension is taking up around 4-5GB of RAM, making it hard to use together with the game open. I suspect it's because my workspace has too many CK3 projects in it, but I'm not sure if this contributes to it. Does having more CK3 files in a workspace (without opening) them increase RAM usage? My workspace includes:

  • base game's game directory
  • my mods
  • mods that I have compatibility patches for
  • mods that my mods depend on

Another possible culprit is that many of my event files are autogenerated via a python script, so I have like 20k line files that should be excluded from processing. Is there a way to mark files or directories as excluded from indexing?

@tboby
Copy link
Member

tboby commented Jul 3, 2023

Does having more CK3 files in a workspace (without opening) them increase RAM usage?

Yes: cwtools keeps a processed form of every script and localisation file in it's scope in memory.

It's basically unavoidable if you want to have anything responsive, and all programming languages have high memory usage if you want to open several projects at once sadly!

At a minimum this would be the "vanilla cache" which contains all the vanilla files, plus your mod. If you're including the base game in your workspace you might be causing it to load all of vanilla again. If your mod is a total conversion, you'd then effectively be keeping three copies of vanilla around :)

One recommendation I have would be to create multiple workspaces, where some contain only your core mods + dependencies. This is the approach taken in other languages when solutions get too large.

The huge files will cause some problems, although if they're over 2MB they're probably already being ignored by the default max file size setting cwtools.maxFileSize. There's also cwtools.ignore_patterns which you could use to ignore whole filepaths, which you should be able to use to ignore your reference inclusion of vanilla.

@PerplexedPeach
Copy link
Author

I see, thanks! Those are all actionable and I'll get back to you with how well some of them work.

@PerplexedPeach
Copy link
Author

PerplexedPeach commented Jul 3, 2023

Removing the base game and some other mods from the workspace reduced it down to around 3.5GB of RAM, so that worked as intended. The cwtools.ignore_patterns doesn't seem to be working. When I put a single string there (not even utilizing any glob patterns; it's just the path relative to the workspace of one of my event files), the extension just stops working - the cwtools loaded files tile in the bottom left is completely empty and it makes no attempt to load anything. Is there a way to debug the extension settings?

EDIT: disabled then re-enabled the extension and reopened vscode 3 times to get it to populate the loaded files tile again, but the specified path wasn't ignored. Are the filepaths not relative to workspace (are they absolute)?

EDIT: is there a way to ignore all rules / stop linting? That should probably reduce the RAM usage significantly. I know I can manually specify individual rules to ignore via cwtools.errors.ignore, but that's not ideal. Could I set rules_version to manual then specify a non-existent or empty path in rules_folder? The rules are almost entirely noise since 99% of it is false positives even on rules_version: latest. Maybe this is a separate issue, but I get errors for statements that work like:

chance_to_happen is unexpected in random_eventsCW262
triggered_outfit is unexpected in left_portraitCW263(CW263)
Missing event_background, expecting at least 1CW242(CW242)
reference is unexpected in override_backgroundCW262(CW262)
has_trait_xp is unexpected in limitCW263(CW263)
multiply is unexpected in valueCW262(CW262)
any_normal_councillor is unexpected in ORCW263(CW263)

EDIT: I would like being able to search in the vanilla files within the workspace. I think the best way to accomplish this is to add the vanilla folder to the workspace but ignore it using cwtools.ignore_patterns once I figure out how to use that.

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

No branches or pull requests

2 participants