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

wxGUI/preferences: allow the user set maximum memory to be used by modules #3307

Merged

Conversation

tmszi
Copy link
Member

@tmszi tmszi commented Dec 15, 2023

Closes #3267.

  1. Solution require Python psutil lib to be installed.
  2. The global memory size in MB used by modules is calculated using the formula total_memory - (1 / 6 * total_memory)
wxgui_preferences_add_max_module_memory_settings.mp4

@tmszi tmszi added enhancement New feature or request GUI wxGUI related labels Dec 15, 2023
@tmszi tmszi added this to the 8.4.0 milestone Dec 15, 2023
@tmszi tmszi self-assigned this Dec 15, 2023
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

Let's not use psutil, it's another external dependency. Since MEMORYMB is by default not set, I would leave it unset, probably need to use TextCtrl instead of SpinCtrl.

The same could be done for NPROCS variable.

What I am not sure is whether these variables are actually respected by the tools.

@tmszi
Copy link
Member Author

tmszi commented Dec 15, 2023

Let's not use psutil, it's another external dependency.

There is no other cross-platform way to find out the total RAM size of a user machine.

#3267 It would be convenient if the default minimum could be set globally more easily in the wxGUI preferences environment to match the capacity of a user's workstation rather than having to set it individually in every module.

Since MEMORYMB is by default not set, I would leave it unset, probably need to use TextCtrl instead of SpinCtrl.

Could you explain why to use the TextCtrl widget, please?

@tmszi
Copy link
Member Author

tmszi commented Dec 15, 2023

Since MEMORYMB is by default not set, I would leave it unset

Without setting gis env MEMORYMB is not possible simple dynamically change memory value (set default value which reflect user machine RAM size) for all modules.

case G_OPT_MEMORYMB:
Opt->key = "memory";
Opt->type = TYPE_INTEGER;
Opt->key_desc = "memory in MB";
Opt->required = NO;
Opt->multiple = NO;
Opt->answer = "300";
/* start dynamic answer */
/* check MEMORYMB in GISRC, set with g.gisenv */
memstr = G_store(G_getenv_nofatal("MEMORYMB"));
if (memstr && *memstr)
Opt->answer = memstr;
/* end dynamic answer */
Opt->label = _("Maximum memory to be used (in MB)");
Opt->description = _("Cache size for raster rows");
break;

@wenzeslaus
Copy link
Member

These MEMORYMB and NPROCS are gisenv variables, so it seems to me that a analysis is needed to determine how the GUI setting should interact with switching mapsets and turning GRASS GIS on and off. Notably, the settings is already managed by the MEMORYMB variable, so why to involve GUI setting file?

Maybe, this is supposed to be completely different from the GUI settings or at least separate from implementation perspective but perhaps as a tab in the setting dialog (just thinking out-loud here). Maybe, g.gisenv just needs a wrapper.

The default for in the individual tools when MEMORYDB is not set is already there - it is 300.

@petrasovaa
Copy link
Contributor

Let's not use psutil, it's another external dependency.

There is no other cross-platform way to find out the total RAM size of a user machine.

#3267 It would be convenient if the default minimum could be set globally more easily in the wxGUI preferences environment to match the capacity of a user's workstation rather than having to set it individually in every module.

This mixes two things together, setting the default globally and setting it to match the capacity. I am not in favor of the latter, e.g. I have rarely the full capacity (or 5/6 of it) available, and it's not worth adding a new dependency.

Since MEMORYMB is by default not set, I would leave it unset, probably need to use TextCtrl instead of SpinCtrl.

Could you explain why to use the TextCtrl widget, please?

Sorry, I was too brief, my suggestion was to use TextCtrl, which allows you (unlike SpinCtrl) to have no value set. So by default MEMORYMB is not set, so initially the TextCtrl would be empty. SpinCtrl is not useful for input of large numbers anyway I think. We could include integer validator in the TextCtrl I suppose.

@petrasovaa
Copy link
Contributor

These MEMORYMB and NPROCS are gisenv variables, so it seems to me that a analysis is needed to determine how the GUI setting should interact with switching mapsets and turning GRASS GIS on and off. Notably, the settings is already managed by the MEMORYMB variable, so why to involve GUI setting file?

We could remove this from the settings file and just keep it in the settings GUI, it would be dynamically read from the MEMORYMB variable when you open settings, but it won't be recorded in the json file.

When switching mapsets, the variable seem to persist, so this looks ok to me.

Maybe, this is supposed to be completely different from the GUI settings or at least separate from implementation perspective but perhaps as a tab in the setting dialog (just thinking out-loud here). Maybe, g.gisenv just needs a wrapper.

The default for in the individual tools when MEMORYDB is not set is already there - it is 300.

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@tmszi tmszi merged commit bdf631b into OSGeo:main Dec 30, 2023
18 checks passed
@tmszi tmszi deleted the wxgui_preferences_add_max_module_memory_settings branch December 30, 2023 04:11
HuidaeCho pushed a commit to HuidaeCho/grass that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GUI wxGUI related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global memory use setting in preferences
3 participants