Ubuntu Server Gazette - Issue 7 - MySQL memory allocation

Thanks to our collaboration with Oracle, MySQL in Ubuntu is now faster and more memory-efficient for everyone.

Cooperation with Oracle

We’re thrilled to share some exciting news for MySQL users on Ubuntu! Our continuous collaboration with the community and partners, including recent discussions at FOSDEM 2025 and the attached MySQL Belgian Days, have led to a significant performance boost.

A great presentation by Oracle engineers Frederic and Dimitri, utilizing Fred’s mysql-component-profiler, highlighted the gains that can be achieved with tcmalloc as MySQL’s memory allocator.

This clear preference for tcmalloc prompted us to make it the default in MySQL 8.4 in Ubuntu, ensuring you get the best performance out of the box.

tcmalloc is the recommended allocator

There is a substantial improvement of memory allocation efficiency - using less resident memory for the same workload when scaling up. Furthermore tcmalloc has shown a lower allocation latency compared to jemalloc and it’s faster in freeing of unused memory.

Want to dive deeper? Check out the FOSDEM presentation for graphs and more details.

Making it available to the end users

After that we have taken action to ensure MySQL 8.4 compiled with tcmalloc directly.
This approach provides the recommended option by default - at the same time it avoids error prone LD_PRELOAD setups and makes using tcmalloc slightly more efficient.

I implemented this via bug 2119483 and therefore it will be available to all of you to enjoy from Ubuntu 25.10 questing quokka onwards.

Doing your own profiling

As a side effect of this work I made the aforementioned profiler available, which you can use to analyze your own workloads in 25.10 if you like. The MySQL Component profiler can be found in a PPA. If that is a strong use case for you, please get in contact so we can consider adding it to the archive.

Want to learn how to put it to good use? Check out the FOSDEM presentation here for a detailed walkthrough. Here is an excerpt to know what it looks like:

Tcmalloc memory profiling (warning, lots of overhead)

  1. Install component through mysql CLI
mysql\> install component 'file://component\_profiler';  
mysql\> install component 'file://component\_profiler\_memory';
  1. Clean up and start profiler
mysql\> select profiler\_cleanup();  
mysql\> select memprof\_start();
  1. Run your very own workload

  2. Dump data

mysql\> select memprof\_dump();
  1. Stop profiler
mysql\> select memprof\_stop();

Tcmalloc CPU profiling

  1. Install component through mysql CLI
mysql\> install component 'file://component\_profiler';  
mysql\> install component 'file://component\_profiler\_cpu';
  1. Start profiler
mysql\> select cpuprof\_start();
  1. Stop profiler
mysql\> select cpuprof\_stop();

Use it!

We hope this helps the efficiency of your workload too. Furthermore, the integrated profiling capabilities might allow you to check your workload more thoroughly.

Ubuntu 25.10 “Questing Quokka” is our last interim release before the highly anticipated 26.04 LTS, making it the perfect opportunity to dive into all the exciting new features and enhancements since 24.04 LTS. This is your chance to influence the next LTS final form, so don’t miss out!

P.S. If you’re eager to get started right away, you can even try tcmalloc or jemalloc in older releases using the LD_PRELOAD trick.

4 Likes