Drop IO priority to idle while reading blocks for getblock requests #9245

Open
wants to merge 2 commits into
from

Projects

None yet

6 participants

@luke-jr
Member
luke-jr commented Nov 30, 2016

No description provided.

src/util.h
@@ -131,6 +131,49 @@ void OpenDebugLog();
void ShrinkDebugFile();
void runCommand(const std::string& strCommand);
+#ifdef HAVE_IOPRIO_SYSCALL
@laanwj
laanwj Nov 30, 2016 Member

Please move this to a new include file util_ioprio.h.

@laanwj
Member
laanwj commented Nov 30, 2016 edited

Concept ACK. Though not very happy to introduce platform-specific voodoo - we only just got rid of thread priority manipulation. But it may be worth the hassle, I don't know.

Can we quantify whether this works or not somehow?

@gmaxwell
Member

This will also delay other processing, in particular block relay-- at least until the handling is made more concurrent-- no? Not a reason to not do it, but maybe a reason to not do it by default for everyone.

I second the need to quantify this-- I could imagine it making for a big usability improvement. ... or not mattering at all. If the former, I want it... if the latter...

@luke-jr
Member
luke-jr commented Nov 30, 2016

Whenever I restart my node lately, I find myself eventually manually ioniceing the entire process as it slows down other things monitoring it in iotop. I can't be sure it's sending out old blocks, but I can't imagine what else it'd be spending so much time reading... :/

Added Mac and Windows support for completeness.

@ryanofsky
ryanofsky approved these changes Nov 30, 2016 edited View changes

ACK 6430b92 (after adding missing #includes)

+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_UTIL_IOPRIO_H
@ryanofsky
ryanofsky Nov 30, 2016 Contributor

Should add #include "config/bitcoin-config.h"

src/utilioprio.h
+#define IOPRIO_IDLER(actually_idle) ioprio_idler ioprio_idler_(actually_idle)
+
+#else
+#define ioprio_get() (-1)
@ryanofsky
ryanofsky Nov 30, 2016 Contributor

It doesn't seem like it should be necessary to declare these if the ioprio_idler class isn't around to call them.

@luke-jr
luke-jr Nov 30, 2016 Member

We can simplify some of the other stuff (move the logic into the class itself) if low-level access is undesired, but for now it's too early to know if these won't be needed IMO.

src/utilioprio.h
+#ifdef WIN32
+bool ioprio_set_file_idle(FILE *);
+#else
+#define ioprio_set_file_idle(f) (false)
@ryanofsky
ryanofsky Nov 30, 2016 Contributor

Maybe change this to ((void)false) to prevent a compiler warning:

main.cpp:1673:12: warning: statement has no effect [-Wunused-value]
     ioprio_set_file_idle(filein.Get());
src/utilioprio.cpp
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifdef HAVE_IOPRIO_SYSCALL
@ryanofsky
ryanofsky Nov 30, 2016 Contributor

Needs #include "config/bitcoin-config.h" to prevent link errors.

@fanquake
Contributor
fanquake commented Dec 1, 2016

Travis failure:

'../../src/'`utilioprio.cpp
In file included from ../../src/utilioprio.cpp:9:0:
../../src/utilioprio.h: In destructor ‘ioprio_idler::~ioprio_idler()’:
../../src/utilioprio.h:42:51: error: ‘LogPrintf’ was not declared in this scope
             LogPrintf("failed to restore ioprio\n");
@luke-jr
Member
luke-jr commented Dec 1, 2016

Looks like to make the Windows part work, we need to bump _WIN32_WINNT to 0x0600 which means it will only run on Vista or newer. AFAIK this is okay(?), but I'm going to leave it for a separate PR...

@rebroad
Contributor
rebroad commented Dec 19, 2016

I like this (concept ACK) although I wonder what the impact is on the p2p network as a whole if everyone ran this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment