EmergencyEMERGENCY? Get 24/7 Help Now!

Enabling and Disabling Jemalloc on Percona Server

 | January 3, 2017 |  Posted In: Insight for DBAs, MySQL

PREVIOUS POST
NEXT POST

Jemalloc on Percona ServerThis post discusses enabling and disabling jemalloc on Percona Server for MySQL.

The benefits of jemalloc versus glibc for use with MySQL have been widely discussed. With jemalloc (along with Transparent Huge Pages disabled) you have less memory fragmentation, and thus more efficient resource management of the available server memory.

For standard installations of Percona Server 5.6+ (releases starting with 5.6.19-67.0), the only thing needed to use jemalloc as the memory library for mysqld is for it to be installed on the server.

Enabling Jemalloc on Percona Server

First thing first: install Jemalloc.

The library is available on the Percona repository, which is available for both apt and yum package management:

Once you have the repo, just run the install command (according to your OS) to install it:

Now that you have the jemalloc package installed, all it takes to start using it is…..

  • Restart the server.

That’s it! No modifications needed on the my.cnf file or anywhere else. Plain and simple!

Disabling Jemalloc on Percona Server

If for any reason you need to disable jemalloc and go back to the default library, you have two options: remove the jemalloc package (not too practical), or add the following line to the [mysqld_safe] section of the my.cnf file:

In other words, an empty path. That will do the trick. Note that commenting or removing the “malloc-lib” parameter on the cnf file won’t work.

How to Know if Jemalloc is Being Used?

There are couple of ways you can verify this, but the less invasive way is by using the pt-mysql-summary (version 2.2.20 and higher) tool from the Percona Toolkit:

PREVIOUS POST
NEXT POST
Daniel Guzmán Burgos

Daniel studied Electronic Engineering, but quickly becomes interested in all data things. He has worked as a DBA since 2007 for several companies including one of the major social gaming company at that time in Latin America. Daniel lives in Bogotá, Colombia and in his free time he loves to spend time with his family and go out to eat at any kind of restaurant. Working for Percona since 2014, he is part of the Consulting team.

3 Comments

  • Running Persona Server 5.7 here and wasn’t able to find a package called ‘jemalloc’

    # apt-cache search jemalloc
    libjemalloc-dev – development files and documentation for jemalloc
    libjemalloc1 – general-purpose scalable concurrent malloc(3) implementation
    libjemalloc1-dbg – debug symbols for jemalloc

    Installed ‘libjemalloc1’ and it works perfectly:

    # pt-mysql-summary | grep -A5 -i “memory management”
    # Memory management library ##################################
    jemalloc enabled in MySQL config for process with ID 24470
    Using jemalloc from /usr/lib/x86_64-linux-gnu/libjemalloc.so.1
    # The End ####################################################

    • Hi!

      Yes, you’re right. For apt the package name is libjemalloc1. I’ll fix the post. Thanks for catching it up!

Leave a Reply