mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									ef59e59f5b
								
							
						
					
					
						commit
						1fd0a1be94
					
				@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -485,8 +491,8 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
 | 
				
			|||||||
          response->current->file->last_modification_time);
 | 
					          response->current->file->last_modification_time);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if false
 | 
					  #if false
 | 
				
			||||||
#define PRINT_SECTION(name)                                                    \
 | 
					  #define PRINT_SECTION(name)                                                    \
 | 
				
			||||||
    if (response->perf.name) {                                                   \
 | 
					    if (response->perf.name) {                                                   \
 | 
				
			||||||
      total += response->perf.name;                                              \
 | 
					      total += response->perf.name;                                              \
 | 
				
			||||||
      output << " " << #name << ": " << FormatMicroseconds(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 << "\n       total: " << FormatMicroseconds(total);
 | 
				
			||||||
    output << " path: " << response->current_index->path;
 | 
					    output << " path: " << response->current_index->path;
 | 
				
			||||||
    LOG_S(INFO) << output.rdbuf();
 | 
					    LOG_S(INFO) << output.rdbuf();
 | 
				
			||||||
#undef PRINT_SECTION
 | 
					  #undef PRINT_SECTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (response->is_interactive)
 | 
					    if (response->is_interactive)
 | 
				
			||||||
      LOG_S(INFO) << "Applying IndexUpdate" << std::endl << update.ToString();
 | 
					      LOG_S(INFO) << "Applying IndexUpdate" << std::endl << update.ToString();
 | 
				
			||||||
#endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user