Commit Graph

1081 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
6babeb1a12 apply StaticStorage to windows/system-alloc.cc 2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
fa3753dc86 apply StaticStorage across the source code 2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
ee123a1a0d apply StaticStorage to TrivialOnce 2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
86606eef40 introduce tcmalloc::StaticStorage
We have a number of things that are explicitly constructed in some
statically allocated space, so lets finally have a helper for that.
2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
7cbbbdd099 use DirectAnonMMap in emergency allocator
It is just more straightforward and cleaner than going via
LowLevelAllocators "default" pages allocator, which does direct mmap
thingy anyways.
2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
6785aeb027 add test coverage of emergency malloc 2024-03-27 15:48:30 -04:00
Aliaksey Kandratsenka
703dc970fc add missing override declarations to TestingPortalImpl 2024-03-27 15:48:30 -04:00
hmihaylov-sc
e80e863e37 remove deprecated register storage class 2024-03-27 12:11:30 -04:00
Aliaksey Kandratsenka
c71e512664 implement support for hidden visibility
This is off by default for now. And autotools-only. But after
significant preparatory work, we're now able to do it cleanly. Stuff
that was previously exported just for tests (like page heap stuff or
flags) is now unexported.

Just like on windows all symbols explicitly exported by
PERFTOOLS_DLL_DECL are visible and exported and rest are hidden. Those
include all the malloc/new APIs of course, and all the other symbols
we advertise in our headers (e.g. MallocExtension, MallocHook).

Updates issue #600
2024-03-24 19:56:57 -04:00
Aliaksey Kandratsenka
38d741710b drop unused pwd.h/grp.h checks 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
02f10c15a5 update heap-checker_unittest to reach into malloc guts via TestingPortal 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
d5bd0087c1 avoid VLOG dependency in heap-profiler test
This makes the test compatible with -fvisibility=hidden
2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
c23bbdb4c7 don't dllexport Log and HookList 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
ea4fceb796 don't dllexport flags 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
274038486b ensure dllexport/public visibility of all aliases we generate 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
32796c754e export all mmap and sbrk replacement functions 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
5cba04ead2 export IsHeapProfilerRunning symbol
It is part of our API and ABI, so it needs to public visibility
declaration, like rest of functions declared in the same public header.
2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
2436c80d6c ensure that malloc_extension_c_test includes config.h first
Like we do everywhere.
2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
701777bbee dont define unused HAVE_MEMORY_H in windows config.h 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
6038a09c76 simplify vdso_support.h/elf_mem_image.h integration
This is only used by Linux/PPC, so lets make it simpler and
clearer (e.g. no need to do __GLIBC__ test).
2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
ae31e6afa3 drop unused LT_OBJDIR from cmake config.h template 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
e867bb7818 amputate unused Elf32_Versym check 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
b65b9e3e61 amputate unused AC_INSTALL_PREFIX 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
fc496c87c4 liberate our tests from makefile setting TCMALLOC_SAMPLE_PARAMETER 2024-03-20 16:06:59 -04:00
Aliaksey Kandratsenka
abc0ac6147 drop legacy_assertions.h 2024-03-20 16:06:57 -04:00
Aliaksey Kandratsenka
8cb41da4f9 gtestify debugallocation_test
As part of that we eliminate use of shell script and rely on gtest's
death testing facility instead (which this test was originally using).
2024-03-20 16:06:48 -04:00
Aliaksey Kandratsenka
14598dd4ac gtestify and refactor tcmalloc_unittest
While it still needs more work to be up to highest standards of
cleanness and clarity, we made it better.

One big part of this change is we're now liberated from
tcmalloc_unittest.sh. We now arrange testing of various environment
variable tweaks in C++ by self-execing with updated environment at the
end of tests.
2024-03-20 16:05:14 -04:00
Aliaksey Kandratsenka
93380fc754 drop dependency on sys/resource.h
Biggest part of it is removal of SetTestResourceLimit. The reasoning
behind it is, we don't do it on windows. Tests pass just fine. So,
there is no reason to bother.
2024-03-20 16:05:06 -04:00
Aliaksey Kandratsenka
a4fe2d7cd0 liberate sampling test from use of shell script
As part of that we do somewhat tighter job with temp files.
2024-03-20 16:04:52 -04:00
Aliaksey Kandratsenka
c3e9ad95f1 minor cleanup of thread_dealloc_unittest 2024-03-20 16:04:47 -04:00
Aliaksey Kandratsenka
6b53b1a4c1 gtestify and cleanup system-alloc_unittest 2024-03-20 16:04:45 -04:00
Aliaksey Kandratsenka
f7c8b45dcd gtestify realloc_unittest 2024-03-20 16:04:41 -04:00
Aliaksey Kandratsenka
0dddc476b3 gtestify malloc_extension_c_test 2024-03-20 16:04:39 -04:00
Aliaksey Kandratsenka
3cda0c4185 gtestify malloc_extension_test 2024-03-20 16:04:37 -04:00
Aliaksey Kandratsenka
2de5f833fb page_heap_test: test that more OS-es can release memory
I just dealt with somewhat curious failure in page heap test and the
change was due to breakage of HaveSystemRelease on OSX. And since OSX
can truly release memory and Windows too, lets assert this.
2024-03-20 16:04:31 -04:00
Aliaksey Kandratsenka
159c9e5c53 clean up and gtest-ify large_heap_fragmentation_unittest 2024-03-20 16:04:28 -04:00
Aliaksey Kandratsenka
27a57a1b30 MmapSysAllocator: try to extend previous mapping
This improves fragmentation in some use-cases when mmap sys allocator
is used. In specific terms, it unbreaks
tcmalloc_large_heap_fragmentation_unittest on OSX. They have sbrk that
seemingly always fails (fair game). And this test aggressive
fragmentation use-case pretty much requires tcmalloc to allocate
memory "linearly". Which sbrk does.

Previously, our mmap sys allocator didn't pass any start address hint,
so it caused the test to fail. Now we remember end of previous mmap
allocation into hint_ member variable and try to pass it as address
hint to next mmap.

Note, it doesn't help TCMALLOC_SKIP_SBRK=t to pass this test on Linux,
as Linux tends to pick initial mmap chunk "backwards" and too close to
library allocations. So it leaves not enough address space to extend
into. We may address this use-case some other time.
2024-03-20 16:04:05 -04:00
Aliaksey Kandratsenka
641cef6b4c unbreak early use of MallocExtension and simpify it some
On OSX and Windows we could end up with "default" and no-op
MallocExtension to be used if MallocExtension::instance() is used
before tcmalloc is fully initialized. It was nearly intended after my
recent change. But thinking about this more, even in use-cases where
we don't replace systems malloc APIs, we want MallocExtension to
reflect tcmalloc's state. So we now truly force tcmalloc
initialization on first MallocExtension::instance() use and
MallocExtension is now abstract class.
2024-03-20 16:03:11 -04:00
Aliaksey Kandratsenka
02adc8ceab also disable _TIME_BITS in mmap_hook.cc
Otherwise when _TIME_BITS are set, glibc complains that it seems
_TIME_BITS=64 without seeing _FILE_OFFSET_BITS=64. Thankfully, none of
the code in mmap_hook.cc depends on time_t.
2024-03-07 13:23:30 -05:00
Aliaksey Kandratsenka
198b3dd2d0 disable _FILE_OFFSET_BITS in mmap_hook.cc
Debian is doing massive rebuild of everything with 64-bit off_t (and
time_t), but on those systems where it matters, glibc still has mmap
with 32-bit off_t argument and mmap64 with 64-bit off_t. Since we're
aiming to match glibc's ABI, we need to see system's native off_t
width.
2024-03-01 16:28:04 -05:00
Aliaksey Kandratsenka
37b59a206e gtestify current_allocated_bytes_test 2024-02-27 17:04:53 -05:00
Aliaksey Kandratsenka
f9e6c517b8 gtestify markidle_unittest 2024-02-27 17:04:39 -05:00
Aliaksey Kandratsenka
3b12487a83 gtestify memalign_unittest 2024-02-27 17:00:42 -05:00
Aliaksey Kandratsenka
9cb7f7040e gtestify frag_unittest 2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
80a02ea645 update {tcmalloc_unit,debugallocation_}test to use TestingPortal
So that they're not reaching into guts of
libtcmalloc{,_debug}{,_minimal} anymore.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
ddc162f1d1 implement TestingPortal
Some our tests are intended to test behavior of external APIs (like
operator new etc), but they do need occasional ability to peek into
the guts of tcmalloc. We want to make our .so libraries to be built
with -fvisibility=hidden, so we'll loose this ability.

In order to have this limited ability for tests to get into the guts
of tcmalloc, we introduce TestingPortal exactly for that. It uses
carefuly designed and thouroughly undocumented GetNumericProperty
extension to grab pointer to TestingPortal. Then through calling
member functions of this instance, we're able to do the right thing.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
66bdf24061 initialize correct MallocExtension instance early
Previous implementation only had tcmalloc.cc's TCMallocGuard to
register correct MallocExtension instance. Which is occasionally too
late.

This original design (as well as it's ancestor in abseil tcmalloc)
allows malloc_extension.cc to be built and linked separately from
tcmalloc. So that software that uses extended features can be linked
with non-tcmalloc malloc (or, for example, asan).

In our case, we don't offer such flexibility. But we choose to keep
ability to (re)enable it.

New implementation makes sure to register malloc extension on first
call to memory allocation. Which typically happens super-early.

In case malloc/operator new aren't called early enough, we make sure
that first call to MallocExtension::instance invokes malloc as part of
creating it's 'empty' malloc extension, and thus provoking
tcmalloc (or any other malloc that chose to implement our malloc
extension interface) to register it's proper MallocExtension instance.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
9dfab2cdce cmake: refactor CMakeLists.txt
It is still somewhat broken and somewhat of a mess, but it is much
lesser mess now.

As part of this change I also amputated a number of unnecessary or too
complicated bits. Like attempt to build both static and shared
versions of tcmalloc libraries at the same time. We stick to cmake's
"common" (seemingly) behavior of defaulting to something (in our case
shared library) and letting users override BUILD_SHARED_LIBS.

All the "install" bits are amputated as well, they're not ready.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
5fabaea30d link page_heap_test with entirety of tcmalloc_minimal
This makes page_heap_test a bit more uniform with rest of things and
prevents any future missing symbols issues.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
5f9eb91129 cleanup and untangle sampling-test from tcmalloc guts 2024-02-27 17:00:35 -05:00