High frequent file search refreshing game state every second
Opened this issue · 4 comments
My drives show read access on plenty of uplay_install.state files all the time forever with GOG Galaxy started.
Status for all games is updated in an endless loop with a sleep time of 1 seconds between executions.
In each execution the game installation and running state is updated. While the running state is retrieved with rather cheap mechanisms, the game installation status update requires disk access for each game.
I think it would be better to update the game installation status less frequently, at most one time every minute.
Maybe the GameStatus.Installed could be cached in each game object and only be updated if a boolean flag is passed to this method:
galaxy-integration-uplay/src/local_game_status.py
Lines 157 to 169 in 41cd311
Not sure about the implementation but this update mechanism interval does not seem reasonable to me. I can prepare a PR if you agree to my finding.
I agree that this is not optimal. PR welcomed.
But instead of managing timeout I suggest to stat this file often (like every second or a few seconds), but read it only if it has changed.
Like here:
https://github.com/FriendsOfGalaxy/galaxy-integration-epic/blob/master/src/local.py#L40
or in batch like here:
https://github.com/FriendsOfGalaxy/galaxy-integration-origin/blob/master/src/local_games.py#L281
This way we make it lightweight for drive and still keep a nice feature that is quick detection just after you installed a uplay game (that is desirable in case you install it though Galaxy).
@jneumaier are you still interested in making PR? What do you think about my suggestion?
@FriendsOfGalaxy I like your idea. Currently I have no time for a PR, will try to find some in the future.
The stat comparison might be done here:
galaxy-integration-uplay/src/local_helper.py
Lines 74 to 87 in 41cd311
Yes, we have to decide where to store previous stats. This function is used here: https://github.com/FriendsOfGalaxy/galaxy-integration-uplay/search?q=get_game_installed_status
- in process watcher (why?)
- in local games parser
Looks like un-spaghetting candidate..
One way to do it cleanly would be to create "file watcher" class that do only this:
galaxy-integration-uplay/src/local_client.py
Lines 112 to 129 in 41cd311
Other way (more functional) - gether all files stats in one step and then pipe them to another function like get_game_installed_status
.
To double check - I just wrote this without much investigation.