mirror of https://gitee.com/bigwinds/arangodb
remove superfluous threads after a grace period
This commit is contained in:
parent
25601bb7d9
commit
9c9bd02454
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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--;
|
||||
|
|
Loading…
Reference in New Issue