Repository navigation
test(logging): 日志窗口测试等待期限与租约时钟,更正 LSP 日志性能说明 - #1715
Merged
Merged
Conversation
LogWindowTests 和 LogWindowReviewTests 里等待真实 MacLogStore 查询结果的 门闩都用默认 2 秒。一次查询要在存储的 I/O 队列上依次完成通道解析、过滤 解析、写入排空、读文件和 Core 查询,本机负载高时会超过 2 秒, serverTabShowsOneServerAndClearsOnlyThatServer 因此超时失败。 新增 Duration.logStoreQuery(10 秒,与存储自身的操作租约一致),只用于 等待真实存储查询的门闩;门闩仍在状态送达时打开,通过的测试不会等满期限。 测试自己控制释放的门闩保持原期限。
MacLogStoreTests.collectionBudgetKeepsActiveChannelsBeforeOldRotations 读取 约 12 MB 的轮转文件,LogWindowTests.realtimeWatermarkCapPauseAndReference 连续查询三批各 10000 条记录。两者都用真实 systemUptime 计算 10 秒控制租约, 本机负载高时超过期限,抛出 NSCocoaErrorDomain 3072(操作已取消)。 为这两个测试注入固定的 diagnosticNow,使租约期限不再取决于机器速度; 生产代码的 10 秒期限和取消检查不变。
原文写“每批耗时随批次大小增长,而不是随缓冲大小增长”,不准确:格式化 和拼接只随批次增长,但确认记录没变仍要逐条比较身份。改为说明这一点, 并写入 2026-11-04 本机 release 构建的实测数字(20000 条、约 3.4 MB): 原来每次发布 58–96 ms,整份重建约 93 ms 只发生一次,记录不变的发布 约 2–4 ms,淘汰 100 条并追加 100 条约 2 ms,作为不移到后台线程的依据。
xiaoyumuxi
marked this pull request as ready for review
November 4, 2026 05:25
Lithe Review结论: ✅ 通过 未发现需要阻塞合并的问题。 Scope Check
Summary改动范围集中,等待期限调整保留了事件驱动同步;固定租约时钟消除了这两个数据量测试对机器速度的依赖。独立的租约过期测试仍然保留。性能说明补充了记录身份比较的成本及作者提供的测量数据。 Verification
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
#1712 合入后的收尾:修复日志窗口相关测试在本机负载高时偶发失败,并更正 Agent Note 里一句不准确的性能说明。生产代码没有改动。
改动
1. 日志窗口真实查询的等待期限改为 10 秒(
LogWindowTests.swift、LogWindowReviewTests.swift)问题:这两个文件里,等待真实
MacLogStore查询结果的门闩都用TestGate.waitUntilOpen()的默认 2 秒。日志窗口的一次查询要在存储的 I/O 队列上依次完成通道解析、过滤解析、写入排空、读文件和 Core 查询。本机同时编译另一个工作树时,LogWindowReviewTests.serverTabShowsOneServerAndClearsOnlyThatServer在第一次加载服务器日志时等满 2 秒失败(同一测试平时 0.1 秒左右通过)。修复:
LogWindowTests.swift新增Duration.logStoreQuery(10 秒),与存储自身的操作租约(MacLogStore.perform默认 10 秒)一致。LogWindowTests14 处、LogWindowReviewTests4 处。WindowQueryGate.release、防抖测试的delayRelease等)保持原期限。2. 大数据量日志查询测试改用固定租约时钟(
LogWindowTests.swift、MacLogStoreTests.swift)问题:
MacLogStoreTests.collectionBudgetKeepsActiveChannelsBeforeOldRotations读取约 12 MB 的轮转文件,LogWindowTests.realtimeWatermarkCapPauseAndReference连续查询三批各 10000 条记录。两者用真实systemUptime计算 10 秒控制租约,负载高时超过期限,抛出NSCocoaErrorDomain 3072(操作已取消)。本机复现过一次:44 秒后失败。修复:这两个测试给
MacLogStore注入固定的diagnosticNow: { 0 },租约期限不再取决于机器速度;生产代码的 10 秒期限和取消检查不变。这个提交与 git 命令轨迹分支(
fix/git-command-logging)里的同一提交内容完全相同,两个 PR 先合哪个都不会冲突。3. Agent Note 更正(
2026-11-03-structured-logging-log-window.md)“LSP 日志标签页”一节原来写“每批耗时随批次大小增长,而不是随缓冲大小增长”,不准确:格式化和文本拼接只随批次增长,但确认缓冲里的记录没变仍要逐条比较身份(整数和共享字符串比较)。改为说明这一点,并写入实测基线作为不移到后台线程的依据。
性能基线(#1712 的 LSP 日志增量文本)
2026-11-04 在本机用 release(
-O)构建测得,20000 条记录、约 3.4 MB 文本:内存:常驻一份约 3.4 MB 的文本,加上每条记录的身份与字节长度索引(20000 × 48 B ≈ 0.96 MB,路径和时间字符串与记录共享存储);原来每次发布都会新分配一份 3.4 MB 的字符串。
验证
.agents/skills/write-stable-tests/scripts/verify-test-stability.shscripts/agent-notes/verify-agent-notes.shnode scripts/platform-feature-matrix/verify-platform-feature-matrix-change.mjs origin/preview HEAD(没有平台实现路径变化)git diff --check--filter 'LogWindowTests|LogWindowReviewTests|collectionBudgetKeepsActiveChannelsBeforeOldRotations'):scripts/macos/test/test-macos.sh:3 个套件 21 个测试全部通过。test-stability-macos.sh(热构建):21 个测试全部通过,用时 4.1 秒。标为 SLOW 的两个测试是本来就处理大数据量的realtimeWatermarkCapPauseAndReference(2.1 秒)和collectionBudgetKeepsActiveChannelsBeforeOldRotations(1.7 秒)。这次只改了它们的租约时钟,测试的数据量和查询都没变。