Commit Graph

1165 Commits

Author SHA1 Message Date
Andrey Semashev
28c2853cba
Avoid sampling_test failures
Increase the upper bound of allocated memory amount to avoid test failures on Kubuntu 24.04.

Fixes https://github.com/gperftools/gperftools/issues/1564.
2024-10-02 19:33:28 +03:00
Aliaksei Kandratsenka
a9a52320fc drop a bunch of unnecessary "using std::XYX" declarations 2024-09-27 22:39:39 -04:00
Aliaksei Kandratsenka
b128b1557e unbreak profiler_unittest when linking statically
When linking statically we may end up calling ProfilerGetCurrentState
earlier than profiler is initialized. And we segfaulted on that early
call. Lets make us handle this case gracefully.
2024-09-27 22:20:08 -04:00
Aliaksei Kandratsenka
f0bab33d27 do non-minimal cmake configuration for ci.yml 2024-09-27 17:46:48 -04:00
Aliaksei Kandratsenka
608e6d0625 unbreak cmake testing of heap-profiler 2024-09-27 17:34:36 -04:00
Aliaksei Kandratsenka
aaed4feb28 [heap-profiler] use regular stacktracing API
Instead of MallocHook::GetCallerStackTrace.

Thing is, GetCallerStackTrace isn't reliable beyond ELF systems, like
OSX. And, yet, things just work without it for e.g. heap
sampling. Why? Because pprof already knows how to exclude
tcmalloc-internal stack frames (by looking at e.g. tcmalloc::
namespace). So we do the same for heap profiler.

This fixes heap profiling unit tests on OSX.
2024-09-27 14:47:03 -04:00
Aliaksei Kandratsenka
c1e3eac0c6 move Invoke*Hook stuff under tcmalloc namespace
This will allow us to move heap profiling from
MallocHook::GetCallerStackTrace into plain tcmalloc::GrabBacktrace
thingy.
2024-09-27 14:46:06 -04:00
Aliaksei Kandratsenka
d0724116cf drop a bunch of bogus private stuff from public malloc_hook.h 2024-09-27 14:30:01 -04:00
Aliaksei Kandratsenka
fc86294f9d add initial github actions CI 2024-09-27 00:18:35 -04:00
Aliaksei Kandratsenka
f01510ccf2 make large_heap_fragmentation_unittest not as painful on windows 2024-09-27 00:06:13 -04:00
Aliaksei Kandratsenka
96e3eca05e amputate dead travis CI integration 2024-09-26 14:58:40 -04:00
Aliaksei Kandratsenka
ff061b4de3 actualize AUTHORS 2024-09-26 14:51:59 -04:00
Aliaksei Kandratsenka
6a7419e39f drop mmap_hook 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
00d235325f drop memory region map 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
07c30d1229 amputate mmap heap profiling
It wasn't entirely functional (i.e. see
https://github.com/gperftools/gperftools/issues/1010 or
https://github.com/gperftools/gperftools/issues/1458) and it's
underlying mmap hooks facility introduces significant source
portability complications. And since we've just dropped heap checker
we can drop entire mmap hooks stuff too.
2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
b19a1999a4 amputate MallocHook_InitAtFirstAllocation_HeapLeakChecker logic 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
187b31e952 amputate heap checker 2024-09-25 18:34:09 -04:00
Aliaksei Kandratsenka
05692cc057 drop unused windows/{addr2line,nm}-pdb 2024-09-25 18:33:57 -04:00
Aliaksei Kandratsenka
be755a8d3c mass-replace NULL -> nullptr 2024-09-25 18:33:56 -04:00
Aliaksei Kandratsenka
91b96b92a2 slightly saner malloc_hook_test implementation 2024-09-25 18:33:08 -04:00
Aliaksei Kandratsenka
e1014dead2 bump version to 2.16 2024-09-25 18:25:20 -04:00
Aliaksei Kandratsenka
b569be106c [stacktrace_unittest] skip "from ucontext" case when not on glibc
glibc carefully handles unwind info for signal trampoline stack frame,
so even brittle "skip N frames" case works there. But e.g. on musl it
doesn't.

So lets skip this test on non-glibc systemsfor now, until we test
things closer to how it is done by cpu profiler.
2024-09-25 17:32:46 -04:00
Aliaksei Kandratsenka
6aecbbdb6b unbreak heap checker unittest on systems without execinfo.h
I.e. musl
2024-09-25 17:11:02 -04:00
Aliaksei Kandratsenka
3cc9014c57 make profiler_unittest less brittle
So I noticed that profiler_unittest failed somewhat regularly on
armhf. On inspection I found that it fails because the test compares
"nested-most" tick counts between several profiles and we had most
ticks inside inlined atomic ops functions and not test_main_thread.

