[bisq-network/bisq] Improve AvoidStandyModeService (#4060)

Stan notifications at github.com
Fri Mar 13 18:28:32 UTC 2020


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.

<!-- 
- make yourself familiar with the CONTRIBUTING.md if you have not already (https://github.com/bisq-network/bisq/blob/master/CONTRIBUTING.md)
- make sure you follow our [coding style guidelines][https://github.com/bisq-network/style/issues)
- pick a descriptive title
- provide some meaningful PR description below
- create the PR
- in case you receive a "Change request" and/or a NACK, please react within 30 days. If not, we will close your PR and it can not be up for compensation.
- After addressing the change request, __please re-request a review!__ Otherwise we might miss your PR as we tend to only look at pull requests tagged with a "review required".
-->

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...

	$ dbus-send --session --print-reply --dest=org.gnome.SessionManager \
		/org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors

If Bisq falls back to systemd-inhibit on a non gnome desktop...

	$ systemd-inhibit --list
	$ systemd-inhibit --list | grep Bisq
	
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

	Debian 10.3 (gnome)
	Arch Linux 9.2.1 (gnome)
	Fedora 31.1.9 (cinnamon)

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


You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/4060

-- Commit Summary --

  * Improve AvoidStandyModeService

-- File Changes --

    M core/src/main/java/bisq/core/app/AvoidStandbyModeService.java (145)
    M core/src/main/java/bisq/core/app/BisqExecutable.java (1)
    D core/src/main/java/bisq/core/app/OSXStandbyModeDisabler.java (27)
    M desktop/src/main/java/bisq/desktop/app/BisqApp.java (2)
    M desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java (2)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/4060.patch
https://github.com/bisq-network/bisq/pull/4060.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4060
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200313/4e8c116e/attachment-0001.html>


More information about the bisq-github mailing list