Commit Graph

203 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka 144c118f92 drop outdated comment in Makefile.am 2024-02-04 23:42:58 -05:00
Aliaksey Kandratsenka e262ebc741 ship everything under vsprojects/ in make dist
We also drop all those WINDOWS_PROJECTS amends and simplify makefile.
2024-02-04 23:38:18 -05:00
Aliaksey Kandratsenka b49920ea64 don't bother listing every header in Makefile.am
For compiling things automake never needs to be given a full set of
headers. Usually headers are specified so that make dist includes them
into archive, but we can achieve this goal easier.

This reduces size and complexity of our Makefile.am stuff.
2024-02-04 23:20:35 -05:00
Aliaksey Kandratsenka 1331c0e0d1 drop long deprecated google/ headers 2024-02-04 21:54:46 -05:00
Aliaksey Kandratsenka 2e5ecb4de6 amputate src/base/simple_mutex.h
Use standard mutex instead
2024-02-04 16:38:21 -05:00
Aliaksey Kandratsenka 21e66f807c enable -Wthread-safety for clang 2024-02-04 13:37:53 -05:00
Aliaksey Kandratsenka 6691226953 split and rewrite TLS access for thread caches
Logic was removed from thread_cache.{h,cc} into
thread_cache_ptr.{h,cc}.

Separation will help possible future evolution, and we already changed
the logic quite a bit:

* early access (when TLS isn't initialized yet) now uses global
ThreadCache instance. We therefore have ThreadCachePtr instances
managing required locking. This eliminates unnecessary complication of
PTHREADS_CRASHES_IF_RUN_TOO_EARLY logic, and any other danger of
touching TLS too early. BTW previous implementation actually leaked
initial early-initialized ThreadCache instance(!)

* old configure-time HAVE_TLS logic is amputated. Config-time part of
it made little sense as C++ 17 guarantees availability of
thread_local, but we have manually curated deny-list of "bad" OSes,
that we tested (via compile checks!) at configure time. Now this
is all compile time. There is now compile-time kHaveGoodTLS variable
and we're using it mostly via if constexpr.

* kHaveGoodTLS case of creating thread cache is simplified and made
more straightforward (no need to have in_setspecific logic).

* !kHaveGoodTLS case if fixed and improved too. We avoid
std:🧵:get_id, as it deadlocks on mingw. We use errno address as
a portable and (usually) async-signal safe 'my thread' identifier. We
also eliminate linear searching of thread's cache and replace it with
straightforward hash table lookup.
2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka 51d3340b39 avoid -Wunused-results warnings from read/write
glibc with _FORTIFY_SOURCE sets those up to give warnings on unused
results. We used to disable this warning globally, but lets do better.
2024-01-30 17:08:29 -05:00
Aliaksey Kandratsenka 82a36a6fcd bump required c++ standard to c++-17 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka 5db2adc4e7 drop stale workaround for ancient solaris issue 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka a3080fa8d6 extract proc-maps iteration into own file and cover it by tests
This allows us, later, to avoid building this stuff in configurations
that don't use it. I have also reduced API and ABI surface to enable
further refactorings.
2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka 3e328e4058 unbreak make dist 2024-01-29 20:16:39 -05:00
lennoxho 9a6848de8a A number of cleanups
* Remove build dependency on HAVE_PTHREAD
* Remove build dependency on HAVE_STD_ALIGNED_VAL_T and ENABLE_ALIGNED_NEW_DELETE
* Remove redundant tcmalloc.h files & ensure there are no cross-build-tool references
* Adopt automake commit 26927d1 in the CMake build
2024-01-29 17:15:53 -08:00
lennoxho 96f34120fe Several build fixes and cleanups
- Fix CMake builds for MinGW and MSVC
- Ensure the Autotools, CMake and VSProj builds do not reference each others' config.h
- Use std:🧵:id instead of our own thread ID wrappers
- Moved explicit TLS wrapper functions into the tcmalloc:: namespace and change their visibility to hidden
Resolves #1486
2024-01-26 16:56:17 -05:00
lennoxho 5cab8f3f77 Convert MinGW builds to always use WinAPI based threading facilities. See ##1483 2024-01-24 21:47:06 -05:00
Aliaksey Kandratsenka 24774ebb38 introduce generic_writer facility 2024-01-24 17:30:18 -05:00
Aliaksey Kandratsenka 5abc572130 move dynamic_annotations.cc under libsysinfo.la
See github issue #1474 for immediate reason.

Note, this entire idea of number of convenience libraries is likely
simply artifact of Google's codebase past. We don't really need this
complexity. But I am holding big reorganization of this for after API
and ABI work. For now, simply moving dynamic_annotations.cc into
libsysinfo fixes things. Most of the code links both anyways. So lets
just do it.
2024-01-04 19:35:47 -05:00
Aliaksey Kandratsenka f17d54df5c add recently added getpc-inl.h to a set of headers to package 2023-12-31 23:17:03 -05:00
Mateusz Jakub Fila b8e75ae6fe Add mallinfo2 function 2023-12-07 14:10:51 +01:00
Aliaksey Kandratsenka 4d1a9e9226 stacktrace_unittest: test all stacktrace capturing methods 2023-10-27 19:06:15 -04:00
Lennox Ho 589d416977 Add a more performant SpinLockDelay implementation for Windows based on WaitOnAddress and friends 2023-09-19 14:53:16 +08:00
Aliaksey Kandratsenka 523b72f754 make sampling_debug_test actually test debug malloc
We do shell wrapper for actual test run, so we can inspect output of
pprof. But when we set up sampling_debug_test.sh we simply copied
regular sampling_test.sh, which ran same non-debug test binary. Now we
sed-replace contents of shell program when copying, so we test right
binary.

Another thing we fix here is our (still hardcoded) test output path is
now different between sampling{,_debug}_test.sh. So this fixes main
cause of flakiness of our unit tests.
2023-09-10 18:14:57 -04:00
Aliaksey Kandratsenka 2748dd5680 unbreak address access "probing" for generic_fp backtracing
We used msync to verify that address is readable. But msync gives
false positives for PROT_NONE mappings. And we recently got bug report
from user hitting this exact condition.

For correct access check, we steal idea from Abseil and do sigprocmask
with address used as new signal mask and with invalid HOW
argument. This works in today's Linux kernels and is among fastest
methods available. But is brittle w.r.t. possible kernel changes. So
we supply fallback method that does 2 syscalls.

For non-Linux systems we implement usual "write to pipe" trick. Which
also has decent performance, but requires occasional pipe draining and
uses fds which could occasionally be damaged by some forking codes.

We also finally cover all new code with unit test.

Fixes github issue #1426
2023-09-10 17:24:32 -04:00
Aliaksey Kandratsenka 8d634c1f56 don't build mmap_hook when --enable-minimal is given to configure
Refers to github issue #1418
2023-08-24 14:06:25 -04:00
Brett T. Warden b4ad04982d Set Description field in generated pkg-config files (instead of Summary)
Fixes #1416
2023-08-22 18:09:33 -04:00
Aliaksey Kandratsenka dbd1071680 link libprofiler with pthread
This unbreaks building on older Linux distros. We missed this at
46d3315ad7 when dropped maybe_thread
stuff, since libprofiler indeed uses pthread, and because on newer
libc-s pthread stuff is now part of regular libc.so.

I am also dropping bogus LIBPROFILER stuff referring to some rpath
badness. Unsure what it was, maybe way back we did libstacktrace as a
proper libtool library, so maybe something was needed. But it is just
a convenience archive this days, so we don't really need to add it
everywhere libprofiler.la is linked.
2023-08-09 23:57:06 -04:00
Aliaksey Kandratsenka 51c5e2bec7 massage latest GetUniquePathFromEnv changes
This fixes a number of minor bits (like build details) as well as
making overall code style similar to what we're doing elsewhere.
2023-08-09 16:29:13 -04:00
Artem Polyakov 86450ad99f Add unit test for GetUniquePathFromEnv()
Signed-off-by: Artem Polyakov <artpol84@gmail.com>
2023-08-08 16:44:18 -07:00
Aliaksey Kandratsenka 862039c185 don't -momit-leaf-frame-pointer when asked for full frame pointers 2023-08-06 14:44:05 -04:00
Aliaksey Kandratsenka a51e08b06a drop obsolete TODO file 2023-07-31 15:40:13 -04:00
Aliaksey Kandratsenka 1ff09a680e drop obsolete deb/rpm packaging stuff 2023-07-31 14:28:40 -04:00
Aliaksey Kandratsenka b6cdd8f510 [mingw] dont add libstacktrace to libtcmalloc_minimal
There was this piece of makefile with indention to add stack tracing
functionality (for stuff like growthz, GetCallerStackTrace and
probably heap sampling) to work even in minimal configuration on
mingw.

What is odd is we fail to actually define libstacktrace.la target on
mingw, since libstacktrace.la requires WITH_STACK_TRACE automake
conditional which we don't enable on this platform. And yet somehow it
doesn't fail. It produces empty libstacktrace.la, so build kinda
works. Except at least on my machine it produces racy makefiles. So
lets not pretend and stop breaking our parallel builds.
2023-07-27 19:27:42 -04:00
Aliaksey Kandratsenka 8be84e4a5c drop old mmap hooks and introduce internal & simpler mmap_hook.h
Previous implementation wasn't entirely safe w.r.t. 32-bit off_t
systems. Specifically around mmap replacement hook. Also, API was a
lot more general and broad than we actually need.

Sadly, old mmap hooks API was shipped with our public headers. But
thankfully it appears to be unused externally (checked via github
search). So we keep this old API and ABI for the sake of formal API
and ABI compatibility. But this old API is now empty and always
fails (some OS/hardware combinations didn't have functional
implementations of those hooks anyways).

New API is 64-bit clean and only provides us with what we need. Namely
being able to react to virtual address space mapping changes for
logging, heap profiling and heap leak checker. I.e. no pre hooks or
mmap-replacement hooks. We also explicitly not ship this API
externally to give us freedom to change it.

New code is also hopefully tidier and slightly more portable. At least
there are fewer arch-specific ifdef-s.

Another somewhat notable change is, since mmap hook isn't needed in
"minimal" configuration, we now don't override system's
mmap/munmap/etc functions in this configuration. No big deal, but it
reduces risk of damage if we somehow mess those up. I.e. musl's mmap
does few things that our mmap replacement doesn't, such as very fancy
vm_lock thingy. Which doesn't look critical, but is good thing for us
not to interfere with when not necessary.

Fixes issue #1406 and issue #1407. Lets also mention issue #1010 which
is somewhat relevant.
2023-07-21 16:13:19 -04:00
Aliaksey Kandratsenka 46d3315ad7 amputate maybe_threads
This facility allowed us to build tcmalloc without linking in actual
-lpthread. Via weak symbols we checked at runtime if pthread functions
are available and if not, special single-threaded stubs were used
instead. Not always brining in pthread dependency helped performance
of some programs or libraries which depended at runtime on whether
threads are linked or not. Most notable of those are libstdc++ which
uses non-atomic refcounting on single threaded programs.

But such optional dependency on pthreads caused complications for
nearly no benefit. One trouble was reported in github issue #1110.

This days glibc/libstdc++ combo actually depends on
sys/single_threaded.h facility. So bringing pthread at runtime is
fine. Also modern glibc ships pthread symbols inside libc anyways and
libpthread is empty. I also found that for whatever reason on BSDs and
osx we already pulled in proper pthreads too.

So we loose nothing and we get issue #1110 fixed. And we simplify
everything.
2023-07-14 03:07:16 -04:00
Chris Cambly 2d70ea9ad2 initial batch of changes to enable AIX in 32-bit and 64-bit
- Some small automake changes. Add libc++ for AIX instead of libstdc++
- Add the interface changes for AIX:User-defined malloc replacement
- Add code to avoid use of pthreads library prior to its initialization
- Some small changes to the unittest case
- Update INSTALL for AIX

[alkondratenko@gmail.com]: lower-case/de-trailing-dot for commit subject line
[alkondratenko@gmail.com]: rebase
[alkondratenko@gmail.com]: amputate unused AM_CONDITIONAL for AIX
[alkondratenko@gmail.com]: explicitly mention libc_override_aix.h in Makefile.am
2023-07-09 16:52:20 -04:00
Aliaksey Kandratsenka 26927d1333 clean up unused link dependencies for malloc_extension_c_test
We used to explicitly link to libstdc++, libm and even libpthread, but
this should be handled by libtool since those are dependencies of
libtcmalloc_minimal. What also helps is we now build everything with
C++ compiler, not C. So libstdc++ or (libc++) dependency doesn't need
to be added at all, even if libtool for some reason fails to handle
it.
2023-07-09 16:11:51 -04:00
Aliaksey Kandratsenka f15425dc99 implement SafeStrError and use it inside strerror
This fixes issue #1371

From time to time things file inside tcmalloc guts where calling to
malloc is not safe. Regular strerror does locale bits, so will
occasionally open files/malloc/etc. We avoid this by using our own
"safe" variant that hardcodes names of all POSIX errno constants.
2023-07-03 18:14:05 -04:00
Aliaksey Kandratsenka 88d0fd5a3b remove dead remains of arm_instruction_set_select header 2023-07-03 17:29:13 -04:00
Aliaksey Kandratsenka dd89dc7d01 install compat headers and .pc files only with matching libs
Thix closes issue #1356
2023-07-03 15:29:56 -04:00
Aliaksey Kandratsenka 972c12f77d refactor stacktrace.cc and drop x86 backtracer
We had plenty of old and mostly no more correct i386 cruft. Now that
generic_fp backtracer covers i386 just fine, we can drop explicit x86
backtracer.

With that we refactored and simplified stacktrace.cc mostly around
picking default implementation, but also adding few more minor
cleanups.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 4b78ffd03c try building with -fno-omit-frame-pointer -momit-leaf-frame-pointer
The idea is -momit-leaf-frame-pointer gives us performance pretty much
same as fully omitting frame pointers. And having frame pointers
elsewhere allows us to support cases when user's code is built with
frame pointers. We also pass all tests with
TCMALLOC_STACKTRACE_METHOD=generic_fp (not just libunwind or libgcc).
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka e5ac219780 restore unwind-bench
We previously deleted it, since it wasn't portable enough. But
unportable bits are now ifdef-ed out, so we can return it.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 25698cd1b8 improve diagnostics for stacktrace_unittest 2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 88d7e65cc2 drop unused libtool target in our Makefile.am
Not sure what it was for, but it is not useful today.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 7ffd35a54b correctly detect and link to backtrace_symbols
BSDs need -lexecinfo
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 7dd1b82378 simplify project by making it C++-only
I.e. no need for any AC_LANG_PUSH stuff in configure. Most usefully,
only CXXFLAGS needs to be set now when you need to tweak compile
flags.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka cf28e03567 correctly order weakening step to avoid race
Previously we allowed test programs to be linked at the same time as
weakening is performed, rewriting the .a archives. So lets be more
explicit. We weaken after all-am (which "runs" everything including
libraries and programs), but before all target.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka a39073886a unbreak symbol weakening
It is kinda minor feature, and apparently we never had it working. But
is a nice to have. Allows our users to override malloc/free/etc while
still being able to link to us (for tc_malloc for example). With
broken weakening we had this use-case broken for static library
case. And it should now work.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 630dac81ea implement simpler ChangeLog generation for source tarballs
We used ax_generate_changelog which works great. But it made our
makefile require GNU make, which was causing annoyance on bsd systems.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka e78238d94d reworked heap leak checker for more portability
In most practical terms, this expands "official" heap leak checker
support to Linux/arm64 and Linux/riscv (mips-en and legacy arm are
likely to work & pass tests too now).

The code is now explicitly Linux-only, without trying to pretend
otherwise. Main goal of this change is to finally amputate
linux_syscall_support.h, which we historically had trouble maintaining
well. Biggest challenge was around thread listing facility which uses
clone (ptrace explicitly fails between threads) and that causes
difficulties around parent and child tasks sharing
errno. linux_syscall_support stuff had special feature to "redirect"
errno accesses. But it caused us for more trouble. We switched to
regular syscalls, and errno stamping avoidance is now simply via
careful programming.

A number of other cleanups is made (such us thread finding codes in
procfs which clearly was built for some ages old and odd kernels).

sem_post/sem_wait synchronization was previously potentially prone to
deadlock (if parent died at bad time). We now use pipe pair for this
synchronization and it is fully robust.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 2186967987 fix heap checker unittest
We had shell wrapper for heap checker unittest, but it failed to deal
with heap-checker-debug variant. So we now posix_spawn from .cc test
instead.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka 54605b8a58 amputate old atomic ops implementation 2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka e80652b627 ship cmake bits with tar.gz distribution
Fixes issue #1321.
2022-01-14 23:08:57 -08:00
Aliaksey Kandratsenka c939dd5531 correctly check sized delete hint when asserts are on
We previously tested wrong assumption that larger than page size size
classes have addresses aligned on page size. New code is making proper
check of size class.

Also added is unit test coverage for this previously failing
condition. And we now also run "assert-ful" unittests for big tcmalloc
too, not only tcmalloc_minimal configuration.

This fixes github issue #1254
2021-02-28 15:54:22 -08:00
Aliaksey Kandratsenka f4aa2a435e implement generic frame pointer backtracer
This supports frame pointer backtracing on x86-64, aarch64 and
riscv-s (should work for both 32 and 64 bits).

Also added is detection of borked libunwind on aarch64-s. In this case
frame pointer unwinder is preferred.
2021-02-14 22:11:09 -08:00
Aliaksey Kandratsenka 17bab484ae always respect --enable-frame-pointers
Previously it only was respected on x86_64, but this days lots of modern
ABIs are without frame pointers by default (e.g. arm64 and riscv, and
even older mips).
2021-02-14 16:44:28 -08:00
Aliaksey Kandratsenka 419c85814d amputate unused dynamic annotations support 2021-02-14 16:09:17 -08:00
Aliaksey Kandratsenka 180bfa10d7 bumped version to 2.8 2020-07-06 02:51:43 -07:00
Aliaksey Kandratsenka 50f89afaed liberate gperftools tests from relying on -fno-builtin-XXX flags
Clang mostly ignores those anyways, so our tests needed better way to
disable optimizations (clang is quite aggressive replacing new/delete
pair with stack allocation).
2020-07-06 00:58:56 -07:00
Aliaksey Kandratsenka e5f77d6485 chmod -x Makefile.am gperftools.sln 2020-03-23 01:22:16 -07:00
Kirill Müller 4cddede399 New ProfilerGetStackTrace() 2020-03-08 23:58:13 -07:00
Aliaksey Kandratsenka 5eec9d0ae3 Drop not very portable and not very useful unwind benchmark. 2018-10-07 08:17:04 -07:00
Aliaksey Kandratsenka 954f9dc0e3 Add flag to disable installing unmaintained & deprecated pprof.
Everyone should be using golang pprof from github.com/google/pprof, but
distros still ship our perl version and not everyone is aware of
better pprof yet.

This is another step in completely dropping perl pprof. We still
default to installing it, but hopefully we'll be able to convince
distros to disable this soon.

We still install pprof under pprof-symbolize name because
stack traces symbolization depends on it, and because golang pprof
won't support this feature.

This is related to issue #1038.
2018-08-26 11:37:59 -07:00
Holy Wu 69867c523b Clean up MSVC projects
1.Remove superfluous per file settings for include directory and runtime library.
2.Remove unnecessary project tcmalloc_minimal_unittest-static. We can simply build libtcmalloc_minimal as a static library and then link against the single .lib file.
3.Add separate configurations of patching and overriding facility for release mode.
2018-08-14 22:34:00 -07:00
Aliaksei Kandratsenka 51a5613f21 Upgrade MSVC projects to MSVC2015 2018-08-05 15:54:00 -07:00
Fabrice Fontaine 30e5e614a8 Fix build without static libraries
Only add -static to malloc_bench_LDFLAGS and binary_trees_LDFLAGS if
ENABLE_STATC is set otherwise build with some compilers will fail if
user has decided to build only the shared version of gperftools
libraries

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-04-29 14:29:16 -07:00
Andrey Semashev 7efb3ecf37 Add support for C++17 operator new/delete for overaligned types.
- Add auto-detection of std::align_val_t presence to configure scripts. This
  indicates that the compiler supports C++17 operator new/delete overloads
  for overaligned types.

- Add auto-detection of -faligned-new compiler option that appeared in gcc 7.
  The option allows the compiler to generate calls to the new operators. It is
  needed for tests.

- Added overrides for the new operators. The overrides are enabled if the
  support for std::align_val_t has been detected. The implementation is mostly
  based on the infrastructure used by memalign, which had to be extended to
  support being used by C++ operators in addition to C functions. In particular,
  the debug version of the library has to distinguish memory allocated by
  memalign from that by operator new. The current implementation of sized
  overaligned delete operators do not make use of the supplied size argument
  except for the debug allocator because it is difficult to calculate the exact
  allocation size that was used to allocate memory with alignment. This can be
  done in the future.

- Removed forward declaration of std::nothrow_t. This was not portable as
  the standard library is not required to provide nothrow_t directly in
  namespace std (it could use e.g. an inline namespace within std). The <new>
  header needs to be included for std::align_val_t anyway.

- Fixed operator delete[] implementation in libc_override_redefine.h.

- Moved TC_ALIAS definition to the beginning of the file in tcmalloc.cc so that
  the macro is defined before its first use in nallocx.

- Added tests to verify the added operators.

[alkondratenko@gmail.com: fixed couple minor warnings, and some
whitespace change]
[alkondratenko@gmail.com: removed addition of TC_ALIAS in debug allocator]
Signed-off-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
2017-11-29 19:51:42 +00:00
Aliaksey Kandratsenka ac072a3fc7 Revert "Ignore current_instance heap allocation when leak sanitizer is enabled"
This reverts commit 70a35422b5.
2017-09-23 14:55:33 -07:00
Aliaksey Kandratsenka fb5987d579 Revert "Ensure that lsan flags are appended on all necessary targets"
This reverts commit a3bf61ca81.
2017-09-23 14:55:20 -07:00
Aliaksey Kandratsenka d406f22853 implement support for C11 aligned_alloc
Just like glibc does, we simply alias it to memalign.
2017-09-16 20:38:44 -07:00
Piotr Sikora 92a27e41a1 Fix build on macOS.
Fixes #910.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-08-21 15:06:23 -07:00
Francis Ricci a3bf61ca81 Ensure that lsan flags are appended on all necessary targets 2017-07-08 13:33:30 -07:00
Francis Ricci 70a35422b5 Ignore current_instance heap allocation when leak sanitizer is enabled
Without this patch, any user program that enables LeakSanitizer will
see a leak from tcmalloc. Add a weak hook to __lsan_ignore_object,
so that if LeakSanitizer is enabled, the allocation can be ignored.
2017-07-04 20:24:47 -07:00
Aliaksey Kandratsenka 5ac82ec5b9 added stacktrace capturing benchmark 2017-05-29 14:57:13 -07:00
Aliaksey Kandratsenka 6d98223a90 don't build with -fno-exceptions
It looks like, in past it could produce better code. But since
unwinding is totally different since almost forever now, there is no
perfomance benefit of it anymore.
2017-05-14 19:04:55 -07:00
Aliaksey Kandratsenka 5c778701d9 added tcmalloc minimal unittest with ASSERTs checked 2017-05-14 19:04:55 -07:00
Aliaksey Kandratsenka 069e3b1655 build malloc_bench_shared_full only when full tcmalloc is built
I.e. because otherwise, when --enable-minimal is given, we're building
empty libtcmalloc.la and linking it to malloc_bench_shared_full. Which
has no effect at all and actually breaks builds on OSX.

Should fix issue #869.
2017-02-20 14:26:54 -08:00
Aliaksey Kandratsenka b8f9d0d44f ported nallocx support from Google-internal tcmalloc
nallocx is extension introduced by jemalloc. It returns effective size
of allocaiton without allocating anything.

We also support MALLOCX_LG_ALIGN flag. But all other jemalloc
flags (which at the moment do nothing for nallocx anyways) are
silently ignored, since there is no sensible way to return errors in
this API.

This was originally contributed by Dmitry Vyukov with input from
Andrew Hunter. But due to significant divergence of Google-internal
and free-software forks of tcmalloc, significant massaging was done by
me. So all bugs are mine.
2016-12-18 12:53:47 -08:00
Kirill Müller 855b380006 replace docs by doc 2016-11-19 15:04:44 -08:00
Aliaksey Kandratsenka db8d483609 Autogenerate ChangeLog from git on make dist
This fixes build breakage introduced in preceding commit for issue #796.
2016-06-25 16:31:29 -07: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 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 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 32d9926795 added malloc_bench_shared_full 2016-02-06 19:14:23 -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 0fb6dd8aa3 added binary_trees benchmark 2015-11-21 18:17:21 -08:00
Aliaksey Kandratsenka 88686972b9 pass -fsized-deallocation to gcc 5
Otherwise it gives warning for declaration of sized delete operator.
2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka 962aa53c55 added more fastpath microbenchmarks
This also makes them output nicer results. I.e. every benchmark is run 3
times and iteration duration is printed for every run.

While this is still very synthetic and unrepresentave of malloc performance
as a whole, it is exercising more situations in tcmalloc fastpath. So it a
step forward.
2015-10-17 20:34:19 -07:00
Aliaksey Kandratsenka 6627f9217d drop cycleclock 2015-10-05 21:00:49 -07:00
Aliaksey Kandratsenka d7fdc3fc9d dropped unused and unsupported synchronization profiling facility
Spinlock usage of cycle counter is due do tracking of time it's spent
waiting for lock. But this tracking is only useful we actually have
synchronization profiling working, which dont have. Thus I'm dropping
calls to this facility with eye towards further removal of cycle clock
usage.
2015-10-05 20:56:28 -07:00
Aliaksey Kandratsenka 4194e485cb Don't link libtcmalloc_minimal.so to libpthread.so
So that LD_PRELOAD-ing doesn't force loading libpthread.so which may
slow down some single-threaded apps.

tcmalloc already has maybe_threads facility that can detect if
libpthread.so is loaded (via weak symbols) and provide 'simulations' of
some pthread functions that tcmalloc needs.
2015-10-05 20:56:28 -07:00
Aliaksey Kandratsenka 64e0133901 added trivial malloc fast-path benchmark
While this is not good representation of real-world production malloc
behavior, it is representative of length (instruction-wise and well as
cycle-wise) of fast-path. So this is better than nothing.
2015-08-02 16:53:19 -07:00
Aliaksey Kandratsenka 1035d5c18f start building malloc_extension_c_test even with static linking
Comment in Makefile.am stating that it doesn't work with static
linking is not accurate anymore.
2014-12-21 19:52:34 -08:00
Aliaksey Kandratsenka 4ace8dbbe2 added subdir-objects automake options
This is suggested by automake itself regarding future-compat.
2014-12-21 18:49:47 -08:00
Aliaksey Kandratsenka 1108d83cf4 implemented cpu-profiling mode that profiles threads separately
Default mode of operation of cpu profiler uses itimer and
SIGPROF. This timer is by definition per-process and no spec defines
which thread is going to receive SIGPROF. And it provides correct
profiles only if we assume that probability of picking threads will be
proportional to cpu time spent by threads.

It is easy to see, that recent Linux (at least on common SMP hardware)
doesn't satisfy that assumption. Quite big skews of SIGPROF ticks
between threads is visible. I.e. I could see as big as 70%/20%
division instead of 50%/50% for pair of cpu-hog threads. (And I do see
it become 50/50 with new mode)

Fortunately POSIX provides mechanism to track per-thread cpu time via
posix timers facility. And even more fortunately, Linux also provides
mechanism to deliver timer ticks to specific threads.

Interestingly, it looks like FreeBSD also has very similar facility
and seems to suffer from same skew.  But due to difference in a way
how threads are identified, I haven't bothered to try to support this
mode on FreeBSD.

This commit implements new profiling mode where every thread creates
posix timer which tracks thread's cpu time. Threads also also set up
signal delivery to itself on overflows of that timer.

This new mode requires every thread to be registered in cpu
profiler. Existing ProfilerRegisterThread function is used for that.

Because registering threads requires application support (or suitable
LD_PRELOAD-able wrapper for thread creation API), new mode is off by
default. And it has to be manually activated by setting environment
variable CPUPROFILE_PER_THREAD_TIMERS.

New mode also requires librt symbols to be available. Which we do not
link to due to librt's dependency on libpthread.  Which we avoid due
to perf impact of bringing in libpthread to otherwise single-threaded
programs. So it has to be either already loaded by profiling program
or LD_PRELOAD-ed.
2014-11-02 18:29:55 -08:00
Aliaksey Kandratsenka c009398e32 issue-628:package missing stacktrace_powerpc-{linux,darwin}-inl.h
This headers were missing in .tar.gz because they were not mentioned
anywhere in Makefile.am.
2014-06-15 12:58:29 -07:00
Aliaksey Kandratsenka aeef3b4420 issue-610: introduced TCMallocGetenvSafe
This is version of GetenvBeforeMain that's available to C code.
2014-04-12 18:05:59 -07:00
Aliaksey Kandratsenka 90ba15d1f2 issue-604: implement runtime-selectable stacktrace capturing
We're now building all supported stacktrace capturing methods. And
there's now a way to select at runtime which method is used.
2014-02-16 19:22:06 -08:00
Aliaksey Kandratsenka 100f310088 unbreak make dist 2014-02-16 18:28:21 -08:00
Aliaksey Kandratsenka 48a0d131c1 issue-548: pass -fno-builtin to compiler for unittests
Because clang doesn't understand -fno-builtin-malloc and friends. And
otherwise new/delete pairs get optimized away causing our tests that
expect hooks to be called to fail.
2014-01-18 13:28:46 -08:00