[SERVER-6758] cpu profiler doesn't work with embedded tcmalloc Created: 13/Aug/12  Updated: 11/Jul/16  Resolved: 27/Nov/12

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 2.3.2

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Either --use-cpu-profiler should imply --use-system-tcmalloc or it should use the embedded copy of gperftools, and possibly build a copy of pprof.



 Comments   
Comment by Githook User [ 21/May/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-8995 added gperftools-2.2 generated headers and SConscript files. cpu-profiler build tweaks.

config-10gen_macos.h:

  • generated by: ./configure
  • disabled HAVE_LIBUNWIND_H

config-10gen_linux.h:

  • generated by: ./configure --enable-minimal
  • applied config-10gen_linux.h changes made in src/gperftools-2.0/src/config-10gen_linux.h in commit eee3fe4ce66c7bbda9329a3c8bd8e3549b07437c:
    SERVER-4683 Support the imported tcmalloc, ystem tcmalloc or the default system allocator library.
    Pass --allocator=tcmalloc (default on Linux) or --allocator=system (default elsewhere)
    to control which allocator is used, and -use-system-tcmalloc to use the system
    installed tcmalloc instead of the one in the mongo source tree if you use --allocator=tcmalloc.
  • applied config-10gen_linux.h changes made in src/gperftools-2.0/src/config-10gen_linux.h in commit 498d9102e00e61ca2d41b7db1448969728884b50:
    SERVER-6758 - use third_party profiler when using --use-cpu-profiler
    does require libunwind installed on system

SCons --use-cpu-profiler changes:

Comment by Eliot Horowitz (Inactive) [ 27/Nov/12 ]

Note, this does require libunwind installed on system.

Comment by auto [ 27/Nov/12 ]

Author:

{u'date': u'2012-11-27T19:26:07Z', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

Message: SERVER-6758 - use third_party profiler when using --use-cpu-profiler
does require libunwind installed on system
Branch: master
https://github.com/mongodb/mongo/commit/498d9102e00e61ca2d41b7db1448969728884b50

Comment by John Hinsdale [ 24/Oct/12 ]

Not sure there is a 100% hard dependency on libunwind to use the profiler, at least the CPU profiler. FWIW, I was able to build mongo from source (on x86_64) with "-use-cpu-profiler" but without a depend on libunwind. Following the advice in the README/INSTALL files that come with gperftools 2.0, I used gperftools' built-in unwind facility by (1) building gperftools with "-enable-frame-pointers" and (2) tweaked the mongo build script to compile mongo code with "-fno-omit-frame-pointer" when --use-cpu-profiler was on. This was the only way I was able to get reliable call-graph profiles to work on my system.

Perhaps mongo distros that bundle gperftools could set all the flags to work in harmony for the different packages' compiles, based on the detected presence/absence (and/or explicitly directed use/nonuse) of libunwind.

The gperftools docs seem to imply that all these unwind issues relate only to the profilers and not to tcmalloc, but I may have misread that. I imagine there is a very big "YMMV" for all this

Comment by Andy Schwerin [ 14/Aug/12 ]

FYI, pprof is a script (python or perl), so we just need to drop it in the source tree if we go this route.

The profilers imply a dependency on libunwind, which is why we didn't build support for them into the tcmalloc we link by default. Extending the build system to be able to build the tcmalloc version with profiling support seems like a reasonable approach.

Generated at Thu Feb 08 03:12:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.