[SRU] tcmalloc performance degredation over time

Bug #1439277 reported by James Page
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
google-perftools (Ubuntu)
Fix Released
High
Unassigned
Trusty
Fix Released
High
James Page
Vivid
Fix Released
High
Unassigned

Bug Description

[Impact]
When under memory pressure, tcmalloc will consume increasing amounts of CPU cycles resulting in performance degradation; the mechanism to permit a larger thread cache is broken, so the pinch point cannot be worked around by increasing the amount of memory to relieve this pressure.

[Test Case]
(compile attached binary)
g++ -o gperftest gperftest.c -ltcmalloc
export TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=67108864
./gperftest
Tcmalloc BUG! TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES: 67108864 Internal Size: 33554432 different

[Regression Potential]
Fix committed upstream and isolate to a specific code path.

[Original Bug Report]

Reported by upstream:

> Sage,
> Here is the tcmalloc issue I was talking in the performance meeting.
>
> http://code.google.com/p/gperftools/issues/detail?id=585
>
> The tcmalloc is consuming lot of cpus (and eventually slowing down the performance) with the following perf top trace.
>
> 25.73% libtcmalloc.so.4.1.2 [.] tcmalloc::CentralFreeList::FetchFromSpans()
> 12.52% libtcmalloc.so.4.1.2 [.] tcmalloc::ThreadCache::ReleaseToCentralCache(tcmalloc::ThreadCache::FreeList*, unsigned long, int)
> 11.62% libtcmalloc.so.4.1.2 [.] tcmalloc::CentralFreeList::ReleaseToSpans(void*)
> 1.56% [kernel] [k] __copy_user_nocache
> 1.44% libtcmalloc.so.4.1.2 [.] tcmalloc::CentralFreeList::RemoveRange(void*, void*, int)
> 1.39% libtcmalloc.so.4.1.2 [.] tcmalloc::CentralFreeList::ReleaseListToSpans(void*)
> 0.89% libtcmalloc.so.4.1.2 [.] operator new(unsigned long)
>
>
> The TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES is alleviating that but the env variable setting for this is a noop in the binary we are having in Ubuntu 14.04. It is fixed in gperftools-2.1.90 release.
> See the following link.
>
> http://code.google.com/p/gperftools/
>
> We can request Ubuntu guys to incorporate this version or the latest tcmalloc version which is gperftools-2.4.
>
> It will be really helpful if you can push them to incorporate this in 14.04 updates.
>
> Thanks & Regards
> Somnath

Revision history for this message
James Page (james-page) wrote : Re: tcmalloc performance degredation over time

vivid has 2.2.1 - marking Fix Released.

summary: - Performance regredation over time
+ tcmalloc performance degredation over time
Changed in google-perftools (Ubuntu Vivid):
status: New → Fix Released
Changed in google-perftools (Ubuntu Trusty):
importance: Undecided → High
status: New → Triaged
Changed in google-perftools (Ubuntu Vivid):
importance: Undecided → High
Revision history for this message
James Page (james-page) wrote :

From the upstream bug:

What steps will reproduce the problem?
1. export TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=1000000000
2. run program A with -ltcmalloc
3. check memory used by program A

ps: A is a multithread program(with 80+ threads) which alloc/free memory repeatedly

What is the expected output?
program A eat 1G memory
What do you see instead?
program A eat 32M

Changed in google-perftools (Ubuntu Trusty):
status: Triaged → In Progress
assignee: nobody → James Page (james-page)
Revision history for this message
James Page (james-page) wrote :

I've shoved the proposed patched version of gperftools into:

https://launchpad.net/~james-page/+archive/ubuntu/ceph-sru

Revision history for this message
Chaitanya Huilgol (chaitanya-huilgol) wrote :

Please find source of the test program to verify this bug at

http://pastebin.com/KAxQZARm

compile it with -ltcmalloc
To test:
Export a non-default value of the cache size, for eg # export TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=67108864
Run the test prog, For the buggy version you will see

Tcmalloc BUG! TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES: 67108864 Internal Size: 33554432 different

With the bug fixed, you should see

"Tcmalloc Internal and Env cache size are same:67108864"

Revision history for this message
James Page (james-page) wrote :

Thanks Chaitanya

description: updated
summary: - tcmalloc performance degredation over time
+ [SRU] tcmalloc performance degredation over time
Revision history for this message
James Page (james-page) wrote :
description: updated
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello James, or anyone else affected,

Accepted google-perftools into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/google-perftools/2.1-2ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in google-perftools (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote : [google-perftools/trusty] verification still needed

The fix for this bug has been awaiting testing feedback in the -proposed repository for trusty for more than 90 days. Please test this fix and update the bug appropriately with the results. In the event that the fix for this bug is still not verified 15 days from now, the package will be removed from the -proposed repository.

tags: added: removal-candidate
Revision history for this message
Mathew Hodson (mhodson) wrote :

This is fixed with the packages in trusty-proposed.

$ apt list libgoogle-perftools*
Listing... Done
libgoogle-perftools-dev/trusty-proposed,now 2.1-2ubuntu1.1 amd64 [installed]
libgoogle-perftools4/trusty-proposed,now 2.1-2ubuntu1.1 amd64 [installed]
libgoogle-perftools4-dbg/trusty-proposed 2.1-2ubuntu1.1 amd64

$ g++ -o gperftest gperftest.c -ltcmalloc
$ TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=67108864 ./gperftest
Tcmalloc OK! Internal and Env cache size are same:67108864

tags: added: verification-done
removed: removal-candidate verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package google-perftools - 2.1-2ubuntu1.1

---------------
google-perftools (2.1-2ubuntu1.1) trusty-proposed; urgency=medium

  * d/p/TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES.patch: Cherry pick fix from
    upstream VCS to allow total thread cache size to be overridden using an
    environment variable, allowing tcmalloc cpu burden when under memory
    pressure to be reduced (LP: #1439277).
 -- James Page <email address hidden> Thu, 09 Apr 2015 14:36:52 +0100

Changed in google-perftools (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for google-perftools has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.