On the other hand, removing atomic ops from nested loop makes test way
too fast for the modern quick x86 desktops.

So lets make it try harder to be non-brittle. We do that by grabbing
access to profiler's ticks count, which helps our inner loops to run
long enough to get sufficient ticks count.

We also do couple more minor updates.

*) we have shell script use random temp directory name. Which allows
us to exercise golang-stress and similar utils.

*) we drop PERFTOOLS_UNITTEST and relevant code because this
"variable" was always set to be true anyways.
2024-09-23 17:23:56 -04:00
Aliaksei Kandratsenka
dd751345df unbreak generic_fp frame skipping
Sadly, we missed another issue there which is we returned negative
frame counts whenever skip_count exceeded number of stack frames we
had.
2024-09-23 14:28:34 -04:00
Aliaksei Kandratsenka
e46b3e79aa make sampling_test more robust
The test inspects "nested-most" frames in malloc sampling samples. And
some compile options caused noopt to seen as call site of
malloc. I.e. because noopt is immediately after malloc.

To make things more robust we create local "copy" of noopt that is
marked as noinline and so immediately next instruction after malloc is
call to this local_noopt thingy, which makes test more robust since
malloc stack trace will see that, as we expect, AllocateAllocate is
what calls malloc.
2024-09-23 14:19:37 -04:00
Aliaksei Kandratsenka
7803e80bb2 don't fail mmap_hook_test on mmap recursions
Because some backtracing methods (which we invoke as part of calling
mmap hooks) do use mmap themselves.

Fixes github ticket #1558
2024-09-18 15:43:09 -04:00
Aliaksei Kandratsenka
74a7381cc9 initialize tcmalloc's sample parameter at earliest opportunity
I.e. so that correct value is available immediately, so that sampling
is more precise.

Update github ticket #1557.
2024-09-18 12:59:24 -04:00
Aliaksei Kandratsenka
c2dc36d00d improve quality of sampling_test
Part of this change is better diagnostic for when/if it fails. And
most important part is compensating for the delay between sampling
parameter is set for the test and when it is actually taken into
account by thread cache Sampler logic.

As a result about 1% of flaking probability has been fixed as we're
getting mean estimate for the allocated size actually same (or about
same) as allocated size.

Update github ticket #1557.
2024-09-18 12:59:04 -04:00
Aliaksei Kandratsenka
cefaaffeb4 fix compiler warning in malloc_hook_test 2024-09-17 20:37:45 -04:00
Aliaksei Kandratsenka
8899936b77 fix warning in profile-handler unittest
Clang kinda rightfully noticed that if FLAGS_test_profiler_enabled is
false (and it never is false in practice), we'd be reading unitialized
variables. Since this flag is never updated, we can simply drop those
dead "false" paths.
2024-09-16 20:41:11 -04:00
Aliaksey Kandratsenka
6b8962d797 bump version to 2.16rc 2024-09-16 20:28:05 -04:00
Aliaksei Kandratsenka
362938f1f7 replace sprintf usage with snprintf
Even though this specific usage is safe, it is, arguably, not great to
be using sprintf in year 2024. snprintf is portable enough this
days. Thanks goes to OSX headers that warn about sprintf loudly enough
to be noticed.
2024-09-16 19:49:00 -04:00
Aliaksei Kandratsenka
5273567470 [trivialre] fix past-end-of-string access in MatchSubstring
Thanks goes to MSVC's string_view asserts that check this.
2024-09-16 19:33:14 -04:00
Aliaksei Kandratsenka
38abfd9038 make dist windows/CMakeLists.txt 2024-09-16 19:33:14 -04:00
Aliaksei Kandratsenka
d5c94e0bd3 unbreak make dist for benchmark/trivialre.h 2024-09-16 18:17:02 -04:00
Aliaksei Kandratsenka
e0844fa799 [low_level_alloc_unittest] cleanup unused variable usage 2024-09-16 16:30:10 -04:00
Aliaksei Kandratsenka
a4e2f95038 [osx] unbreak EmergencyMallocNoHook test
OSX's malloc zones stuff is essentially incompatible with emergency
malloc. In order to handle it, our unit tests use tc_free directly in
order to free memory allocated by emergency malloc. So lets keep doing
it for our newer code that exercises calloc/free pair as well.
2024-09-16 13:13:42 -04:00
Aliaksei Kandratsenka
92fd07cc2f bump googletest version to latest 2024-09-14 22:54:29 -04:00
Aliaksey Kandratsenka
ea35d14585 stop checking unused malloc_hook "subsection"
Originally at Google they had to do 2 subsections for hookable
functions because of some linking detais (in bazel infrastructure they
still do different libraries as .so-s for tests). So "generic" hooks
(such as mmap/sbrk) were in malloc_hook section and tcmalloc's
were/are in google_malloc. Since those are different bazel/blaze
libraries. And we kept this distinction simply because no-one bothered
to undo it, despite us never needing it.

