MySQL Large Pages errors

Using "large pages" (aka HugeTLB or "huge pages") for MySQL under Linux is pretty sweet, since it lets you use larger memory pages. Unfortunately, if you're like me, you can set up huge pages according to the documentation, but still get errors like this when you start up MySQL:


080324 01:38:04  mysqld started
InnoDB: HugeTLB: Warning: Failed to allocate 12884918272 bytes. errno 22
InnoDB HugeTLB: Warning: Using conventional memory pool
080324  1:38:04  InnoDB: Error: cannot allocate 12884918272 bytes of
InnoDB: memory with malloc! Total allocated memory
InnoDB: by InnoDB 153659216 bytes. Operating system errno: 12
InnoDB: Check if you should increase the swap file or
InnoDB: ulimits of your operating system.
InnoDB: On FreeBSD check you have compiled the OS with
InnoDB: a big enough maximum process size.
InnoDB: Note that in most 32-bit computers the process
InnoDB: memory space is limited to 2 GB or 4 GB.
InnoDB: We keep retrying the allocation for 60 seconds...
InnoDB: Fatal error: cannot allocate the memory for the buffer pool
Warning: Failed to allocate 220200960 bytes from HugeTLB memory. errno 22

The fix, it turns, out, is simple. While it's not actually spelled out anywhere in the documentation, you need to adjust the kernel.shmall and kernel.shmmax syctls (also found at /proc/sys/kernel/shmall and /proc/sys/kernel/shmmax) to allow enough memory to be allocated to those big pages. What you set those values to will depend on how much RAM you have, how much RAM you've allocated to InnoDB, and how many large pages you've reserved. These are the values I used on the DKos db servers:


vm.nr_hugepages = 6350
kernel.shmmax = 17179869184
kernel.shmall = 4194304

Comments imported from the old site.
PAE necessary?

Is this dependent on either 64-bit support or a PAE kernel, or can this be done on 32-bit machines with a non-PAE kernel?

You know, I'm not sure.

I guess it depends on if you can even have large pages under a non-PAE 32 bit kernel. You might also run up against the problem where you can't address more that 2GB mem at once anyway.

 
comments powered by Disqus