CachyOS / CachyOS-Settings

Settings used for CachyOS
GNU General Public License v3.0
91 stars 22 forks source link

Enable defer+madvise defragmention for THP by default #31

Closed ventureoo closed 12 months ago

ventureoo commented 1 year ago

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 commented 1 year ago

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

Boria138 commented 1 year ago

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

ptr1337 commented 1 year ago

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

https://github.com/CachyOS/CachyOS-Settings/pull/31/commits/b26ae7bed801909980498de3ccade8fdd19d4810

Should fix it

Torston420 commented 1 year ago

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: https://github.com/google/tcmalloc/issues/85

ventureoo commented 12 months ago

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: https://github.com/google/tcmalloc/issues/85

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

ventureoo commented 12 months ago

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