add idxniceprio parameter to choose indexing process priority

This commit is contained in:
Jean-Francois Dockes 2020-01-31 09:29:02 +01:00
parent da05b762a7
commit aa40531bbe
3 changed files with 278 additions and 252 deletions

View File

@ -233,6 +233,7 @@ void rclIxIonice(const RclConfig *config)
string clss, classdata; string clss, classdata;
if (!config->getConfParam("monioniceclass", clss) || clss.empty()) if (!config->getConfParam("monioniceclass", clss) || clss.empty())
clss = "3"; clss = "3";
// Classdata may be empty (must be for idle class)
config->getConfParam("monioniceclassdata", classdata); config->getConfParam("monioniceclassdata", classdata);
rclionice(clss, classdata); rclionice(clss, classdata);
#endif #endif
@ -241,7 +242,13 @@ void rclIxIonice(const RclConfig *config)
static void setMyPriority(const RclConfig *config) static void setMyPriority(const RclConfig *config)
{ {
#ifndef _WIN32 #ifndef _WIN32
if (setpriority(PRIO_PROCESS, 0, 20) != 0) { int prio{19};
std::string sprio;
config->getConfParam("idxniceprio", sprio);
if (!sprio.empty()) {
prio = atoi(sprio.c_str());
}
if (setpriority(PRIO_PROCESS, 0, prio) != 0) {
LOGINFO("recollindex: can't setpriority(), errno " << errno << "\n"); LOGINFO("recollindex: can't setpriority(), errno " << errno << "\n");
} }
// Try to ionice. This does not work on all platforms // Try to ionice. This does not work on all platforms

View File

@ -817,18 +817,38 @@ checkneedretryindexscript = rclcheckneedretry.sh
# Example: mondelaypatterns = *.log:20 "*with spaces.*:30"</descr></var> # Example: mondelaypatterns = *.log:20 "*with spaces.*:30"</descr></var>
#mondelaypatterns = *.log:20 "*with spaces.*:30" #mondelaypatterns = *.log:20 "*with spaces.*:30"
# <var name="idxniceprio" type="int">
#
# <brief>"nice" process priority for the indexing processes. Default: 19
# (lowest)</brief>
#
# <descr>Appeared with 1.26.5. Prior versions were fixed at 19.</descr>
#
# </var>
#idxniceprio = 19
# <var name="monioniceclass" type="int"> # <var name="monioniceclass" type="int">
# #
# <brief>ionice class for the real time indexing process</brief> # <brief>ionice class for the indexing process.</brief>
# <descr>On platforms where this is supported. The default value is #
# 3.</descr></var> # <descr>Despite the misleading name, and on platforms where this is
# supported, this affects all indexing processes,
# not only the real time/monitoring ones. The default value is 3 (use
# lowest "Idle" priority).</descr>
#
# </var>
#monioniceclass = 3 #monioniceclass = 3
# <var name="monioniceclassdata" type="string"> # <var name="monioniceclassdata" type="string">
# #
# <brief>ionice class parameter for the real time indexing process.</brief> # <brief>ionice class level parameter if the class supports it.</brief>
# <descr>On platforms where this is supported. The default is #
# empty.</descr></var> # <descr>The default is empty, as the default "Idle" class has no
# levels.</descr>
#
# </var>
#
#monioniceclassdata = #monioniceclassdata =

View File

@ -51,9 +51,8 @@ bool rclionice(const string& clss, const string& cdata)
int status = cmd.doexec(ionicexe, args); int status = cmd.doexec(ionicexe, args);
if (status) { if (status) {
LOGERR("rclionice: failed, status 0x" << (status) << "\n" ); LOGERR("rclionice: failed, status 0x" << status << "\n");
return false; return false;
} }
return true; return true;
} }