perf: Memory alignment to improve operatorCache memory efficiency #366
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.
What type of PR is this?
perf
Check the PR title.
(Optional) Translate the PR title into Chinese.
内存对齐,提高operatorCache内存效率
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:Due to the characteristics of golang memory alignment, locked and freelocked need to be placed in adjacent positions, which can reduce the size of the operatorCache structure from 72 bytes to 64 bytes, keep it within one cache line, improve memory utilization, and reduce cache miss.
In addition, you can consider filling blank memory between locked and freelocked, so that locked and freelocked are in different cache lines, reducing the frequency of competition between locks.
zh(optional): 由于golang内存对齐的特性,locked 和 freelocked 需要放在相邻位置,可以使 operatorCache结构体 从72个字节,变成64个字节,保持在一个缓存行之内,提高内存使用率,降低cachemiss。
另外可以考虑下locked和freelocked 之间,填充空白内存,使locked和freelocked分别处于不同的缓存行,降低锁之间相互竞争的频率。
(Optional) Which issue(s) this PR fixes:
Fixes #365