Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 0b4d086

Browse files
committed
Always use the number of logical cores as threadpools
1 parent e6a6b01 commit 0b4d086

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "utils/nitro_utils.h"
2-
#include <climits> // for PATH_MAX
2+
#include <algorithm> // Include the algorithm header
3+
#include <climits> // for PATH_MAX
34
#include <drogon/HttpAppFramework.h>
45
#include <drogon/drogon.h>
6+
#include <thread>
57

68
#if defined(__APPLE__) && defined(__MACH__)
79
#include <libgen.h> // for dirname()
@@ -35,11 +37,12 @@ int main(int argc, char *argv[]) {
3537
port = std::atoi(argv[3]); // Convert string argument to int
3638
}
3739

40+
int logical_cores = std::thread::hardware_concurrency();
3841
nitro_utils::nitro_logo();
3942
LOG_INFO << "Server started, listening at: " << host << ":" << port;
4043
LOG_INFO << "Please load your model";
4144
drogon::app().addListener(host, port);
42-
drogon::app().setThreadNum(thread_num + 5);
45+
drogon::app().setThreadNum(std::max(thread_num, logical_cores));
4346
LOG_INFO << "Number of thread is:" << drogon::app().getThreadNum();
4447

4548
drogon::app().run();

0 commit comments

Comments
 (0)