Commit Graph

657 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
4a13598319 renamed ChangeLog to ChangeLog.old
I.e. to avoid confusion. This should fix issue #796.
2016-06-25 16:12:52 -07:00
Aliaksey Kandratsenka
7852eeb75b Use initial-exec tls for libunwind's recursion flag
If we don't do it, then reading variable calls to __tls_get_addr, which
uses malloc on first call. initial-exec makes dynamic linker reserve tls
offset for recusion flag early and thus avoid unsafe calls to malloc.

This fixes issue #786.
2016-04-09 13:09:18 -07:00
Mike Gaffney
a07f9fe75a gerftools -> gperftools in readme 2016-03-31 11:27:21 -07:00
Aliaksey Kandratsenka
9fd6d26879 added define to enable MADV_FREE usage on Linux
Building with -DTCMALLOC_USE_MADV_FREE will enable usage of MADV_FREE on
Linux if glibc copy of kernel headers has MADV_FREE defined.

I.e. so that people can test this more easily.

Affects ticket #780.
2016-03-20 12:30:54 -07:00
Mathias Stearn
6f7a14f45e Don't use MADV_FREE on Linux
Addresses #780.
2016-03-16 18:22:32 -04:00
Aman Gupta
55cf6e6281 Fix symbol resolution on OSX
The library mapping ranges on OSX and Linux are sorted in opposite orders

  7f71c3323000-7f71c3339000 r-xp 00000000 09:02 29099128                   /lib/x86_64-linux-gnu/libz.so.1.2.3.4
  7f71c3339000-7f71c3538000 ---p 00016000 09:02 29099128                   /lib/x86_64-linux-gnu/libz.so.1.2.3.4
  7f71c3538000-7f71c3539000 r--p 00015000 09:02 29099128                   /lib/x86_64-linux-gnu/libz.so.1.2.3.4
  7f71c3539000-7f71c353a000 rw-p 00016000 09:02 29099128                   /lib/x86_64-linux-gnu/libz.so.1.2.3.4

vs

  108f8d000-108f95000 r-xp 00025000 00:00 0           /usr/local/opt/libmemcached/lib/libmemcached.11.dylib
  108f8c000-108f8d000 r-xp 00024000 00:00 0           /usr/local/opt/libmemcached/lib/libmemcached.11.dylib
  108f68000-108f8c000 r-xp 00000000 00:00 0           /usr/local/opt/libmemcached/lib/libmemcached.11.dylib
2016-03-14 12:20:45 -07:00
Aliaksey Kandratsenka
8e85843622 added simple .travis.yml config 2016-03-13 15:54:20 -07:00
Brian Silverman
05e40d29c0 Recognize modern Linux ARM
Commit e580d78881 fixed the macros in some
of the code but not other places.

`make check` still fails in the same places on a Debian Jessie armhf
system.
2016-03-12 13:05:20 -08:00
Aliaksey Kandratsenka
632de2975e bumped version up to 2.5 2016-03-12 11:59:05 -08:00
Aliaksey Kandratsenka
6682016092 Unbreak profiling with CPUPROFILE_FREQUENCY=1
This closes ticket #777.

No test sadly, since it's not trivial to unittest this case. But
fix with single-shot manual testing is better than nothing.
2016-03-12 10:55:42 -08:00
Aliaksey Kandratsenka
6ff86ff6a7 bumped version to 2.4.91 for 2.5rc2 2016-03-05 17:12:04 -08:00
Aliaksey Kandratsenka
782165fa7f build sized delete aliases even when sized-delete is disabled
In this case we alias to regular delete. This is helpful because if we
don't override sized delete, then apps will call version in libstdc++
which delegates calls to regular delete, which is slower than calling
regular delete directly.
2016-03-05 17:12:04 -08:00
Aliaksey Kandratsenka
06811b3ae4 disable dynamic sized delete support by default
IFUNC relocations don't support our advanced use case (calling
application function or looking up environment variable).

