런처 유휴 CPU와 AX Agent 백그라운드 갱신 부담을 줄임
Some checks failed
Release Gate / gate (push) Has been cancelled
Some checks failed
Release Gate / gate (push) Has been cancelled
- FuzzyEngine에 인덱스 버전 기준 쿼리 캐시를 추가해 색인 완료 후 반복 검색 반응성을 개선함 - 캐시된 인덱스가 없을 때는 앱 시작 시 watcher를 먼저 켜지 않도록 조정해 런처 유휴 CPU 부담을 완화함 - AX Agent는 최소화/백그라운드 상태에서 task summary, 입력 보조 UI, agent UI flush를 지연했다가 활성화 시 한 번에 반영하도록 정리함 - README와 DEVELOPMENT 문서에 2026-04-06 23:33 (KST) 기준 이력을 반영함 - 검증: dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify\\ -p:IntermediateOutputPath=obj\\verify\\ (경고 0 / 오류 0)
This commit is contained in:
@@ -116,7 +116,8 @@ public partial class App : System.Windows.Application
|
||||
_indexService = new IndexService(settings);
|
||||
var indexService = _indexService;
|
||||
indexService.LoadCachedIndex();
|
||||
indexService.StartWatchers();
|
||||
if (indexService.HasCachedIndexLoaded)
|
||||
indexService.StartWatchers();
|
||||
var fuzzyEngine = new FuzzyEngine(indexService);
|
||||
var commandResolver = new CommandResolver(fuzzyEngine, settings);
|
||||
var contextManager = new ContextManager(settings);
|
||||
|
||||
@@ -9,10 +9,16 @@ namespace AxCopilot.Core;
|
||||
public class FuzzyEngine
|
||||
{
|
||||
private readonly IndexService _index;
|
||||
private readonly object _cacheLock = new();
|
||||
private readonly Dictionary<string, List<FuzzyResult>> _queryCache = new(StringComparer.Ordinal);
|
||||
private readonly Queue<string> _queryCacheOrder = new();
|
||||
private const int QueryCacheLimit = 64;
|
||||
private int _indexGeneration;
|
||||
|
||||
public FuzzyEngine(IndexService index)
|
||||
{
|
||||
_index = index;
|
||||
_index.IndexRebuilt += (_, _) => InvalidateQueryCache();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,6 +31,13 @@ public class FuzzyEngine
|
||||
return Enumerable.Empty<FuzzyResult>();
|
||||
|
||||
var normalized = query.Trim().ToLowerInvariant();
|
||||
var cacheKey = $"{_indexGeneration}:{maxResults}:{normalized}";
|
||||
lock (_cacheLock)
|
||||
{
|
||||
if (_queryCache.TryGetValue(cacheKey, out var cached))
|
||||
return cached;
|
||||
}
|
||||
|
||||
var entries = _index.Entries;
|
||||
|
||||
// 쿼리 언어 타입 1회 사전 분류 — 항목마다 재계산하지 않음
|
||||
@@ -36,20 +49,56 @@ public class FuzzyEngine
|
||||
}
|
||||
|
||||
// 300개 초과 시 PLINQ 병렬 처리
|
||||
List<FuzzyResult> results;
|
||||
if (entries.Count > 300)
|
||||
{
|
||||
return entries.AsParallel()
|
||||
results = entries.AsParallel()
|
||||
.Select(e => new FuzzyResult(e, CalculateScoreFast(normalized, e, queryHasKorean)))
|
||||
.Where(r => r.Score > 0)
|
||||
.OrderByDescending(r => r.Score)
|
||||
.Take(maxResults);
|
||||
.Take(maxResults)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
results = entries
|
||||
.Select(e => new FuzzyResult(e, CalculateScoreFast(normalized, e, queryHasKorean)))
|
||||
.Where(r => r.Score > 0)
|
||||
.OrderByDescending(r => r.Score)
|
||||
.Take(maxResults)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return entries
|
||||
.Select(e => new FuzzyResult(e, CalculateScoreFast(normalized, e, queryHasKorean)))
|
||||
.Where(r => r.Score > 0)
|
||||
.OrderByDescending(r => r.Score)
|
||||
.Take(maxResults);
|
||||
StoreCachedResults(cacheKey, results);
|
||||
return results;
|
||||
}
|
||||
|
||||
private void InvalidateQueryCache()
|
||||
{
|
||||
lock (_cacheLock)
|
||||
{
|
||||
_indexGeneration++;
|
||||
_queryCache.Clear();
|
||||
_queryCacheOrder.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreCachedResults(string cacheKey, List<FuzzyResult> results)
|
||||
{
|
||||
lock (_cacheLock)
|
||||
{
|
||||
if (_queryCache.ContainsKey(cacheKey))
|
||||
return;
|
||||
|
||||
_queryCache[cacheKey] = results;
|
||||
_queryCacheOrder.Enqueue(cacheKey);
|
||||
|
||||
while (_queryCacheOrder.Count > QueryCacheLimit)
|
||||
{
|
||||
var oldKey = _queryCacheOrder.Dequeue();
|
||||
_queryCache.Remove(oldKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>미리 계산된 캐시 필드를 활용하는 빠른 점수 계산.</summary>
|
||||
|
||||
@@ -38,6 +38,9 @@ public partial class ChatWindow : Window
|
||||
private bool _isInWindowMoveSizeLoop;
|
||||
private bool _pendingResponsiveLayoutRefresh;
|
||||
private bool _pendingHiddenExecutionHistoryRender;
|
||||
private bool _pendingBackgroundTaskSummaryRefresh;
|
||||
private bool _pendingBackgroundInputUiRefresh;
|
||||
private bool _pendingBackgroundAgentUiEventFlush;
|
||||
private CacheMode? _cachedRootCacheModeBeforeMove;
|
||||
private string _selectedCategory = ""; // "" = 전체
|
||||
private readonly Dictionary<string, string> _tabSelectedCategory = new(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -308,6 +311,7 @@ public partial class ChatWindow : Window
|
||||
if (TokenUsagePopup != null)
|
||||
TokenUsagePopup.IsOpen = false;
|
||||
};
|
||||
Activated += (_, _) => FlushDeferredUiRefreshIfNeeded();
|
||||
IsVisibleChanged += (_, _) => FlushDeferredUiRefreshIfNeeded();
|
||||
StateChanged += (_, _) => FlushDeferredUiRefreshIfNeeded();
|
||||
UpdateConversationFailureFilterUi();
|
||||
@@ -2726,6 +2730,12 @@ public partial class ChatWindow : Window
|
||||
if (_inputUiRefreshTimer == null)
|
||||
return;
|
||||
|
||||
if (IsBackgroundUiThrottleActive())
|
||||
{
|
||||
_pendingBackgroundInputUiRefresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_inputUiRefreshTimer.Stop();
|
||||
_inputUiRefreshTimer.Start();
|
||||
}
|
||||
@@ -5674,10 +5684,37 @@ public partial class ChatWindow : Window
|
||||
_executionHistoryRenderTimer.Stop();
|
||||
_executionHistoryRenderTimer.Start();
|
||||
}
|
||||
|
||||
if (_pendingBackgroundTaskSummaryRefresh)
|
||||
{
|
||||
_pendingBackgroundTaskSummaryRefresh = false;
|
||||
_taskSummaryRefreshTimer.Stop();
|
||||
_taskSummaryRefreshTimer.Start();
|
||||
}
|
||||
|
||||
if (_pendingBackgroundInputUiRefresh)
|
||||
{
|
||||
_pendingBackgroundInputUiRefresh = false;
|
||||
_inputUiRefreshTimer.Stop();
|
||||
_inputUiRefreshTimer.Start();
|
||||
}
|
||||
|
||||
if (_pendingBackgroundAgentUiEventFlush)
|
||||
{
|
||||
_pendingBackgroundAgentUiEventFlush = false;
|
||||
_agentUiEventTimer.Stop();
|
||||
_agentUiEventTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ScheduleTaskSummaryRefresh()
|
||||
{
|
||||
if (IsBackgroundUiThrottleActive())
|
||||
{
|
||||
_pendingBackgroundTaskSummaryRefresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_taskSummaryRefreshTimer.Stop();
|
||||
_taskSummaryRefreshTimer.Start();
|
||||
}
|
||||
@@ -5695,10 +5732,27 @@ public partial class ChatWindow : Window
|
||||
private void ScheduleAgentUiEvent(AgentEvent evt)
|
||||
{
|
||||
_pendingAgentUiEvent = evt;
|
||||
if (IsBackgroundUiThrottleActive())
|
||||
{
|
||||
_pendingBackgroundAgentUiEventFlush = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_agentUiEventTimer.Stop();
|
||||
_agentUiEventTimer.Start();
|
||||
}
|
||||
|
||||
private bool IsBackgroundUiThrottleActive()
|
||||
{
|
||||
if (!IsLoaded)
|
||||
return true;
|
||||
|
||||
if (!IsVisible || WindowState == WindowState.Minimized)
|
||||
return true;
|
||||
|
||||
return !IsActive;
|
||||
}
|
||||
|
||||
private void FlushPendingAgentUiEvent()
|
||||
{
|
||||
var evt = _pendingAgentUiEvent;
|
||||
|
||||
Reference in New Issue
Block a user