We recently refactored mmap/sbrk hooking. And we don't use section
stuff anymore for those hooks. And so there are no malloc_hook
anymore. And so we were getting bogus and useless warnings about empty
section. So lets avoid this.
2024-09-14 17:24:20 -04:00
Aliaksey Kandratsenka
fd09d89fcd [qnx] provide -lregex dependency for googletest
For more context see: https://github.com/gperftools/gperftools/pull/1544
2024-09-14 16:02:46 -04:00
Aliaksey Kandratsenka
a5d86777ce [malloc_bench] add rnd_dependent_8cores benchmark
This benchmark exercizes multi-threaded central free list operations,
and this is where we're losing to a bunch of competing malloc (i.e. which
shard heap).
2024-09-13 18:02:37 -04:00
Aliaksey Kandratsenka
ea81e46ff1 improve benchmarks facility
We now support a set of command line flags similar to "abseil"
benchmark thingy. I.e. to let people specify a subset of benchmarks or
run them longer/shorter as needed.

This commit also includes small, portable and very simple regexp
facility. It isn't good enough for some production use, but it is
plenty good for some testing uses or benchmark selection.
2024-09-13 18:01:25 -04:00
Aliaksey Kandratsenka
7fa0c2da53 modernize malloc_bench
Instead of relying on gperftools-specific tc_XYZ functions for sized
deallocation and memalign we use standard C++ facilities. There are
also other minor improvements like mallocing larger buffers rather
than statically allocating them.
2024-09-05 22:56:23 -04:00
Olivier Langlois
f46c141b4e make ThreadCache constructor/destructor private
1. This documents the intent that the way to create/destroy a ThreadCache
    object is through the static methods NewHeap()/DeleteCache()
2. It makes using the class less error prone. The compiler will complain
   if some new code is accidentally creating objects directly
3. This may allow some compilers to optimize code knowing that those
   functions are private

Signed-off-by: Olivier Langlois <olivier@trillion01.com>
2024-09-01 15:45:16 -04:00
Aliaksey Kandratsenka
ae15d7a490 fix spurious rare failures in profile handler unittest
It's method of verifying that cpu profiling ticks happens is
inherently brittle. It sleeps certain time and then checks if ticks
happened during that time. And sleeping is by wall clock time. But due
to cpu scheduling being unpredictable, it is not impossible to see no
ticks even waiting 200 ms. We improve the issue by having the code
loop a bit until it seeks ticks happen.
2024-08-18 15:56:17 -04:00
Xiang.Lin
2e0b81852e [qnx] prefer fp unwinder 2024-08-13 14:26:05 -04:00
Xiang.Lin
68ae9e624e [qnx] fix empty proc maps info
Qnx pmap file starts with a header line, skip it to make ForEachLine
continue feeding next valid proc maps line.

vaddr,size,flags,prot,maxprot,dev,ino,offset,rsv,guardsize,refcnt,mapcnt,path
0x0000001c0ae92000,0x0000000000002000,0x00010071,0x05,0x0d,0x00000802,0x00000000c00000ab, \
  0x0000000000000000,0x0000000000000000,0x00000000,0x0000017e,0x0000017c,/bin/cat
2024-08-13 14:26:05 -04:00
Aliaksey Kandratsenka
285908e8c7 actualize TCMallocGuard comment
It was incorrectly refering to long gone behavior of updating
environment variables to tell (ancient versions of) libstdc++ to use
new/delete.
2024-06-21 15:52:57 -04:00
Aliaksey Kandratsenka
469da8dac6 override_functions: add _{msize,recalloc}_base
Apparently modern ucrt does have _msize_base and _recalloc_base
defined in same .obj files as their corresponsing "non-base"
functions. And they're seemingly used somewhere in their C or C++
runtime. So lets provide them too in our override_functions.cc, so
that overriding malloc routines in MSVC's static C runtime option
works.

Otherwise, whatever msize_base usage pulls msize.obj file that wants
to define regular msize, and with msize already provided by
override_function, we'd rightfully get linking error.

Update github ticket
https://github.com/gperftools/gperftools/issues/1430
2024-06-21 13:32:35 -04:00