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

@ -104,7 +104,7 @@ static void cleanup()
// Also check for an interrupt request and return the info to caller which // Also check for an interrupt request and return the info to caller which
// should subsequently orderly terminate what it is doing. // should subsequently orderly terminate what it is doing.
class MyUpdater : public DbIxStatusUpdater { class MyUpdater : public DbIxStatusUpdater {
public: public:
MyUpdater(const RclConfig *config) MyUpdater(const RclConfig *config)
: m_file(config->getIdxStatusFile().c_str()), : m_file(config->getIdxStatusFile().c_str()),
m_stopfilename(config->getIdxStopFile()), m_stopfilename(config->getIdxStopFile()),
@ -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
@ -418,54 +425,54 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
string thisprog; string thisprog;
static const char usage [] = static const char usage [] =
"\n" "\n"
"recollindex [-h] \n" "recollindex [-h] \n"
" Print help\n" " Print help\n"
"recollindex [-z|-Z] [-k]\n" "recollindex [-z|-Z] [-k]\n"
" Index everything according to configuration file\n" " Index everything according to configuration file\n"
" -z : reset database before starting indexing\n" " -z : reset database before starting indexing\n"
" -Z : in place reset: consider all documents as changed. Can also\n" " -Z : in place reset: consider all documents as changed. Can also\n"
" be combined with -i or -r but not -m\n" " be combined with -i or -r but not -m\n"
" -k : retry files on which we previously failed\n" " -k : retry files on which we previously failed\n"
#ifdef RCL_MONITOR #ifdef RCL_MONITOR
"recollindex -m [-w <secs>] -x [-D] [-C]\n" "recollindex -m [-w <secs>] -x [-D] [-C]\n"
" Perform real time indexing. Don't become a daemon if -D is set.\n" " Perform real time indexing. Don't become a daemon if -D is set.\n"
" -w sets number of seconds to wait before starting.\n" " -w sets number of seconds to wait before starting.\n"
" -C disables monitoring config for changes/reexecuting.\n" " -C disables monitoring config for changes/reexecuting.\n"
" -n disables initial incremental indexing (!and purge!).\n" " -n disables initial incremental indexing (!and purge!).\n"
#ifndef DISABLE_X11MON #ifndef DISABLE_X11MON
" -x disables exit on end of x11 session\n" " -x disables exit on end of x11 session\n"
#endif /* DISABLE_X11MON */ #endif /* DISABLE_X11MON */
#endif /* RCL_MONITOR */ #endif /* RCL_MONITOR */
"recollindex -e [<filepath [path ...]>]\n" "recollindex -e [<filepath [path ...]>]\n"
" Purge data for individual files. No stem database updates.\n" " Purge data for individual files. No stem database updates.\n"
" Reads paths on stdin if none is given as argument.\n" " Reads paths on stdin if none is given as argument.\n"
"recollindex -i [-f] [-Z] [<filepath [path ...]>]\n" "recollindex -i [-f] [-Z] [<filepath [path ...]>]\n"
" Index individual files. No database purge or stem database updates\n" " Index individual files. No database purge or stem database updates\n"
" Will read paths on stdin if none is given as argument\n" " Will read paths on stdin if none is given as argument\n"
" -f : ignore skippedPaths and skippedNames while doing this\n" " -f : ignore skippedPaths and skippedNames while doing this\n"
"recollindex -r [-K] [-f] [-Z] [-p pattern] <top> \n" "recollindex -r [-K] [-f] [-Z] [-p pattern] <top> \n"
" Recursive partial reindex. \n" " Recursive partial reindex. \n"
" -p : filter file names, multiple instances are allowed, e.g.: \n" " -p : filter file names, multiple instances are allowed, e.g.: \n"
" -p *.odt -p *.pdf\n" " -p *.odt -p *.pdf\n"
" -K : skip previously failed files (they are retried by default)\n" " -K : skip previously failed files (they are retried by default)\n"
"recollindex -l\n" "recollindex -l\n"
" List available stemming languages\n" " List available stemming languages\n"
"recollindex -s <lang>\n" "recollindex -s <lang>\n"
" Build stem database for additional language <lang>\n" " Build stem database for additional language <lang>\n"
"recollindex -E\n" "recollindex -E\n"
" Check configuration file for topdirs and other paths existence\n" " Check configuration file for topdirs and other paths existence\n"
#ifdef FUTURE_IMPROVEMENT #ifdef FUTURE_IMPROVEMENT
"recollindex -W\n" "recollindex -W\n"
" Process the Web queue\n" " Process the Web queue\n"
#endif #endif
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
"recollindex -S\n" "recollindex -S\n"
" Build aspell spelling dictionary.>\n" " Build aspell spelling dictionary.>\n"
#endif #endif
"Common options:\n" "Common options:\n"
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n" " -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
; ;
static void static void
Usage(FILE *where = stderr) Usage(FILE *where = stderr)

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
# monioniceclass = 3 # 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
# <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

@ -30,7 +30,7 @@ bool rclionice(const string& clss, const string& cdata)
string ionicexe; string ionicexe;
if (!ExecCmd::which("ionice", ionicexe)) { if (!ExecCmd::which("ionice", ionicexe)) {
// ionice not found, bail out // ionice not found, bail out
LOGDEB0("rclionice: ionice not found\n" ); LOGDEB0("rclionice: ionice not found\n");
return false; return false;
} }
vector<string> args; vector<string> args;
@ -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;
} }