mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Added config file parameters, controlling threads' priorities scheduler
This commit is contained in:
parent
2a38c9c240
commit
4047237a50
@ -83,7 +83,10 @@ const ConfigImpl::ConfigEntry ConfigImpl::entries[] =
|
||||
{TYPE_INTEGER, "EventMemSize", (ConfigValue) 65536}, // bytes
|
||||
{TYPE_INTEGER, "DeadlockTimeout", (ConfigValue) 10}, // seconds
|
||||
{TYPE_INTEGER, "SolarisStallValue", (ConfigValue) 60}, // seconds
|
||||
{TYPE_BOOLEAN, "TraceMemoryPools", (ConfigValue) false} // for internal use only
|
||||
{TYPE_BOOLEAN, "TraceMemoryPools", (ConfigValue) false}, // for internal use only
|
||||
{TYPE_INTEGER, "PrioritySwitchDelay", (ConfigValue) 100}, // milliseconds
|
||||
{TYPE_INTEGER, "DeadThreadsCollection", (ConfigValue) 50}, // number of PrioritySwitchDelay cycles before dead threads collection
|
||||
{TYPE_INTEGER, "PriorityBoost", (ConfigValue) 5}, // ratio oh high- to low-priority thread ticks in jrd.cpp
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
@ -314,3 +317,29 @@ bool Config::getTraceMemoryPools()
|
||||
{
|
||||
return (bool) sysConfig.values[KEY_TRACE_MEMORY_POOLS];
|
||||
}
|
||||
|
||||
int Config::getPrioritySwitchDelay()
|
||||
{
|
||||
int rc = (int) sysConfig.values[KEY_PRIORITY_SWITCH_DELAY];
|
||||
if (rc < 1)
|
||||
rc = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int Config::getDeadThreadsCollection()
|
||||
{
|
||||
int rc = (int) sysConfig.values[KEY_DEAD_THREADS_COLLECTION];
|
||||
if (rc < 1)
|
||||
rc = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int Config::getPriorityBoost()
|
||||
{
|
||||
int rc = (int) sysConfig.values[KEY_PRIORITY_BOOST];
|
||||
if (rc < 1)
|
||||
rc = 1;
|
||||
if (rc > 1000)
|
||||
rc = 1000;
|
||||
return rc;
|
||||
}
|
||||
|
@ -86,7 +86,10 @@ class Config
|
||||
KEY_EVENT_MEM_SIZE, // 19
|
||||
KEY_DEADLOCK_TIMEOUT, // 20
|
||||
KEY_SOLARIS_STALL_VALUE, // 21
|
||||
KEY_TRACE_MEMORY_POOLS // 22
|
||||
KEY_TRACE_MEMORY_POOLS, // 22
|
||||
KEY_PRIORITY_SWITCH_DELAY, // 23
|
||||
KEY_DEAD_THREADS_COLLECTION, // 24
|
||||
KEY_PRIORITY_BOOST // 25
|
||||
};
|
||||
|
||||
public:
|
||||
@ -205,6 +208,21 @@ public:
|
||||
Trace memory pools
|
||||
*/
|
||||
static bool getTraceMemoryPools();
|
||||
|
||||
/*
|
||||
Priority switch delay
|
||||
*/
|
||||
static int getPrioritySwitchDelay();
|
||||
|
||||
/*
|
||||
Dead threads collection
|
||||
*/
|
||||
static int getDeadThreadsCollection();
|
||||
|
||||
/*
|
||||
Priority boost
|
||||
*/
|
||||
static int getPriorityBoost();
|
||||
};
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
@ -769,7 +769,8 @@ STATUS DLL_EXPORT GDS_ATTACH_DATABASE(STATUS* user_status,
|
||||
dbb->dbb_attachments = attachment;
|
||||
dbb->dbb_flags &= ~DBB_being_opened;
|
||||
dbb->dbb_sys_trans->tra_attachment = attachment;
|
||||
tdbb->tdbb_quantum = (THPS_BOOSTDONE() ? 5 : 1) * QUANTUM;
|
||||
tdbb->tdbb_quantum = (THPS_BOOSTDONE() ?
|
||||
Config::getPriorityBoost() : 1) * QUANTUM;
|
||||
tdbb->tdbb_request = NULL;
|
||||
tdbb->tdbb_transaction = NULL;
|
||||
tdbb->tdbb_inhibit = 0;
|
||||
@ -4446,7 +4447,9 @@ BOOLEAN JRD_reschedule(TDBB tdbb, SLONG quantum, BOOLEAN punt)
|
||||
}
|
||||
|
||||
tdbb->tdbb_quantum = (tdbb->tdbb_quantum <= 0) ?
|
||||
((quantum) ? quantum : (THPS_BOOSTDONE() ? 5 : 1) * QUANTUM) : tdbb->tdbb_quantum;
|
||||
(quantum ? quantum : (THPS_BOOSTDONE() ?
|
||||
Config::getPriorityBoost() : 1) * QUANTUM) :
|
||||
tdbb->tdbb_quantum;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -23,12 +23,13 @@
|
||||
|
||||
#include "firebird.h"
|
||||
#include "../jrd/os/thd_priority.h"
|
||||
#include "../common/config/config.h"
|
||||
|
||||
#ifdef THREAD_PSCHED
|
||||
|
||||
// configurable parameters
|
||||
#define THPS_TIME 100 // ms between rescheds
|
||||
#define THPS_TICKS 50 // sched loops before thread killing
|
||||
#define THPS_TIME (Config::getPrioritySwitchDelay()) // ms between rescheds
|
||||
#define THPS_TICKS (Config::getDeadThreadsCollection()) // sched loops before thread killing
|
||||
|
||||
#include "../jrd/ib_stdio.h"
|
||||
#include <errno.h>
|
||||
|
Loading…
Reference in New Issue
Block a user