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

hostcheck@schorschii causes stutter #1025

Closed
H34dl3ss opened this issue Dec 29, 2023 · 11 comments · Fixed by #1026
Closed

hostcheck@schorschii causes stutter #1025

H34dl3ss opened this issue Dec 29, 2023 · 11 comments · Fixed by #1026
Labels

Comments

@H34dl3ss
Copy link

Desklet version/Build date

Version 1.3 (2023-12-06 05:00:14)

Cinnamon version

Cinnamon 5.8.4

Distribution

Linux Mint 21.2 Victoria

Graphics hardware and driver used

NVIDIA GA104 [GeForce RTX 3070] driver: nvidia v: 535.129.03

Desklet name and maintainer

hostcheck@schorschii @schorschii

What happened?

Hi,
this seems similar to the stutter issue of the diskspace applet.
#932 (comment)

At the moment I have 5 desklets checking different hosts @ 10s intervall and the stutter is really noticeable.
e.g. check glxgears to see how it is chopping.
Could you please have a look into it - thanks.
Guten Rutsch! ;-)

Other information

No response

@H34dl3ss H34dl3ss added the bug label Dec 29, 2023
@schorschii
Copy link
Contributor

schorschii commented Dec 30, 2023

Unfortunately, it's not that easy here. While Gio has functions to get information about the file system, it can't ping or do http(s) requests, so spawning a ping or curl subprocess seems to be necessary (this was the cause on the diskspace desklet).
Are you using ping or http(s) checks? Do the stutters appear on the other check type too?

@H34dl3ss
Copy link
Author

I switched some instances to http(s) checks but I can't really see a difference in stutter.

Is there a way/hack to disable all desklets (of a certain type) at once?
At the moment I have to remove one by one and then also add one by one - not the easy way for troubleshooting.

@schorschii
Copy link
Contributor

schorschii commented Dec 31, 2023

I found a way to fix it for HTTP checks. There is a library called Soup which we can use for HTTP connections. Can you please check if HTTP checks are working without stutters with the Soup library by copying the version 1.4 from my hostcheck-http-soup branch into your ~/.local/share/cinnamon/desklets/hostcheck@schorschii? Don't forget to restart Cinnamon.

For the ping check, I don't see any solution.

You can remove all desklets of a certain type with this button in the desklet manager:
image

@H34dl3ss
Copy link
Author

Yes, the new version is not causing stutter if http is employed. But this is only working if the target is answering on http requests. I will keep an eye on that. At the moment the clients are offline.
Ping is still a problem.

When removing all instances in the desklet manager, I have to set up everything from scratch. Maybe this can be improved so that the new instances pick up the old settings. Sensors@claudiux somehow does.

@claudiux
While testing I noticed that his plugin is also causing stutter!
It seems this is a problem by design, since any subprocess spawn is affecting cinnamon performance...
Can you explain, why Gio and Soup don't do so?

@claudiux
Copy link
Member

claudiux commented Dec 31, 2023

@H34dl3ss In the settings of Sensors@claudiux, in the General tab, check the "Avoid size changes" option.
EDIT: Also, you can set the "Refresh interval (seconds)" to 5.

@schorschii
Copy link
Contributor

schorschii commented Dec 31, 2023

@H34dl3ss The stuttering is a specific issue of starting a subprocess (via Gio.Subprocess()). So the question is why starting a subprocess does this and not why Gio's function query_filesystem_info_async (new solution in the diskspace desklet) and Soup don't.

It's not possible to avoid subprocesses everywhere.

@H34dl3ss
Copy link
Author

H34dl3ss commented Jan 1, 2024

The stuttering is a specific issue of starting a subprocess (via Gio.Subprocess()). So the question is why starting a subprocess does this...

It's not possible to avoid subprocesses everywhere.

Then it should be escalated to the Gio project shouldn't it?
If there is no workaround possible, like it is with the "ping" solution, this issue might be a showstopper.

Thanks for the fixes in the hostcheck desklet.
Using the http query reduced the stutter significantly!

@schorschii
Copy link
Contributor

Yes, it should be reported to the correct project. But I'm not quite sure which component really causes this. Starting a subprocess via GLib.spawn_async_with_pipes() also causes stuttering. I checked some GNOME extensions how they do it and found a Ping Indicator and Gnome shell ping monitor extension using this method. On Cinnamon, this also causes stutter. Next step is to install a GNOME desktop with the mentioned extensions and check if it also stutters there. If not, the problem may be with Cinnamon.

@schorschii
Copy link
Contributor

schorschii commented Jan 12, 2024

I just tested the mentioned GNOME ping extensions. They only allow one single instance / ping check unlike the Cinnamon desklets, that's why there wasn't really anything noticeable first. But after modifying one extension to do multiple requests (= spawn multiple subprocesses) at the same time, stuttering was visible just like in Cinnamon. Using NVIDIA proprietary/open driver or Intel onboard GPU does not seem to make a difference.

Edit: I found out that Gio.Subprocess() internally also uses Glib.spawn_async_with_pipes_and_fds(). I created an issue in the Gjs repo although I'm not sure if it's the causative component.

Edit2: New issue in the Glib repo. Seems like there won't be a fix for that.

@schorschii
Copy link
Contributor

schorschii commented Jan 18, 2024

There was an interesting outcome in the issue on the Glib repo yesterday. @pwithnall mentioned:

In particular, fork() has to copy all of the process's address space, which for gjs applications is relatively large.

For general info, that’s why the posix_spawn() codepath was added to GLib. It should make spawning from a process with a large address space faster. It’s used automatically if several conditions are met in the g_spawn*() call (see the documentation for g_spawn_async_with_pipes_and_fds()):

  1. G_SPAWN_DO_NOT_REAP_CHILD is set
  2. G_SPAWN_LEAVE_DESCRIPTORS_OPEN is set
  3. G_SPAWN_SEARCH_PATH_FROM_ENVP is not set
  4. working_directory is NULL
  5. child_setup is NULL
  6. The program being spawned is of a recognised binary format, or has a shebang. Otherwise, GLib will have to execute the program through the shell, which is not done using the optimized codepath.

So I modified my spawn_async_with_pipes() call accordingly and noticed that this significantly reduced stuttering on my desktop.

@H34dl3ss can you please test my hostcheck-subprocess-improvement branch? Does this improve the ping check on your computer too?

If yes, this should probably be documented in the developer manual for Cinnamon.

@H34dl3ss
Copy link
Author

Yes, I have tested your improved desklet version and there is no stutter.
I run 5 desklet instances and even at 1s polling rate there is no stutter.

This is definitely a major improvement and should be respected in all desklets and applets code.
Thanks for escalating this to the glib project. Well worth it obviously!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants