Redis server's log issues this warning on startup:
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel
along with instructions for how to change this. However, when adding the necessary configuration edits to the rc.local file it seems that redis manages to launch before rc.local is executed. (Since it gives the same warning, but the settings have indeed been changed and if restarting redis, then the warning goes away...)
So what I've done instead is add this:
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
to the beginning of the /etc/init.d/redis_6379 file, which seems to do the trick.
Any problems with this approach?
Thanks.
Comment From: jingleyang
Could anyone introduce that why Transparent Huge Pages(THP) will impact the performance of Redis? For example, reading materials and testing data are appreciated.
Comment From: badboy
http://antirez.com/news/84
Comment From: KrisKusano
The rc.local solution suggested in the warning and in comment 1 did not solve the issue (Ubuntu 14.04). I guess on my setup, redis was still launching before the rc.local changes took effect.
The solution for me was to follow this guide. Since the guide was for mongoDB, the only change I had to make to the init.d script was to change X-Start-Before to redis.. HTH
Comment From: ulope
IMO the correct way to permanently set this configuration is to use the sysctl facilities of your distro (usually by adding a file in /etc/sysctl.d/ or by modifying /etc/sysctl.conf if you're using an old school distro)
Comment From: tsoldaat
We solved this on Ubuntu 14 LTS and 16 LTS by adding a directive to grub, so this will be activated before services are started and it will survive a reboot.
Create the file /etc/default/grub.d/no_thp.cfg and add:
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT transparent_hugepage=never"
Run sudo update-grub to activate it.
Comment From: antirez
Actually with newer Jemalloc versions (4.5.0) which I hope to upgrade to ASAP, there is directly a build option to avoid using THP automatically. This could be the best way to address the problem in the future.
On Wed, May 17, 2017 at 2:22 PM, Tjalling Soldaat notifications@github.com wrote:
We solved this on Ubuntu 14 LTS and 16 LTS by adding a directive to grub, so this will be activated before services are started and it will survive a reboot.
Create the file /etc/default/grub.d/no_thp.cfg and add:
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT transparent_hugepage=never"
Run sudo update-grub to activate it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/antirez/redis/issues/3176#issuecomment-302073232, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEAYKOLisaltuFix0sAaC9GO2bNeWswks5r6uZqgaJpZM4IJ3Cx .
-- Salvatore 'antirez' Sanfilippo open source developer - Redis Labs https://redislabs.com
"If a system is to have conceptual integrity, someone must control the concepts." — Fred Brooks, "The Mythical Man-Month", 1975.
Comment From: camdenorrb
Bump?
Comment From: romberli
Actually with newer Jemalloc versions (4.5.0) which I hope to upgrade to ASAP, there is directly a build option to avoid using THP automatically. This could be the best way to address the problem in the future. … On Wed, May 17, 2017 at 2:22 PM, Tjalling Soldaat @.***> wrote: We solved this on Ubuntu 14 LTS and 16 LTS by adding a directive to grub, so this will be activated before services are started and it will survive a reboot. Create the file /etc/default/grub.d/no_thp.cfg and add: GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT transparent_hugepage=never" Run sudo update-grub to activate it. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#3176 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEAYKOLisaltuFix0sAaC9GO2bNeWswks5r6uZqgaJpZM4IJ3Cx . -- Salvatore 'antirez' Sanfilippo open source developer - Redis Labs https://redislabs.com "If a system is to have conceptual integrity, someone must control the concepts." — Fred Brooks, "The Mythical Man-Month", 1975.
hi @antirez , have this feature been added to major release? if yes, which version is the lowest?
Comment From: trevex
We run into the same warning in our container infrastructure and an upstream fix would be highly appreciated.
Comment From: djh42
I changed the setting to madvise but the warning still insists on never. Is there a good reason for that?
Comment From: thedotedge
Actually with newer Jemalloc versions (4.5.0) which I hope to upgrade to ASAP, there is directly a build option to avoid using THP automatically. This could be the best way to address the problem in the future.
Seems like it's still not there in 5.0.5 — any ETA so that grub/sysctl workarounds are no longer needed?
Comment From: AdamVenn
This appears to be the definitive: https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
Just replace mongodb with redis and redis-server. Worked well for me!
Oh, by the way, I had to do systemctl edit redis-server and add:
[Service]
Type=notify
Comment From: djh42
The mongodb page also suggests 'never'. Again, what is wrong with 'madvise'?
Comment From: JOduMonT
@songololo I tried your solution, it did'nt work well for me on Ubuntu 20.04LTS
``` if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi ```
I think redis should be aware to start after rc-local and or simply restarting the redis service after applying the new THP rules. To resolve this issue I...
enable rc.local in Ubuntu 20.04
as root
1. make a systemd service for rc-local
add in /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
2. active it
touch /etc/rc.local
chmod +x /etc/rc.local
systemctl enable rc-local
2.1 in that file (rc.local) you could add
#!/bin/bash
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
systemctl restart redis-server.service
exit 0
Comment From: yossigo
@JOduMonT What is your kernel's default? Recent kernels now use madvise and recent versions of Redis no longer (incorrectly) wrong when madvise is detect. I think this issue should be obsolete by now.
Comment From: JOduMonT
@yossigo on my workstation the kernel is: 5.11.0-18.1-liquorix-amd64 and the default config (without the "patch")
$ cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
$ cat /sys/kernel/mm/transparent_hugepage/defrag
always defer [defer+madvise] madvise never
on server side it's the LTS kernel so 5.4, but I don't have any under my hand right now to check the default THP config.
Comment From: yossigo
@JOduMonT Recent versions of Redis (6.0.8 or newer) should not report the above error message in that case, can you please confirm?
Comment From: oranagra
this should be handled in redis 6.0.8 and 6.2.0 see: #4001 #7381 #7771