Skip to content

Commit

Permalink
Lower the compiler background thread priority.
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-m-cyr committed Jan 22, 2019
1 parent 8048f96 commit 2db1d51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions libethash-cl/CLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,21 @@ void CLMiner::asyncCompile()
{
auto saveName = getThreadName();
setThreadName(name().c_str());

#if defined(__linux__)
// Non Posix hack to lower compile thread's priority. Under POSIX
// the nice value is a process attribute, under Linux it's a thread
// attribute
if (nice(5) == -1)
cllog << "Unable to lower compiler priority.";
#endif
#ifdef WIN32
if (!SetThreadPriority(m_compileThread->native_handle(), THREAD_PRIORITY_BELOW_NORMAL))
cllog << "Unable to lower compiler priority.";
#endif

compileKernel(m_nextProgpowPeriod, m_nextProgram, m_nextSearchKernel);

setThreadName(saveName.c_str());
}

Expand Down
15 changes: 14 additions & 1 deletion libethash-cuda/CUDAMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,23 @@ void CUDAMiner::enumDevices(std::map<string, DeviceDescriptor>& _DevicesCollecti

void CUDAMiner::asyncCompile()
{
cuCtxSetCurrent(m_context);
auto saveName = getThreadName();
setThreadName(name().c_str());

#if defined(__linux__)
// Non Posix hack to lower compile thread's priority. Under POSIX
// the nice value is a process attribute, under Linux it's a thread
// attribute
if (nice(5) == -1)
cudalog << "Unable to lower compiler priority.";
#endif
#ifdef WIN32
if (!SetThreadPriority(m_compileThread->native_handle(), THREAD_PRIORITY_BELOW_NORMAL))
cudalog << "Unable to lower compiler priority.";
#endif

cuCtxSetCurrent(m_context);

compileKernel(m_nextProgpowPeriod, m_epochContext.dagNumItems / 2, m_kernel[m_kernelCompIx]);

setThreadName(saveName.c_str());
Expand Down

0 comments on commit 2db1d51

Please sign in to comment.