mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-10 12:59:09 +00:00
Provide some guardrails for thread count.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
static int default_threadCount = 0;
|
||||
static int default_threadCount = std::min(4, (int32_t) std::thread::hardware_concurrency());
|
||||
static bool default_saveChats = false;
|
||||
static bool default_saveChatGPTChats = true;
|
||||
static bool default_serverChat = false;
|
||||
@@ -349,7 +349,10 @@ int MySettings::threadCount() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("threadCount", default_threadCount).toInt();
|
||||
int c = setting.value("threadCount", default_threadCount).toInt();
|
||||
c = std::max(c, 1);
|
||||
c = std::min(c, QThread::idealThreadCount());
|
||||
return c;
|
||||
}
|
||||
|
||||
void MySettings::setThreadCount(int c)
|
||||
@@ -357,6 +360,8 @@ void MySettings::setThreadCount(int c)
|
||||
if (threadCount() == c)
|
||||
return;
|
||||
|
||||
c = std::max(c, 1);
|
||||
c = std::min(c, QThread::idealThreadCount());
|
||||
QSettings setting;
|
||||
setting.setValue("threadCount", c);
|
||||
setting.sync();
|
||||
|
Reference in New Issue
Block a user