How to Disable Transparent Huge Pages in Github Actions

I’m trying to run some PHP tests for a legacy application, and part of that process requires running a container for MariaDB that uses TokuDB (very obscure engine)

The issue is that TokuDB doesn’t work if Transparent Huge Pages are enabled.

How can I disable THP for Github Actions? I’m wanting to move away from Circle CI but this is the last thing blocking me.

@mckalexee,

To check if Transparent Hugepages is enabled on the Linux machine, you can run the following command.

cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
  • If it is enabled, the returned setting is this.
    [always] madvise never
    
  • If it is disabled, the returned setting is this.
    always madvise [never]
    

To disable Transparent Hugepages on the Linux runner machine:

  1. If on the GitHub-hosted runner, you can try to re-install the Hugepages and use the option “–thp-never” to disable Transparent Hugepages.

    - name: Check Transparent Hugepages
      run: cat /sys/kernel/mm/transparent_hugepage/enabled
    
    - name: Re-install Hugepages and disable Transparent Hugepages
      run: |
        sudo su
        sudo apt-get install hugepages
        sudo hugeadm --thp-never
    
    - name: Check Transparent Hugepages again
      run: cat /sys/kernel/mm/transparent_hugepage/enabled
    
  2. If on your self-hosted runner, generally you can follow one one of the two methods below:

    • Edit your boot loader (such as /etc/grub.conf) and add the following line to the end of the kernel line.
      transparent_hugepage=never
      
    • Edit /etc/rc.local and add the following script.
      if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
        echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
      fi
      

    After one of above two methods, you need to reboot your system for the setting to take effect, or run the following echo line to proceed with the install without rebooting:

    echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
    

@mckalexee,

How are things going?
Have you tried my above suggestions to disable Transparent Hugepages on the Linux runner machine?
Are they helpful to you?
Please have try, any update, feel free to tell us.

Unfortunately this doesn’t work on the GitHub-hosted runner. The container has to be running in privileged mode to modify THP.

It should work directly in the runner VM, but to ensure the change is made before the container is started you’ll have to manage your container(s) directly instead of relying on job-level container or services settings.

1 Like

@airtower-luna @brightran

That was it. Thanks!

I needed to manually control the containers instead of using the services option.

One small pain point is that I can’t run my tasks in my own docker container. This means I have to install some things in the linux runner every time, and the actions testing environment doesn’t 100% match my production environment any more.

I can work around it just fine, but it would be nice in the future if a flag existed to disable THP out the gate so I can use some of the built in docker features.

1 Like

Well, you could turn the current steps into a script running in yet another Docker container. Though admittedly that loses the convenience of including pre-made actions.