diff --git a/src/common/config/config.cpp b/src/common/config/config.cpp index ecd80b9d14..876b641fef 100644 --- a/src/common/config/config.cpp +++ b/src/common/config/config.cpp @@ -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; +} diff --git a/src/common/config/config.h b/src/common/config/config.h index 6b647d3ca0..a61eb8c5d7 100644 --- a/src/common/config/config.h +++ b/src/common/config/config.h @@ -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 diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index d19d2c33b9..d7d459ac7b 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -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; } diff --git a/src/jrd/os/win32/thd_priority.cpp b/src/jrd/os/win32/thd_priority.cpp index 83dc770532..5b9200b0a9 100644 --- a/src/jrd/os/win32/thd_priority.cpp +++ b/src/jrd/os/win32/thd_priority.cpp @@ -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