Particularly, it doesn't work on PPC and arm when tcmalloc is linked
with -Wl,-z,now. See RedHat's bugzilla ticket
https://bugzilla.redhat.com/show_bug.cgi?id=1312462 for more details.
2016-03-05 17:11:39 -08:00
Aliaksey Kandratsenka
d4d99eb608 unbreak compilation with visual studio
Specifically, this commit adds missing fake_stacktrace_scope.cc to msvc
build and removes undef-ing of PERFTOOLS_DLL_DECL by tcmalloc.h.
2016-03-05 17:11:39 -08:00
Brian Silverman
126d4582c1 Call function pointers with the right type
I think it's undefined behavior, but it's definitely weird. ubsan
complains too.
2016-03-05 20:00:39 -05:00
Brian Silverman
e0fa28ef7d Don't shift a type by more than its width
It's undefined behavior, so ubsan complains.
2016-03-01 17:59:39 -05:00
Brian Silverman
a1c764d263 Initialize counters in test 2016-03-01 17:59:39 -05:00
Brian Silverman
22123a37c2 Don't overflow a signed integer
It's undefined behavior and ubsan catches it.
2016-03-01 17:59:08 -05:00
Aliaksey Kandratsenka
66e1e94f38 added minimal "header section" to README 2016-02-29 20:09:39 -08:00
Aliaksey Kandratsenka
2804b7cfee bumped version to 2.5rc 2016-02-21 23:09:15 -08:00
Aliaksey Kandratsenka
f47fefbfc1 updated NEWS for 2.5rc 2016-02-21 23:09:15 -08:00
Aliaksey Kandratsenka
cef6036174 alias same malloc/free variants to their canonical versions
This is similar to what gcc 5 does anyways, except gcc 5 is placing
jumps which adds a bit of overhead.

Instead of letting gcc do it, we alias using ELF symbol aliasing. All
free variants (tc_delete{,array}_{,nothrow}) are aliased to
tc_free. There are 3 malloc variants that differ by oom
handling. tc_newarray is aliased to tc_new. And tc_newarray_nothrow is
aliased to tc_new_nothrow.

This aliasing only happens in non-debug malloc, since debug malloc does
distinguish between different variants since it needs checking for
mismatch.
2016-02-21 23:09:15 -08:00
Aliaksey Kandratsenka
ea8d242061 Re-enable MultipleIdleNonIdlePhases test
Which was accidentally removed as part of MarkThreadTemporarilyIdle
support.
2016-02-21 20:16:37 -08:00
Aliaksey Kandratsenka
c9962f698b added maybe_emergency_malloc.h to Makefile.am
Because without this reference it isn't packaged by make dist.
2016-02-21 20:07:37 -08:00
Aliaksey Kandratsenka
7dd4af6536 don't round up sizes for large allocation when sampling
This closes #723.

Since rounding up prior to sampling is introducing possibility of
arithmetic overflow, we're just not doing it.

It introduces some error (up to 4k), but since we're dealing with at
least 256k allocations, we're fine.
2016-02-21 19:26:37 -08:00
Aliaksey Kandratsenka
4f3410e759 enable emergency malloc by default on arm when using libunwind
Because by default libunwind on arm does fopen which mallocs which will
deadlock unless we enable emergency malloc.
2016-02-21 13:57:27 -08:00
Aliaksey Kandratsenka
7f12051dbe implemented emergency malloc
Emergency malloc is enabled for cases when backtrace capturing needs to
call malloc. In this case, we enable emergency malloc just prior to
calling such code and disable it after it is done.
2016-02-21 10:53:45 -08:00
Aliaksey Kandratsenka
3ee2360250 replaced invalid uses of __THROW
We're now using it only when overriding glibc functions (such as malloc
or mmap). In other cases (most importantly in public tcmalloc.h header)
we're doing our own throw() to avoid possible breakage on future glibc
changes.
2016-02-20 22:13:07 -08:00
Aliaksey Kandratsenka
013b82abcf unbreak <malloc.h> inclusion in gperftools/tcmalloc.h
We have shipped header which checked HAVE_XXX defines which we only
defined in project-local config.h. So it could never work correctly.

We're now doing #include <malloc.h> just like tc_mallinfo on constant
which we detect at configure time and write into header that we install.
2016-02-20 22:07:48 -08:00
Aliaksey Kandratsenka
19903e6f15 drop detection of sys/malloc.h and malloc/malloc.h
Which we don't really need.
2016-02-20 22:07:48 -08:00
Aliaksey Kandratsenka
cdff090ebd Fix several harmless clang warnings 2016-02-20 22:07:26 -08:00
Aliaksey Kandratsenka
9095ed0840 implemented stacktrace capturing via libgcc's C++ ABI function
Particularly _Unwind_Backtrace which seems to be gcc extension.

This is what glibc's backtrace is commonly is using.

Using _Unwind_Backtrace directly is better than glibc's backtrace, since
it doesn't call into dlopen. While glibc does dlopen when it is built as
shared library apparently to avoid link-time dependency on libgcc_s.so
2016-02-20 20:34:50 -08:00
Aliaksey Kandratsenka
728cbe1021 force profiler_unittest to do 'real' work
'XOR loop' in profiler unittest wasn't 100% effective because it allowed
compiler to avoid loading and storing to memory.

