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
macOS: disable AppNap during sync #12783
Conversation
src/support/macos_appnap.mm
Outdated
class CAppNapInhibitorInt | ||
{ | ||
public: | ||
id<NSObject> activityId; |
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.
Is there a difference in using NSObject *activityId
?
src/support/macos_appnap.mm
Outdated
~(NSActivitySuddenTerminationDisabled | | ||
NSActivityAutomaticTerminationDisabled); | ||
|
||
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:reason:)]) |
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.
nit: code styling, use brackets {}
src/support/macos_appnap.mm
Outdated
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(endActivity:)]) | ||
[[NSProcessInfo processInfo] endActivity:priv->activityId]; | ||
#endif | ||
delete priv; |
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.
Since we are only holding a NSObject
pointer, is this deallocation really required or could it even be messing with the autorelease pool?
utACK e41bb4a4568e08fe75ab8af7de7db1a2684cd989 |
Will review later. Good question regarding which macOS version to support. The release notes state 10.8+, but I wonder how true that is. Apple pushes macOS updates quite aggressively and the lack of VM's make downgrades impractical. So unless any of the active devs here still runs an older version, I don't think it's realistic to support anything but the current macOS release and maybe one earlier version . |
We do currently support 10.8+ and I have VMs for all OSX versions from 10.5 upwards. I do test the RC regularly in 10.8 till 10.x VMs. |
@jonasschnelli ok, that's great to know. Any hints for setting up a 10.8 VM on an iMac? |
Concept ACK. |
I really really don't like the idea of adding a new compiler requirement for bitcoind (which is why we closed #5804). How about using this for bitcoin-qt only ? |
I think it's reasonable* to expect bitcoind users to understand their OS power management.
|
how to i squash all my commits in PR they contain merging commits from upstream/master 😕 |
87ff82f
to
d143357
Compare
Squashed all my commits into single one. OS X Mountain Lion 10.8 not supported by Apple anymore. Mozilla/Google don't support 10.8 either in their web browsers. |
Would make sense to me. Would (for me) be preferable to having objective C in the core code.
Virtually no one uses bitcoind on MacOSX. For a long time, we didn't even build it, and there was about one person that requested it :) |
src/qt/macos_appnap.mm
Outdated
|
||
CAppNapInhibitor::CAppNapInhibitor(const char* strReason) : d(new Private) | ||
{ | ||
const NSActivityOptions activityOptions = |
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.
Since this isn't defined for < MAC_OS_X_VERSION_10_9, does it need a runtime check?
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.
No idea, i can't setup 10.8 build vm to test code properly, so pre 10.9 support removed.
Started doing some testing. Using c975861, neither process seems to go into App Nap: |
Concept ACK. What's the point of MacOSIdleInhibitor though? In #5804, CIdleInhibitor was introduced as a generic object that could used to be hold any/all platform-specific inhibitors. Here, MacOSIdleInhibitor seems to just be an extra level of indirection. |
Well windows and linux can't lower cpu performance per application, on windows user can only change system-wide power plans. This thing pretty much only macos specific, MacOSIdleInhibitor change reverted anyways. |
ec0c230
to
e953dbf
Compare
src/qt/bitcoin.cpp
Outdated
@@ -259,6 +263,21 @@ public Q_SLOTS: | |||
void startThread(); | |||
}; | |||
|
|||
#if defined(Q_OS_MACOS) | |||
// A RAII wrapper around calls to forbid and re-allow entering into | |||
// low-priority states, specifically OSX's app-nap. For the scope of |
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.
nit: macOS instead of OSX
src/qt/macos_appnap.h
Outdated
@@ -0,0 +1,19 @@ | |||
// Copyright (c) 2009-2010 Satoshi Nakamoto | |||
// Copyright (c) 2009-2018 The Bitcoin Core developers |
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.
You can just use:
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
as the copyright header here
CIdleInhibitor is still there, maybe an issue with the rebase? BitcoinCore::BitcoinCore can just create a CAppNapInhibitor. |
@krab could you now squash your commits. |
7e84a3e
to
e76acf3
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
tACK 2a14df1 on macOS 10.14 (in July I tested on 10.13) I previously wrote:
This works now. With the app in the background, it enters app nap after a minute or so. If however I rewind the chain a bit e.g. with It does enter app nap during expensive RPC operations ( I also wrote:
The current solution looks much cleaner. E.g. it got rid of the undocumented plist option, and instead uses the documented NSActivityOptions. Some relevant Apple docs:
For future reference, I suggest renaming the PR to "macOS: disable AppNap during sync" |
Related upstream ticket QTBUG-43861. If we're lucky, one day Qt might expose an API for this functionality, so we don't have to ship the Objective-C ourselves. |
Signed-off-by: Alexey Ivanov <alexey.ivanes@gmail.com>
2a14df1
to
1e0f3c4
Compare
utACK 1e0f3c4 (rebased) |
1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315
utACK 1e0f3c4 |
1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315
#3024) * Merge bitcoin#12783: macOS: disable AppNap during sync 1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315 * Refactor * Drop `#include <memory>` from `src/qt/bitcoingui.h` Was included by mistake.
dashpay#3024) * Merge bitcoin#12783: macOS: disable AppNap during sync 1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315 * Refactor * Drop `#include <memory>` from `src/qt/bitcoingui.h` Was included by mistake.
dashpay#3024) * Merge bitcoin#12783: macOS: disable AppNap during sync 1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315 * Refactor * Drop `#include <memory>` from `src/qt/bitcoingui.h` Was included by mistake.
* commit '7d8eab2641023c78a72ccd6efc99fc35fd030a46': (32 commits) Add 0.14.0.3 change log to release-notes.md (dashpay#3055) Update release-notes.md for 0.14.0.3 (dashpay#3054) Bump version to 0.14.0.3 and copy release notes (dashpay#3053) Re-verify invalid IS sigs when the active quorum set rotated (dashpay#3052) Remove recovered sigs from the LLMQ db when corresponding IS locks get confirmed (dashpay#3048) Add "instantsendlocks" to getmempoolinfo RPC (dashpay#3047) Use fEnablePrivateSend instead of fPrivateSendRunning Show number of InstantSend locks in Debug Console (dashpay#2919) Optimize on-disk deterministic masternode storage to reduce size of evodb (dashpay#3017) Add "isValidMember" and "memberIndex" to "quorum memberof" and allow to specify quorum scan count (dashpay#3009) Implement "quorum memberof" (dashpay#3004) Bail out properly on Evo DB consistency check failures in ConnectBlock/DisconnectBlock (dashpay#3044) Do not count 0-fee txes for fee estimation (dashpay#3037) Fix broken link in PrivateSend info dialog (dashpay#3031) Merge pull request dashpay#3028 from PastaPastaPasta/backport-12588 Add Dash Core Group codesign certificate (dashpay#3027) Fix osslsigncode compile issue in gitian-build (dashpay#3026) Backport bitcoin#12783: macOS: disable AppNap during sync (and mixing) (dashpay#3024) Remove support for InstantSend locked gobject collaterals (dashpay#3019) [v0.14.0.x] Update release notes for 0.14.0.2 (dashpay#3012) ... # Conflicts: # .gitignore # .travis.yml # configure.ac # doc/man/biblepay-cli.1 # doc/man/biblepay-qt.1 # doc/man/biblepay-tx.1 # doc/man/biblepayd.1 # doc/release-notes.md # src/clientversion.h # src/qt/utilitydialog.cpp
dashpay#3024) * Merge bitcoin#12783: macOS: disable AppNap during sync 1e0f3c4 macOS: disable AppNap during sync (Alexey Ivanov) Pull request description: Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+. What macOS versions bitcoin core currently supports? Tree-SHA512: 85809b8d8d8a05169437b4268988da0b7372c29c6da3223ebdc106dc16dcb6d3caa5c52ace3591467005b50a63fd8b2ab1cb071cb4f450032932df25d5063315 * Refactor * Drop `#include <memory>` from `src/qt/bitcoingui.h` Was included by mistake.
…itialBlockDownload() Introduced in bitcoin#12783 / 1e0f3c4
…itialBlockDownload() Introduced in bitcoin#12783 / 1e0f3c4
Summary: Backport of core [[bitcoin/bitcoin#12783 | PR12783]]. Test Plan: ninja all check On OSX: ninja all check check-functional Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Subscribers: PiRK Differential Revision: https://reviews.bitcoinabc.org/D8334
Code based on pull/5804. Tested only on macOS 10.13.3 and should support 10.9+.
What macOS versions bitcoin core currently supports?