Browse Source

Automatically compute a good value for number of indexer threads to start.

pull/2/head
Jacob Dufault 8 years ago
parent
commit
16dc2971a6
  1. 7
      src/command_line.cc
  2. 14
      src/language_server_api.h

7
src/command_line.cc

@ -1673,8 +1673,11 @@ void QueryDbMain(IndexerConfig* config) {
FileConsumer::SharedState file_consumer_shared;
// Start indexer threads.
std::cerr << "[querydb] Starting " << config->indexerCount << " indexers" << std::endl;
for (int i = 0; i < config->indexerCount; ++i) {
int indexerCount = std::min<int>(std::thread::hardware_concurrency(), 2) - 1;
if (config->indexerCount > 0)
indexerCount = config->indexerCount;
std::cerr << "[querydb] Starting " << indexerCount << " indexers" << std::endl;
for (int i = 0; i < indexerCount; ++i) {
new std::thread([&]() {
IndexMain(config, &file_consumer_shared, &project, &queue_do_index, &queue_do_id_map, &queue_on_id_mapped, &queue_on_indexed);
});

14
src/language_server_api.h

@ -59,9 +59,14 @@ struct IndexerConfig {
std::string cacheDirectory;
NonElidedVector<std::string> whitelist;
NonElidedVector<std::string> blacklist;
int indexerCount = 1;
int maxWorkspaceSearchResults = 1000;
std::vector<std::string> extraClangArguments;
// Maximum workspace search results.
int maxWorkspaceSearchResults = 1000;
// Force a certain number of indexer threads. If less than 1 a default value
// should be used.
int indexerCount = 0;
// If false, the indexer will be disabled.
bool enableIndexing = true;
// If false, indexed files will not be written to disk.
@ -72,9 +77,10 @@ struct IndexerConfig {
MAKE_REFLECT_STRUCT(IndexerConfig,
cacheDirectory,
whitelist, blacklist,
indexerCount,
maxWorkspaceSearchResults,
extraClangArguments,
maxWorkspaceSearchResults,
indexerCount,
enableIndexing, enableCacheWrite, enableCacheRead);

Loading…
Cancel
Save