DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. MySQL performance: Impact of memory allocators (Part 2)

MySQL performance: Impact of memory allocators (Part 2)

Peter Zaitsev user avatar by
Peter Zaitsev
·
Mar. 11, 13 · Interview
Like (0)
Save
Tweet
Share
3.60K Views

Join the DZone community and get the full member experience.

Join For Free

this post comes from alexey stroganov at the mysql performance blog.

last time i wrote about memory allocators and how they can affect mysql performance in general. this time i would like to explore this topic from a bit different angle: what impact does the number of processor cores have on different memory allocators and what difference we will see in mysql performance in this scenario?

let me share a conclusion first: if you have a server with more than 8 cores you should use something different than the default glibc memory allocator.
we recommend jemalloc or tcmalloc
.

in my test i will use dell r720 box( spec ), centos 6.3, upcoming percona server 5.5.30 and 3 allocators – stock glibc 2.13, jemalloc-3.1.0, the latest tcmalloc from svn repo. regarding my selection of jemalloc version see my notes at the end of this post.

test box has 2xintel e5/2.2ghz with 8 real cores per socket – 16 real cores + enabled hyper-threading gives us total – 32 vcpu. in my tests i didn’t see any notable difference between allocators up to 4 vcpu, so on charts below i will highlight results from 4 to 32 vcpu.

as test workload i will use the same 2 sysbench tests – oltp_ro and point_select that i used before.
sysbench dataset – 16 tables, each 5m rows, uniform distribution.

oltp_ro test consists of 5 select queries – select_ranges, select_order_ranges, select_distinct_ranges, select_sum_ranges, point_select. processing these queries will involve notable amount of malloc()/free() operations, so allocator efficiency is the key factor to achieve high throughput in this test.


malloc_test2_oltp_ro

observations:

  • 4 vcpu – results are almost identical for all allocators (~2500tps)
  • 8 vcpu – results doubled (~5000tps) for jemalloc and tcmalloc , but with glibc malloc we have a drop at 64/128 threads to ~3500tps
  • 16vcpu – increase in throughput and quite stable results for jemalloc and tcmalloc up to 4096 threads (~6300tps) and again drop after 16 threads for glibc to ~4000tps
  • 32vcpu – throughput for jemalloc and tcmalloc jumped to ~12500tps, results stay at this level up to 1024 threads and then tps slightly decreased but still looks ok. for glibc tps drops below results we have observed for 8/16 vcpu(~3100tps).

so difference in oltp_ro test between glibc and jemalloc/tcmalloc in case of 32vcpu is ~4x.

point_select – very simple query – select c from sbtest where id=n. test workload with this query
allows to generate significant load and check server behavior under very high pressure

malloc_test2_point_select

observations:

  • 4 vcpu – again no difference between allocators (~50,000qps)
  • 8 vcpu – with all allocators we got ~100,000qps. results for jemalloc/tcmalloc are stable up to 4096 threads, for glibc malloc there is decrease in qps for 2048/4096 threads to ~80.000qps.
  • 16vcpu – with all allocators we got ~140,000qps. for jemalloc/tcmalloc up to 4096 threads, for glibc up to 512 threads, then decrease in throughput to 100,000qps.
  • 32vcpu – with all allocators we got up to ~240,000qps. then for every allocator we have drop in throughput but at different point and to different level.
    - for glibc malloc drop happened after 256 threads, qps is below the level for 8/16 vcpu. (~80,000qps).
    - for tcmalloc drop happened after 1024 threads, at 2048 thread qps is very close to results for 16vcpu and at 4096 threads qps is ~17,000.
    - for jemalloc drop happened after 1024 threads as well, at 2048 thread qps is very close to results for 16vcpu and at 4096 threads – qps is slightly better than results for 4vcpu (~60,000qps).as you can see in the case of the very high concurrency and notable amount of the small/medium allocations, we have quite poor results for jemalloc/tcmalloc. even worse than for glibc. this is the very specific case when overhead from the advanced techniques used in these allocators that should help to speed up allocation,purging of the dirty pages, minimize impact of the memory fragmentation is so significant that becomes bottleneck for the query processing. i believe that both allocators can be tuned to handle such cases better – for instance allocate more arenas but that may notably increase memory footprint.

conclusion:
- if your box has 8 cores or less – there is almost no difference between glibc malloc and alternative allocators
- if your box has more than 8 cores – you should try/evaluate alternative allocators; it can notably boost your mysql server at no cost . also, an alternative allocator must be used if you run benchmarks in this configuration, otherwise the performance will be limited by glibc/malloc and not by mysql.

notes regarding jemalloc version i’ve used in my tests: i’ve noted notable impact on mysql performance after version 3.2.0 (see raw results below) so i used jemalloc-3.1.0 in my tests. i suppose that some changes in 3.2.0 like for instance changes re: page run allocation and dirty page purging may have some correlation with decreasing performance in workloads with mysql.

# test: point_select:throughput, qps
#
# set 1 - 5.5.30pre-jemalloc-3.0.0
# set 2 - 5.5.30pre-jemalloc-3.1.0
# set 3 - 5.5.30pre-jemalloc-3.2.0
# set 4 - 5.5.30pre-jemalloc-3.3.0
#
# threads        set 1     set 2     set 3     set 4 
       1024  236575.74 236862.59 211203.42 215098.20
       2048  154829.26 154348.16 135607.69 137162.29




Allocator (C++) MySQL Memory (storage engine)

Published at DZone with permission of Peter Zaitsev, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Pair Testing in Software Development
  • Implementing Infinite Scroll in jOOQ
  • The 31 Flavors of Data Lineage and Why Vanilla Doesn’t Cut It
  • The Key Assumption of Modern Work Culture

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: