mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
docs: 合并性能分析报告并优化内存管理
将 performance-reporter.md 合入 memory-peak-analysis.md,统一分析文档。 代码优化包括:compact 峰值释放、GC 阈值触发、虚拟滚动参数调优、 HybridTransport 队列缩减、无界缓存加 LRU 淘汰、taskSummary 避免数组拷贝。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -521,7 +521,7 @@ export async function compactConversation(
|
||||
}
|
||||
|
||||
// Store the current file state before clearing
|
||||
const preCompactReadFileState = cacheToObject(context.readFileState)
|
||||
let preCompactReadFileState = cacheToObject(context.readFileState)
|
||||
|
||||
// Clear the cache
|
||||
context.readFileState.clear()
|
||||
@@ -543,6 +543,9 @@ export async function compactConversation(
|
||||
),
|
||||
createAsyncAgentAttachmentsIfNeeded(context),
|
||||
])
|
||||
// Release the readFileState snapshot — it can hold 25+ MB of file content
|
||||
preCompactReadFileState =
|
||||
undefined as unknown as typeof preCompactReadFileState
|
||||
|
||||
const postCompactFileAttachments: AttachmentMessage[] = [
|
||||
...fileAttachments,
|
||||
@@ -649,6 +652,8 @@ export async function compactConversation(
|
||||
|
||||
// Extract compaction API usage metrics
|
||||
const compactionUsage = getTokenUsage(summaryResponse)
|
||||
// Release the full API response — it holds content blocks + usage metadata
|
||||
summaryResponse = undefined as unknown as typeof summaryResponse
|
||||
|
||||
const querySourceForEvent =
|
||||
recompactionInfo?.querySource ?? context.options.querySource ?? 'unknown'
|
||||
@@ -922,7 +927,7 @@ export async function partialCompactConversation(
|
||||
}
|
||||
|
||||
// Store the current file state before clearing
|
||||
const preCompactReadFileState = cacheToObject(context.readFileState)
|
||||
let preCompactReadFileState = cacheToObject(context.readFileState)
|
||||
context.readFileState.clear()
|
||||
context.loadedNestedMemoryPaths?.clear()
|
||||
// Intentionally NOT resetting sentSkillNames — see compactConversation()
|
||||
@@ -937,6 +942,9 @@ export async function partialCompactConversation(
|
||||
),
|
||||
createAsyncAgentAttachmentsIfNeeded(context),
|
||||
])
|
||||
// Release the readFileState snapshot — it can hold 25+ MB of file content
|
||||
preCompactReadFileState =
|
||||
undefined as unknown as typeof preCompactReadFileState
|
||||
|
||||
const postCompactFileAttachments: AttachmentMessage[] = [
|
||||
...fileAttachments,
|
||||
@@ -992,6 +1000,8 @@ export async function partialCompactConversation(
|
||||
summaryResponse,
|
||||
])
|
||||
const compactionUsage = getTokenUsage(summaryResponse)
|
||||
// Release the full API response — it holds content blocks + usage metadata
|
||||
summaryResponse = undefined as unknown as typeof summaryResponse
|
||||
|
||||
logEvent('tengu_partial_compact', {
|
||||
preCompactTokenCount,
|
||||
|
||||
Reference in New Issue
Block a user