1
0
Fork 0

remove superfluous threads after a grace period

This commit is contained in:
Frank Celler 2014-11-10 21:42:32 +01:00
parent 25601bb7d9
commit 9c9bd02454
5 changed files with 31 additions and 4 deletions

View File

@ -35,14 +35,16 @@ endpoint = tcp://0.0.0.0:8529
disable-authentication = yes
# number of server threads
threads = 10
threads = 4
# the user and group are normally set in the start script
# uid = arangodb
# gid = arangodb
[scheduler]
threads = 3
# number of threads used for I/O
threads = 1
[javascript]
startup-directory = @PKGDATADIR@/js

View File

@ -5,11 +5,11 @@
[server]
disable-authentication = true
endpoint = tcp://localhost:8529
threads = 10
threads = 4
# reuse-address = false
[scheduler]
threads = 3
threads = 1
[javascript]
startup-directory = ./js

View File

@ -74,6 +74,8 @@ DispatcherQueue::DispatcherQueue (Scheduler* scheduler,
_nrSpecial(0),
_nrBlocked(0),
_nrThreads(nrThreads),
_lastChanged(0.0),
_gracePeriod(5.0),
_scheduler(scheduler),
_dispatcher(dispatcher),
createDispatcherThread(creator) {
@ -370,6 +372,7 @@ bool DispatcherQueue::startQueueThread () {
}
else {
_nrStarted++;
_lastChanged = TRI_microtime();
}
return ok;

View File

@ -316,6 +316,18 @@ namespace triagens {
size_t _nrThreads;
////////////////////////////////////////////////////////////////////////////////
/// @brief last time we created or deleted a queue thread
////////////////////////////////////////////////////////////////////////////////
double _lastChanged;
////////////////////////////////////////////////////////////////////////////////
/// @brief grace period before shuting down queue threads
////////////////////////////////////////////////////////////////////////////////
double _gracePeriod;
////////////////////////////////////////////////////////////////////////////////
/// @brief scheduler
////////////////////////////////////////////////////////////////////////////////

View File

@ -266,6 +266,16 @@ void DispatcherThread::run () {
tick(true);
_queue->_accessQueue.lock();
// there is a chance, that we created more threads than necessary
if (_queue->_nrThreads + _queue->_nrBlocked < _queue->_nrRunning + _queue->_nrStarted + _queue->_nrWaiting) {
double n = TRI_microtime();
if (_queue->_lastChanged + _queue->_gracePeriod < n) {
_queue->_lastChanged = n;
break;
}
}
// wait, if there are no jobs
if (_queue->_readyJobs.empty()) {
_queue->_nrRunning--;