Reduce queue lengths by running index updates as iteration loop

A single translation unit can create many index updates, so give
IndexMain_DoCreateIndexUpdate a chance to run a few times. This should also be
faster as it is more icache friendly.
This commit is contained in:
Jacob Dufault 2018-03-20 11:55:40 -07:00 committed by Fangrui Song
parent ef59e59f5b
commit 1fd0a1be94

View File

@ -452,9 +452,15 @@ bool IndexMain_DoParse(
bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
auto* queue = QueueManager::instance();
bool did_work = false;
IterationLoop loop;
while (loop.Next()) {
optional<Index_OnIdMapped> response = queue->on_id_mapped.TryPopFront();
if (!response)
return false;
return did_work;
did_work = true;
Timer time;
@ -485,8 +491,8 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
response->current->file->last_modification_time);
}
#if false
#define PRINT_SECTION(name) \
#if false
#define PRINT_SECTION(name) \
if (response->perf.name) { \
total += response->perf.name; \
output << " " << #name << ": " << FormatMicroseconds(response->perf.name); \
@ -503,16 +509,17 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
output << "\n total: " << FormatMicroseconds(total);
output << " path: " << response->current_index->path;
LOG_S(INFO) << output.rdbuf();
#undef PRINT_SECTION
#undef PRINT_SECTION
if (response->is_interactive)
LOG_S(INFO) << "Applying IndexUpdate" << std::endl << update.ToString();
#endif
#endif
Index_OnIndexed reply(std::move(update), response->perf);
queue->on_indexed.PushBack(std::move(reply), response->is_interactive);
}
return true;
return did_work;
}
bool IndexMain_LoadPreviousIndex() {