Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Memory alignment to improve operatorCache memory efficiency #366

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

dxasu
Copy link
Contributor

@dxasu dxasu commented Nov 6, 2024

What type of PR is this?

perf

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the

(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

由于golang内存对齐的特性,locked 和 freelocked 需要放在相邻位置,可以使 operatorCache结构体 从72个字节,变成64个字节,保持在一个缓存行之内,提高内存使用率,降低cachemiss。
@dxasu dxasu requested review from a team as code owners November 6, 2024 08:15
@CLAassistant
Copy link

CLAassistant commented Nov 6, 2024

CLA assistant check
All committers have signed the CLA.

@joway joway merged commit b3ca76e into cloudwego:develop Nov 7, 2024
9 checks passed
@joway
Copy link
Member

joway commented Nov 7, 2024

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

locked和freelocked 这2个字段为什么不放在一起
3 participants