Commit Graph

657 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
6fdfc5a7f4 implemented enabling sized-delete support at runtime
Under gcc 4.5 or greater we're using ifunc function attribute to resolve
sized delete operator to either plain delete implementation (default) or
to sized delete (if enabled via environment variable
TCMALLOC_ENABLE_SIZED_DELETE).
2015-11-21 19:03:03 -08:00
Aliaksey Kandratsenka
c2a79d063c use x86 pause in spin loop
This saves power and improves performance, particulary on SMT.
2015-11-21 18:17:24 -08:00
Aliaksey Kandratsenka
0fb6dd8aa3 added binary_trees benchmark 2015-11-21 18:17:21 -08:00
Aliaksey Kandratsenka
a8852489e5 drop unsupported allocation sampling code in tcmalloc_minimal 2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
a9db0ae516 implemented (disabled by default) sized delete support
gcc 5 and clang++-3.7 support sized deallocation from C++14. We are
taking advantage of that by defining sized versions of operator delete.

This is off by default so that if some existing programs that define own
global operator delete without sized variant are not broken by
tcmalloc's sized delete operator.

There is also risk of breaking exiting code that deletes objects using
wrong class (i.e. base class) without having virtual destructors.
2015-11-21 17:43:42 -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
0a18fab3af implemented sized free support via tc_free_sized 2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
464688ab6d speedup free code path by dropping "fast path allowed check" 2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
10f7e20716 added SizeMap::MaybeSizeClass
Because it allows us to first check for smaller sizes, which is most
likely.
2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
436e1dea43 slightly faster GetCacheIfPresent 2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
04df911915 tell compiler that non-empty hooks are unlikely 2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
8cc75acd1f correctly test for -Wno-unused-result support
gcc is only giving warning for unknown -Wno-XXX flags so test never
fails on gcc even if -Wno-XXX is not supported. By using
-Wunused-result we're able to test if gcc actually supports it.

This fixes issue #703.
2015-11-21 17:43:42 -08:00
Aliaksey Kandratsenka
7753d8239b fixed clang warning about shifting negative values 2015-11-21 17:43:42 -08:00
Jens Rosenboom
ae09ebb383 Fix tmpdir usage in heap-profiler_unittest.sh
Using a single fixed directory would break when tests were being run in
parallel with "make -jN".

Also, the cleanup at the end of the test didn't work because it referred
to the wrong variable.
2015-11-21 17:37:49 -08:00
Aliaksey Kandratsenka
df34e71b57 use $0 when referring to pprof
This fixed debian bug #805536. Debian ships pprof under google-pprof
name so it is handy when google-pprof --help refers to itself correctly.
2015-11-21 17:24:30 -08:00
Adhemerval Zanella
7773ea64ee Alignment fix to static variables for system allocators
This patch the placement new for some system allocator to force the
static buffer to pointer value.
2015-11-06 16:29:12 -02:00
Boris Sazonov
c46eb1f3d2 Fixed printf misuse in pprof - printed string was passed as format. Better use print instead 2015-10-17 22:50:46 -07:00
Boris Sazonov
9bbed8b1a8 Fixed assembler argument passing inside _syscall6 on MIPS - it was causing 'Expression too complex' compilation errors in spinlock 2015-10-17 22:50:46 -07: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
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