After marking result variable as volatile, we're now forcing compiler to
read and write memory, slowing this loops down sufficiently. And
profiler_unittest is now passing more consistently.

Closes #628
2016-02-20 13:21:47 -08:00
Aliaksey Kandratsenka
fff6b4fb88 Extend low-level allocator to support custom pages allocator 2016-02-06 19:14:23 -08:00
Aliaksey Kandratsenka
32d9926795 added malloc_bench_shared_full 2016-02-06 19:14:23 -08:00
Aliaksey Kandratsenka
00d8fa1ef8 always use real throw() on operators new/delete
Since non-glibc-s have no __THROW and lack of throw() on operators gives
us warning.
2016-02-06 19:13:07 -08:00
Aliaksey Kandratsenka
08e034ad59 Detect working ifunc before enabling dynamic sized delete support
Particularly, on arm-linux and x86-64-debian-kfreebsd compilation fails
due to lack of support for ifunc. So it is necessary to test at
configure time whether ifunc is supported.
2016-02-06 16:21:53 -08:00
Aliaksey Kandratsenka
a788f354a0 include unistd.h for getpid in thread_lister.c
This fixes warning produced on arm-linux.
2016-02-06 16:21:53 -08:00
Bryan Chan
644a6bdbdb Add support for Linux s390x
This resolves gperftools/gperftools#761.
2016-02-04 20:15:26 -05:00
Bryan Chan
bab7753aad Fix typo in heap-checker-death_unittest.sh 2016-02-04 18:34:43 -05:00
Simon Que
17182e1d3c Fix include of malloc_hook_c.h in malloc_hook.h
malloc_hook.h includes malloc_hook_c.h as <gperftools/malloc_hook_c.h>.
This requires the compiler to have designated src/gperftools as a
standard include directory (-I), which may not always be the case.

Instead, include it as "malloc_hook_c.h", which will search in the same
directory first. This will always work, regardless of whether it was
designated a standard include directory.
2016-01-29 18:17:16 -08:00
Andrew Morrow
c69721b2b2 Add support for obtaining cache size of the current thread and softer idling 2016-01-26 19:44:16 -08:00
Brian Silverman
5ce42e535d Don't always arm the profiling timer.
It causes a noticeable performance hit and can sometimes confuse GDB.

Tested with CPUPROFILE_PER_THREAD_TIMERS=1.

Based on an old version by mnissler@google.com.
2016-01-26 18:31:42 -08:00
Duncan Sands
7f801ea091 Make sure the alias is not removed by link-time optimization when it can prove
that it isn't used by the program, as it might still be needed to override the
corresponding symbol in shared libraries (or inline assembler for that matter).
For example, suppose the program uses malloc and free but not calloc and is
statically linked against tcmalloc (built with -flto) and LTO is done.  Then
before this patch the calloc alias would be deleted by LTO due to not being
used, but the malloc/free aliases would be kept because they are used by the
program.  Suppose the program is dynamically linked with a shared library that
allocates memory using calloc and later frees it by calling free.  Then calloc
will use the libc memory allocator, because the calloc alias was deleted, but
free will call into tcmalloc, resulting in a crash.
2016-01-24 19:49:52 -08:00
Aliaksey Kandratsenka
6b3e6ef5e0 don't retain compatibility with old docdir behavior
Since it is not really needed. And since we don't care about too ancient
autoconfs.
2016-01-24 19:45:16 -08:00
Chris Mayo
ccffcbd9e9 support use of configure --docdir argument
Value of docdir was being overridden in Makefile.

Retain compatibility with old Autoconf versions that do not provide
docdir.
2015-12-27 18:55:05 +00:00
Aliaksey Kandratsenka
050f2d28be use alias attribute only for elf platforms
It was reported that clang on OSX doesn't support alias attribute. Most
likely because of executable format limitations.

New code limits use of alias to gcc-compatible compilers on elf
platforms (various gnu and *bsd systems). Elf format is known to support
aliases.
2015-12-12 18:27:56 -08:00
cyshi
07b0b21ddd fix compilation error in spinlock 2015-12-02 14:47:15 +08:00
gshirishfree
e14450366a Added better description for GetStats API 2015-11-23 11:34:13 -08:00
Aliaksey Kandratsenka
64892ae730 lower default transfer batch size down to 512
Some workloads get much slower with too large batch size.

This closes bug #678.

binary_trees benchmark benefits from larger batch size. And I found that
512 is not much slower than huge value that we had.
2015-11-21 19:22:49 -08:00