-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve AvoidStandyModeService #4060
Conversation
This change substitutes use of memory efficient, OS supplied sleep/suspend inhibitor utilties for the silent audio file player on Linux, merges OSXStandbyModeDisabler functionality into AvoidStandyModeService, and removes that class. This change also stops Bisq from running the audio file on OSX; it is currently running both caffeinate and the silent audio file, and the avoid standby mode button in the the OSX settings view is currently toggling the audio player on and off, but not caffeinate. (The only way to shut down caffeinate is by shutting down Bisq.) The OSX avoid standby mode button button has not been hidden so a cached 'do not avoid standby mode' preference does not leave the user stuck without a caffeinate service the next time they start Bisq. (They can use it to turn caffeinate on, but it can't be used to turn it off without shutting down Bisq too.) The avoid standy mode button is now displayed on Linux because the native inhibitor can be toggled on and off. There is no change to the avoid shutdown service on Windows and Unix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here on a freshly upgraded Arch linux with gnome shell desktop.
I can confirm that the inhibitor works, although it seems that at least arch linux relies on the systemd mechanics as a primary tool for inhibiting shutdown/hibernate/sleep/...
I further can confirm that disk I/O has dropped by about 50%, at least the read part. Previously, I have seen that the sound file got read very often, it is gone now.
This is a green from me! Thanks for your efforts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK - Tested it on macOS 10.15.3 and it worked as well.
@ManfredKarrer Do you remember why you used the audio workaround and not caffeinate on macOS? Or was it just the best cross-platform solution to do it like that? |
Checked back with Manfred and he doesn't have specific concerns about this change as he didn't use caffeinate in his original solution. |
Trying to reopen this PR to force a new Travis CI build and see if it fixes JDK12 build failure: The JDK 10 build passed, and it also passed on my own JDK11. |
I just reviewed this change now, and was initially wondering why we didn't delete the
Just wondering: was any investigation done as to how to inhibit sleep on Windows? |
@cbeams, I did not investigate how to suspend sleep on Win because don't have a windows OS. |
This change substitutes use of memory efficient, OS supplied sleep/suspend
inhibitor utilities for the silent audio file player on Linux, merges
OSXStandbyModeDisabler functionality into AvoidStandyModeService, and
removes that class.
This change also stops Bisq from running the audio file on OSX; it is
currently running both caffeinate and the silent audio file, and the avoid
standby mode button in the the OSX settings view is currently toggling
the audio player on and off, but not caffeinate. (The only way to shut
down caffeinate is by shutting down Bisq.)
The OSX avoid standby mode button button has not been hidden so a cached
'do not avoid standby mode' preference does not leave the user stuck without
a caffeinate service the next time they start Bisq. (They can use it to
turn caffeinate on, but it can't be used to turn it off without shutting
down Bisq too.)
The avoid standy mode button is now displayed on Linux because the native
inhibitor can be toggled on and off.
There is no change to the avoid shutdown service on Windows and Unix.
OSX and UI related changes are described in the commit message above. An
explanation of Linux OS related changes follows.
On linux hosts, AvoidStandbyService checks for executables
gnome-session-inhibit and systemd-inhibit in that order, then starts
the first found to prevent suspend or sleep while Bisq is running.
To check if an inhibitor is enabled or disabled in a gnome terminal...
If Bisq falls back to systemd-inhibit on a non gnome desktop...
If neither gnome-session-inhibit nor systemd-inhibit are found, the
standby service falls back to playing the silent audio file.
This does not cover all linux desktop types, but other inhibitors
exist for desktops I have not set up, such as mate. It should not
be difficult to support them.
Off heap memory use reduction varies from machine to (virtual) machine.
On my Ubuntu 18 laptop, playing the audio file to block sleep/suspend
is allocating about 1 GB of native memory per hour via malloc() calls.
On the same machine after warm-up, Bisq's virtual memory usage goes from
10.4 GB to 10.1 GB. (This figure was tracked before the MaxRAM=4g setting
was merged from PR #4048.)
This has been tested on OSX Catalina 10.15, Ubuntu 18 (gnome) and the following VMs
However, VMs not running an inhibitor or audio file do not always go into suspend mode
as schedules.
This does not work on Windows Cygwin, but minor changes might make it work if
cygwin inhibitor tools like gnome-session-inhibit.exe and mate-session-inhibit.exe
are installed.
Paritally addresses off-heap memory consumption issues #3128, #3657,
#3918, #3917, #3686, #3677
This PR replaces #4049