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 Transparent Hugepages when Gaming #465

Open
sockusminimus opened this issue Mar 2, 2024 · 0 comments
Open

Enable Transparent Hugepages when Gaming #465

sockusminimus opened this issue Mar 2, 2024 · 0 comments

Comments

@sockusminimus
Copy link

sockusminimus commented Mar 2, 2024

Transparent Hugepages (THP) have the kernel allocate memory pages in 2MiB or 2GiB units instead of 4KiB units as is the platform default on X86. This has been shown to measurably improve gaming performance in many cases. The risk for enabling this is low, as some distros do this by default (such as OpenSUSE). It is also a kernel tunable that can be set at runtime using sysctl.

I propose we enable THP and disable proactive compaction for gaming sessions and set these back to default when the session ends (as some workloads such as databases can be negatively impacted by memory fragmentation that this can cause).

My proposal is to enable the following when gaming and restore when game ends:
echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo advise | sudo tee /sys/kernel/mm/transparent_hugepage/shmem_enabled
echo 0 | sudo tee /proc/sys/vm/compaction_proactiveness
echo 0 | sudo tee /sys/kernel/mm/transparent_hugepage/khugepaged/defrag

See e.g. https://github.com/CryoByte33/steam-deck-utilities/blob/main/docs/tweak-explanation.md
See also https://blog.patshead.com/2023/02/enabling-transparent-hugepages-can-provide-huge-gaming-performance-improvements.html
See also https://alexandrnikitin.github.io/blog/transparent-hugepages-measuring-the-performance-impact/

@sockusminimus sockusminimus changed the title Enable Transparent Hugepages Enable Transparent Hugepages when Gaming Mar 2, 2024
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

No branches or pull requests

1 participant