mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-06 16:24:54 +00:00
Default to using 80% of cores available (instead of 100%) for indexing
This commit is contained in:
parent
cef0203484
commit
e309712bd1
@ -3,6 +3,9 @@
|
||||
|
||||
#include "config.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <thread>
|
||||
|
||||
namespace ccls {
|
||||
Config *g_config;
|
||||
|
||||
@ -16,4 +19,10 @@ void doPathMapping(std::string &arg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int defaultIndexThreadCount() {
|
||||
constexpr float kIndexThreadUtilization = 0.8;
|
||||
return std::max(1, static_cast<int>(std::thread::hardware_concurrency() *
|
||||
kIndexThreadUtilization));
|
||||
}
|
||||
} // namespace ccls
|
||||
|
@ -8,6 +8,10 @@
|
||||
#include <string>
|
||||
|
||||
namespace ccls {
|
||||
|
||||
// Select a reasonable default number of threads to use for indexing.
|
||||
int defaultIndexThreadCount();
|
||||
|
||||
/*
|
||||
The language client plugin needs to send initialization options in the
|
||||
`initialize` request to the ccls language server.
|
||||
@ -286,7 +290,7 @@ struct Config {
|
||||
bool parametersInDeclarations = true;
|
||||
|
||||
// Number of indexer threads. If 0, 80% of cores are used.
|
||||
int threads = 0;
|
||||
int threads = defaultIndexThreadCount();
|
||||
|
||||
// Whether to reparse a file if write times of its dependencies have
|
||||
// changed. The file will always be reparsed if its own write time changes.
|
||||
|
@ -374,6 +374,10 @@ void do_initialize(MessageHandler *m, InitializeParam ¶m,
|
||||
// Start indexer threads. Start this after loading the project, as that
|
||||
// may take a long time. Indexer threads will emit status/progress
|
||||
// reports.
|
||||
//
|
||||
// By default config.hh will select 80% of the available cores to use as
|
||||
// index threads, but explicitly specifying threads=0 will instead use all
|
||||
// available cores.
|
||||
if (g_config->index.threads == 0)
|
||||
g_config->index.threads = (int)std::thread::hardware_concurrency();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user