Compare commits

...

1 Commits

Author SHA1 Message Date
Pi
8cfea3c72f use as many threads as possible 2023-04-22 12:22:46 -07:00
4 changed files with 16 additions and 7688 deletions

3
.gitignore vendored
View File

@ -91,3 +91,6 @@ typings/
# Electron-Forge # Electron-Forge
out/ out/
# yarn lock
yarn.lock

View File

@ -66,6 +66,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",
"express": "^4.18.2", "express": "^4.18.2",
"os-utils": "^0.0.14",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-markdown": "^8.0.6", "react-markdown": "^8.0.6",

View File

@ -374,16 +374,26 @@ const checkIfFileExists = async () => {
} }
}; };
const osUtil = require("os-utils");
var threads = 0;
var sysThreads = osUtil.cpuCount();
for (let i = 1; i < sysThreads; i = i * 2) {
threads = i;
}
if (sysThreads == 4) {
threads = 4;
}
io.on("connection", (socket) => { io.on("connection", (socket) => {
/* /*
The alpaca model doesnot work with context so we need to spawn a new process for each chat The alpaca model doesnot work with context so we need to spawn a new process for each chat
This is not ideal but it works for now. If you have any suggestions on how to improve this This is not ideal but it works for now. If you have any suggestions on how to improve this
please let me know! please let me know!
*/ */
let program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]); let program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH, "--threads", threads.toString(), "--batch_size", (threads * 4).toString()]);
socket.on("chatstart", () => { socket.on("chatstart", () => {
program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]); program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH, "--threads", threads.toString(), "--batch_size", (threads * 4).toString()]);
}); });
socket.on("stopResponding", () => { socket.on("stopResponding", () => {

7686
yarn.lock

File diff suppressed because it is too large Load Diff