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

Enable defer+madvise defragmention for THP by default #31

Merged
merged 5 commits into from
Sep 23, 2023

Conversation

ventureoo
Copy link
Member

This should improve the performance of applications that use the tcmalloc memory allocator, which is used by Chromium/Electron and Valve's native games, among others.
Ref: https://github.com/google/tcmalloc/blob/master/docs/tuning.md#system-level-optimizations

@Boria138
Copy link

Boria138 commented Sep 1, 2023

I guess the settings could be a little more customized

w- /sys/kernel/mm/transparent_hugepage/enabled - - - - - madvise
w- /sys/kernel/mm/transparent_hugepage/khugepaged/defrag - - - - - - 1
w- /sys/kernel/mm/transparent_hugepage/defrag - - - - - defer+madvise

ventureoo and others added 2 commits September 4, 2023 15:20
the difference is that:

w! overwrites existing data in the file.
w- writes data only if the file is empty or unset.
@Boria138
Copy link

Boria138 commented Sep 5, 2023

@ventureoo
Failed to write file "/sys/kernel/mm/transparent_hugepage/defrag": Invalid argument

@ptr1337
Copy link
Member

ptr1337 commented Sep 5, 2023

@ventureoo Failed to write file "/sys/kernel/mm/transparent_hugepage/defrag": Invalid argument

b26ae7b

Should fix it

@Torston420
Copy link

Torston420 commented Sep 19, 2023

Kernel docs imply that setting defrag to 'madvise' would perform the stalling behavior seen in 'always', wouldn't 'defer' be more advantageous than 'defer+madvise' for interactivity?

Update: Team Fortress 2 does not seem to allocate any hugepages at all if /transparent_hugepage/enabled is set to 'madvise' instead of 'always', this appears to be a global issue with TCMalloc: google/tcmalloc#85

@ventureoo
Copy link
Member Author

Update: Team Fortress 2 does not seem to allocate any hugepages at all if /transparent_hugepage/enabled is set to 'madvise' instead of 'always', this appears to be a global issue with TCMalloc: google/tcmalloc#85

Thanks for notice. I'll remove madvise for transparent_hugepage/enabled in that case.

Due to possible regressions
@ventureoo
Copy link
Member Author

@ptr1337 I've signed the last commit. Are there any objections to this PR?

@ptr1337 ptr1337 merged commit b2e6c5b into CachyOS:master Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants