Commit Graph

1185 Commits

Author SHA1 Message Date
Aliaksei Kandratsenka
d5055ef3a2 new symbolize api and implementation
This is part of effort to get rid of perl pprof dependency. We're
replacing forking to pprof --symbols with carefully crafted
libbacktrace integration which has enough support for symbolizing
backtraces.
2024-10-03 21:18:04 -04:00
Aliaksei Kandratsenka
96885311f3 add vendor/libbacktrace 2024-10-03 21:17:51 -04:00
Aliaksei Kandratsenka
94da1c10f9 cleanup unused symbolize.cc from msvc project files 2024-10-03 21:17:51 -04:00
Aliaksei Kandratsenka
acb9f66460 place LowLevelAlloc into tcmalloc namespace 2024-10-03 20:42:26 -04:00
Aliaksei Kandratsenka
40957460b5 [low_level_alloc] allocate Arena with custom allocator when provided
This refactors API so that meta_data_arena isn't needed or used
anymore. We always used nullptr for this argument anyways.

We also change code so that PagesAllocator API is able to choose
rounding up of allocation requests. It now returns pointer to
allocated memory and it's rounded up size.

And most important part of this change is that Arena instance itself
is now allocated with provided allocator (when provided). This reduces
locking depencies.

We make sure to cover new logic by test.
2024-10-03 20:42:26 -04:00
Aliaksei Kandratsenka
d0d4363a34 structure low_level_alloc as own convenience archive 2024-10-03 17:06:22 -04:00
Aliaksei Kandratsenka
3c261d9090 stop linking malloc_hooks to low_level_alloc 2024-10-03 16:56:53 -04:00
Andrey Semashev
2e1799aa78 Fix gcc 10 compilation error
Apparently, gcc 10 doesn't support trailing return types for lambdas with an attribute.

```
src/tests/sampling_test.cc: In lambda function:
src/tests/sampling_test.cc:70:56: error: expected '{' before '->' token
   70 |   auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
      |                                                        ^~
src/tests/sampling_test.cc: In function 'void* AllocateAllocate()':
src/tests/sampling_test.cc:70:56: error: base operand of '->' has non-pointer type 'AllocateAllocate()::<lambda(void*)>'
src/tests/sampling_test.cc:70:59: error: expected unqualified-id before 'void'
   70 |   auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
      |                                                           ^~~~
```

Remove the trailing return type as it is deduced from the `noopt` call anyway.
2024-10-03 08:42:56 -07:00
Aliaksei Kandratsenka
c7dcabf09a [proc_maps_iterator_test] handle unknown PT_XYZ defines 2024-10-02 18:50:24 -04:00
Aliaksei Kandratsenka
fdbf9833ab [proc_maps_iterator] add implementation on top of dl_iterate_phdr
And unbreak on it FreeBSD.

Turns out not only they don't mount procfs by default, their
/proc/pid/map fails to supply mapping offsets. Without offsets all the
hope is lost.
2024-10-02 18:07:32 -04:00
Aliaksei Kandratsenka
d882347119 [proc_maps_iterator_test] print all elf program headers
I.e. to match with what proc maps iterator did.
2024-10-02 18:06:04 -04:00
Aliaksei Kandratsenka
d20ae0c8d8 move GetProgramInvocationName into sysinfo 2024-10-02 16:52:21 -04:00
Aliaksei Kandratsenka
6fee38e5e7 build symbolizer stuff only for debug allocator
Since it is now the only place that uses it
2024-10-02 16:46:44 -04:00
Aliaksei Kandratsenka
0f8cb8416e [sampling_test] print errno when mkstemp fails
I see rare occasional failures there, which look very odd. Typically
both sampling and sampling_debug tests fail at about the same time. So
hopefully we can diagnose them sometime.
2024-10-02 16:42:32 -04:00
Aliaksei Kandratsenka
9d58d03fa4 set default cmake build type to RelWithDebInfo
Which is the only sensible default. Should have been upstream default,
really.
2024-10-02 16:42:32 -04:00
Aliaksei Kandratsenka
feb43df6ae remove some unused includes 2024-10-02 16:41:34 -04:00
Aliaksei Kandratsenka
d87c1a5c77 amputate HeapProfileTable::Snapshot
Those are remains of heap checker.
2024-10-02 16:41:34 -04:00
Aliaksei Kandratsenka
5035d10c85 drop unused kStripFrames constant 2024-10-02 16:41:28 -04:00
Aliaksei Kandratsenka
1cfbc55fbf [debugallocation_test] make death stack trace testing more rigorous
I.e. make sure we actually have stack-trace at least up to actual
allocation function, not just main().
2024-10-02 16:39:59 -04:00
Aliaksei Kandratsenka
0aa7254ac9 [debugallocation] grab entire stack trace of deletion
We used GetCallerStackTrace thingy before, but it is not entirely
reliable in it's detection of malloc stack frames (i.e. on OSX). So
lets do full thing instead. Those stacktraces are to be printed to
users anyways.
2024-10-02 16:39:59 -04:00
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