You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can enable or disable transparent huge pages in a Linux environment by modifying.
/sys/kernel/mm/transparent_hugepage/enabled. See the official Linux admin guide for more details. If you choose to have your Linux production environment enable transparent huge pages, we recommend the following additional settings for Go programs.
Set /sys/kernel/mm/transparent_hugepage/defrag to defer or defer+madvise.
This setting controls how aggressively a Linux kernel coalesces regular pages into huge pages. defer tells the kernel to coalesce huge pages lazily and in the background. A more aggressive setting can induce stalls in memory constrained systems and can often hurt application latencies. defer+madvise is like defer, but is friendlier to other applications on the system that request huge pages explicitly and require them for performance.
Set /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none to 0.
This setting controls how many additional pages the Linux kernel daemon can allocate when trying to allocate a huge page. The default setting is maximally aggressive, and can often undo work the Go runtime does to return memory to the OS. Before Go 1.21, the Go runtime tried to mitigate the negative effects of the default setting, but it came with a CPU cost. With Go 1.21+ and Linux 6.2+, the Go runtime no longer mutates huge page state.
If you experience an increase in memory usage when upgrading to Go 1.21.1 or later, try applying this setting; it will likely resolve your issue. As an additional workaround, you can call the Prctl function with PR_SET_THP_DISABLE to disable huge pages at the process level, or you can set GODEBUG=disablethp=1 (to be added in Go 1.21.6 and Go 1.22) to disable huge pages for heap memory. Note that the GODEBUG setting may be removed in a future release.
The text was updated successfully, but these errors were encountered:
It is necessary to configure THP when building rpm or deb packages https://go.dev/doc/gc-guide#Linux_transparent_huge_pages
One can enable or disable transparent huge pages in a Linux environment by modifying.
/sys/kernel/mm/transparent_hugepage/enabled. See the official Linux admin guide for more details. If you choose to have your Linux production environment enable transparent huge pages, we recommend the following additional settings for Go programs.
Set /sys/kernel/mm/transparent_hugepage/defrag to defer or defer+madvise.
This setting controls how aggressively a Linux kernel coalesces regular pages into huge pages. defer tells the kernel to coalesce huge pages lazily and in the background. A more aggressive setting can induce stalls in memory constrained systems and can often hurt application latencies. defer+madvise is like defer, but is friendlier to other applications on the system that request huge pages explicitly and require them for performance.
Set /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none to 0.
This setting controls how many additional pages the Linux kernel daemon can allocate when trying to allocate a huge page. The default setting is maximally aggressive, and can often undo work the Go runtime does to return memory to the OS. Before Go 1.21, the Go runtime tried to mitigate the negative effects of the default setting, but it came with a CPU cost. With Go 1.21+ and Linux 6.2+, the Go runtime no longer mutates huge page state.
If you experience an increase in memory usage when upgrading to Go 1.21.1 or later, try applying this setting; it will likely resolve your issue. As an additional workaround, you can call the Prctl function with PR_SET_THP_DISABLE to disable huge pages at the process level, or you can set GODEBUG=disablethp=1 (to be added in Go 1.21.6 and Go 1.22) to disable huge pages for heap memory. Note that the GODEBUG setting may be removed in a future release.
The text was updated successfully, but these errors were encountered: