Commit Graph

388 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
347a830689 Ensure that PPROF_PATH is set for debugallocation_test
Which fixes issue #728.
2015-10-17 20:34:19 -07:00
Aliaksey Kandratsenka
a9059b7c30 prevent clang from inlining Mallocer in heap checker unittest
Looks like existing "trick" to avoid inlining doesn't really prevent
sufficiently smart compiler from inlining Mallocer function. Which
breaks tests, since test relies Mallocer having it's own separate stack
frame.

Making mallocer_addr variable volatile is seemingly enough to stop that.
2015-10-17 20:34:19 -07:00
Aliaksey Kandratsenka
6627f9217d drop cycleclock 2015-10-05 21:00:49 -07:00
Aliaksey Kandratsenka
f985abc296 amputate unportable and unused stuff from sysinfo
We still check number of cpus in the system (in spinlock code), but old
code was built under assumption of "no calls malloc" which is not needed
in tcmalloc. Which caused it to be far more complicated than
necessary (parsing procfs files, ifdefs for different OSes and arch-es).

Also we don't need clock cycle frequency measurement.

So I've removed all complexity of ald code and NumCPUs function and
replaced it with GetSystemCPUsCount which is straightforward and
portable call to sysconf.

Renaming of cpus count function was made so that any further code that
we might port from Google that depends on old semantics of NumCPUs will
be detected at compile time. And has to be inspected for whether it
really needs that semantics.
2015-10-05 21:00:49 -07:00
Aliaksey Kandratsenka
16408eb4d7 amputated wait_cycles accounting in spinlocks
This is not needed and pulls in CycleClock dependency that lowers
code portability.
2015-10-05 21:00:45 -07:00
Aliaksey Kandratsenka
fedceef40c drop cycleclock reference in ThreadCache 2015-10-05 20:58:41 -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
3a054d37c1 dropped unused SpinLockWait function 2015-10-05 20:56:28 -07:00
Aliaksey Kandratsenka
5b62d38329 avoid checking for dup. entries on empty backtrace
This might fix issue #721. But it is right thing to do regardless. Since
if depth is 0 we'll be reading random "garbage" on the stack.
2015-10-05 20:56:28 -07:00
Aliaksey Kandratsenka
7b9ded722e fixed compiler warning in memory_region_map.cc 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
Fredrik Mellbin
121038308d Check if _MSC_VER is defined to avoid warnings 2015-10-03 14:54:40 -07:00
Fredrik Mellbin
7367322995 Make default config.h work with VS2015 2015-10-03 14:54:40 -07:00
Dair Grant
ae0a444db0 Ensure ThreadCache objects are CACHELINE_ALIGNED. 2015-10-03 14:50:53 -07:00
Aliaksey Kandratsenka
ea0b1d3154 unbreak TestErrno again
Somehow in previous commit I managed to break assignment of memalign
result to variable being tested. Luckily gcc gave me warning.
2015-09-26 11:13:13 -07:00
Aliaksey Kandratsenka
e53aef24ad don't try to test memalign on windows
This unbreaks tcmalloc_unittest.cc on windows.
2015-09-26 09:58:45 -07:00
Aliaksey Kandratsenka (aka Aliaksei Kandratsenka)
7707582448 Merge pull request #717 from myrsloik/master
Use correct mangled new and delete symbols on windows x64
2015-09-26 09:43:50 -07:00
Fredrik Mellbin
9eb63bddfb Use correct mangled new and delete symbols on windows x64 2015-09-24 19:57:26 +02:00
fdeweerdt
5078abdb33 Don't discard curl options if timeout is not defined.
Editing the options passed to curl via 'my @URL_FETCHER = ("curl",
"-s");' (in particular to add a -k to ignore self signed certs) fails
for some invocations of curl. In FetchDynamicProfile, 'my @fetcher =
AddFetchTimeout($fetch_timeout, @URL_FETCHER);' ends up being just
'curl' if timeout is not defined.

This happens because AddFetchTimeout doesn't retrieve all the arguments
from the caller.

[alk@tut.by: updated commit message]
Signed-off-by: Aliaksey Kandratsenka <alk@tut.by>
2015-09-19 09:46:34 -07:00
Aliaksey Kandratsenka
54505f1d50 help clang with inlining important fast-path functions
Clang's recent focus on code size doesn't help us in malloc fast-path
because somehow clang completely ignores inline directives.

In order to help clang generate code that was actually intended by
original authors, we're adding always_inline attribute to key
fast-path functions.

Clang also guessed likely branch "wrong" in couple places. Which is
now addressed by UNLIKELY declarations there.
2015-08-02 19:36:27 -07:00
Aliaksey Kandratsenka
73c0c8c61b moved do_mallor_or_cpp_alloc in better place 2015-08-02 19:09:02 -07:00
Aliaksey Kandratsenka
41aca070e8 always set errno to ENOMEM on OOM condition and in single place
While standards do not require us to set errno to ENOMEM in certain
places (like posix_memalign), existing code may sometimes set it
(i.e. because mmap or sbrk couldn't get memory from kernel)
anyways. And from my reading of glibc, it's malloc is doing more or
less same by just always setting ENOMEM on OOM condition.

This commit also eliminates some functions (XXX_no_errno) that are not
needed anymore.
2015-08-02 19:06:21 -07:00
Aliaksey Kandratsenka
c4493874cd deal with OOM handling in one place and prior to returning result
This commit removes 4 (four!) duplicates of C++ OOM handling. And
introduces one helper for that.

Other change is that malloc doesn't have to check tc_new_mode anymore
until it _actually_ deals with OOM condition. Which shaves off couple
instructions from fast-path.
2015-08-02 19:06:21 -07:00
Aliaksey Kandratsenka
09448a8fe9 added tcmalloc_unittest path with TCMALLOC_HEAP_LIMIT_MB=512
I.e. so that we can exercise "voluntary" OOM conditions better.
2015-08-02 18:12:16 -07:00
Aliaksey Kandratsenka
73fb7c7eb3 added test on errno = ENOMEM on out of memory 2015-08-02 18:12:16 -07:00
Aliaksey Kandratsenka
eb725ff263 unbreak heap-profiler-unittest on gcc 5
gcc 5 has got nice new optimization (-fipa-icf) which merges identical
functions into one. And that causes heap-profiler_unittest to fail
since it expects to see both Allocate and Allocate2 in heap
profiles. And smart GCC detects that they are same function and makes
one function out of two and thus breaks this test.

New code simply adds (disabled) logging calls to make those functions
non-identical.
2015-08-02 17:25:13 -07:00
Aliaksey Kandratsenka
53833298f3 unbreak heap_checker_unittest on gcc 5
GCC 5 ended up too smart and optimized out assignment of allocated
block to global variable. Which caused test to fail since it triggered
unexpected "leak".
2015-08-02 16:53:24 -07:00
Aliaksey Kandratsenka
024bae96ce dropped support for PREANSINEW define which nobody needs anymore 2015-08-02 16:53:24 -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
Tom Conerly
e1d1311cfb issue-699: Free list on error paths 2015-08-01 12:34:08 -07:00
Aliaksey Kandratsenka
b5b79860fd issue-702: correctly declare arg-less functions in profiler.h
This is patch by user mitchblank.

From his words:

The problem is pretty simple.  Ancient C code allowed declarations
without argument prototypes, i.e.

  int foo();

For compatibility this is still accepted.  If you want to declare a
function with zero prototypes the correct way to do it is:

   int foo(void);

C++ also accepts this syntax, but it's not needed there.

Normally compilers still accept the old-style entries, but with
sufficient warning flags gcc will complain about them.  It is good for
header files to have the explicit "void" argument so all compilers are
kept happy.

I'm attaching a simple patch to add the "void" parameter to that file.
I haven't checked if other headers have the same problem (I'm just
using the profiler at the moment)

<end of quote>

In fact "int foo()" means "foo accepts any args" and we really want
"foo has no args". For which int foo (void) is right declaration.
2015-08-01 11:24:56 -07:00
Aliaksey Kandratsenka
7df7f14c94 issue-693: enable futex usage on arm
This patch was contributed by user spotrh.
2015-06-27 21:17:48 -07:00
Aliaksey Kandratsenka
cb998e56d7 issue-693: convert sys_futex to it's 6-arg form
Because sys_futex actually takes 6 args in more recent kernels (even
though last two args are unused for FUTEX_{WAKE,WAIT}.

This is patch contributed by user spotrh.
2015-06-27 21:17:48 -07:00
Aliaksey Kandratsenka
36066b8df4 issue-695: implementated TCMALLOC_TRACE_FILE variable
This is contributed by Paolo Bonzini.

This commit adds TCMALLOC_TRACE_FILE environment variable, which if
defined overrides location of malloc trace file.
2015-06-27 21:15:30 -07:00
Brian Silverman
c4069d2d37 Add empty virtual destructor to class with virtual methods.
Clang 3.5 has a warning about deleting objects with virtual methods
through non-virtual destructors which was triggered. I'm not sure
whether this actually creates any undefined or otherwise incorrect
behavior, but it seems like a good thing to fix regardless.

Example compiler warning:
third_party/gperftools/src/tests/profile-handler_unittest.cc:282:5: error:
  delete called on '(anonymous namespace)::BusyThread' that has virtual
  functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete busy_worker_;
    ^
2015-06-16 19:58:56 -07:00
Patrick LoPresti
019362fefc Add support for CPUPROFILE_TIMER_SIGNAL environment variable.
Which both enables per-thread timers and allows the signal number for
the timer to be selected.

[alk@tut.by: reformatted commit message for subject line length]
Signed-off-by: Aliaksey Kandratsenka <alk@tut.by>
2015-05-30 10:25:42 -07:00
Milton Chiang
81d8d2a9e7 Add "ARMv8-A" to the supporting list of ARM architecture. 2015-05-23 12:01:48 -07:00
Aliaksey Kandratsenka
64d1a86cb8 include time.h for struct timespec on Visual Studio 2015
This patch was submitted by user wmamrak.
2015-05-09 15:38:12 -07:00
Aliaksey Kandratsenka
7013b21997 hook mi_force_{un,}lock on OSX instead of pthread_atfork
This is patch by Anton Samokhvalov.

Apparently it helps with locking around forking on OSX.
2015-05-09 14:56:58 -07:00
Angus Gratton
f25f8e0bf2 Clarify that only tcmalloc_minimal is supported on Windows. 2015-05-09 12:03:17 -07:00
Aliaksey Kandratsenka
772a686c45 issue-683: fix compile error in clang with -m32 and 64-bit off_t 2015-05-03 13:15:16 -07:00
Aliaksey Kandratsenka
0a3bafd645 fix typo in PrintAvailability code
This is patch contributed by user ssubotin.
2015-04-11 10:35:53 -07:00
Matt Cross
6ce10a2a05 Add support for printing collapsed stacks for generating flame graphs. 2015-03-26 16:24:11 -04:00
Matt Cross
2c1a165fa5 Add support for reading debug symbols automatically on systems where shared libraries with debug symbols are installed at "/usr/lib/debug/<originalpath>.debug", such as RHEL and CentOS. 2015-03-26 12:14:56 -04:00
Jonathan Lambrechts
2e65495628 callgrind : handle inlined functions 2015-02-13 17:54:21 -08:00
Jonathan Lambrechts
90d7408d38 pprof : callgrind : fix unknown files 2015-02-13 17:54:14 -08:00
Aliaksey Kandratsenka
aa963a24ae issue-672: fixed date of news entry of gperftools 2.4 release
It is 2015 and not 2014. Spotted and reported by Armin Rigo.
2015-02-09 08:35:03 -08:00
Aliaksey Kandratsenka
c66aeabdba fixed default value of HEAP_PROFILER_TIME_INTERVAL in .html doc 2015-01-10 14:35:54 -08:00
Aliaksey Kandratsenka
689e4a5bb4 bumped version to 2.4 2015-01-10 12:26:51 -08:00
Aliaksey Kandratsenka
3f5f1bba0c bumped version to 2.4rc 2014-12-28 18:28:18 -08:00