fix(vol1): 修正 cache 步长实验量纲错误(总耗时→每次访问耗时)#68
Merged
Conversation
原版用「遍历数组的总耗时」展示 Cache 效应,但 i+=stride 使步长 翻倍访问次数减半,总耗时被访问次数主导而单调下降,cache 命中差异 被完全淹没——参考输出(68ms→223ms 上升)在任何真实机器上都复现不出来。 改用 clock_gettime(CLOCK_MONOTONIC) 测墙上时间,输出 per_access=总时间÷访问次数,剥离访问次数干扰;同步重写解释段、 踩坑预警、练习题。修正后 per_access 在 stride=16(64B 缓存行边界) 处出现拐点,与文字解释自洽。 Closes #67
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.
感谢 @Nyuudoukumo 老师的反馈,这里发现一个比较严重的内容错误,修改前的原版代码原版用「遍历数组的总耗时」展示 Cache 效应,但 i+=stride 使步长。翻倍访问次数减半,总耗时被访问次数主导而单调下降,cache 命中差异被完全淹没。
现在改用 clock_gettime(CLOCK_MONOTONIC) 测墙上时间,输出per_access=总时间÷访问次数,剥离访问次数干扰;同步重写解释段、踩坑预警、练习题。修正后 per_access 在 stride=16(64B 缓存行边界)处出现拐点