Repository navigation
fix: 新建 box 的 child_max_cap 初始化为 {0, 0},消除满叶节点重复下探 - #9
Closed
carsontung666 wants to merge 1 commit into
Closed
carsontung666 wants to merge 1 commit into
carsontung666 wants to merge 1 commit into
Conversation
Merged
Collaborator
Author
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.
概述
slotsboxmalloc是基于 64 叉树的分层内存分配器,每个节点(sbo_box_t)通过max_obj_cap(自身剩余连续槽位)与child_max_cap(子节点最大可用容量)向上汇报可用容量。本 PR 修复新建节点child_max_cap初值错误导致满叶子节点被反复无效遍历的性能退化问题。问题与修复
sbo_box_format初始化新节点时无子节点,但将child_max_cap设为了非零的{objlevel + 1, 1}。叶子节点填满全部 64 个槽位后仅更新max_obj_cap = 0,child_max_cap仍保持{objlevel + 1, 1},导致对外容量sbo_box_and_child_max_cap恒不为 0,后续每次sbo_alloc都会重复下探所有已满叶子节点。sbo_box_format中的box->child_max_cap初始值改为{0, 0},并新增叶节点满/释放状态转换的回归测试。验证
sbo_find_alloc访问次数从 8,617,984 次降至 131,072 次,耗时从 606 ms 降至 17 ms(35x)。kvlangSHMfib(13)中位耗时从 445 ms 降至 135 ms(3.3x)。