Commit Graph

1175 Commits

Author SHA1 Message Date
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
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