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) { bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
auto* queue = QueueManager::instance(); auto* queue = QueueManager::instance();
bool did_work = false;
IterationLoop loop;
while (loop.Next()) {
optional<Index_OnIdMapped> response = queue->on_id_mapped.TryPopFront(); optional<Index_OnIdMapped> response = queue->on_id_mapped.TryPopFront();
if (!response) if (!response)
return false; return did_work;
did_work = true;
Timer time; Timer time;
@ -511,8 +517,9 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
Index_OnIndexed reply(std::move(update), response->perf); Index_OnIndexed reply(std::move(update), response->perf);
queue->on_indexed.PushBack(std::move(reply), response->is_interactive); queue->on_indexed.PushBack(std::move(reply), response->is_interactive);
}
return true; return did_work;
} }
bool IndexMain_LoadPreviousIndex() { bool IndexMain_LoadPreviousIndex() {