Commit Graph

203 Commits

Author SHA1 Message Date
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 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 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
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 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
Ishant Goyal addf751420 Added support to configure lower bound on per-thread cache size
[alkondratenko@gmail.com: removed spurious new line at thread_cache.h]
Signed-off-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
2024-06-04 12:11:01 -04:00
Aliaksey Kandratsenka 29f394339b refactor and simplify capturing backtraces from mmap hooks
The case of mmap and sbrk hooks is simple enough that we can do
simpler "skip right number of frames" approach. Instead of relying on
less portable and brittle attribute section trick.
2024-05-29 18:30:09 -04:00
Aliaksey Kandratsenka 29b6eff4c7 replace heap-checker "bcad" stuff
The comments in this file stated that it has to be linked in specific
order to get initialized early enough. But our initialization is
de-facto via initial malloc hook. And to deal with latest-possible
destruction, we use more convenient destructor function
attribute, and make things simpler.
2024-05-29 18:30:09 -04:00
Aliaksey Kandratsenka d9a99c290a expand emergency malloc integration to !kHaveGoodTLS systems
References github issue #1503.

This significantly reworks both early thread cache access and related
emergency malloc mode checking integration. As a result, we're able to
to rely on emergency malloc even on systems without "good"
TLS (e.g. QNX which does emutls).

One big change here is we're undoing early change to have single
"global" thread cache early during process lifetime. It was nice and
somewhat simpler approach. But because of inherent locking during
early process lifetime, we couldn't be sure of certain lock ordering
aspects w.r.t. backtracing/exception-stack-unwinding. So I choose to
keep it safe. So the new idea is we use SlowTLS facility to find
threads' caches when normal tls isn't ready yet. It avoids holding
locks around potentially recursion-ful things (like
ThreadCache::ModuleInit or growing heap). But we then have to be
careful to "re-attach" those early thread cache instances to regular
TLS. There will nearly always be just one of such thread caches. For
initial thread. But we cannot entirely rule out more general case
where someone creates threads before process initializers ran and
main() is reached. Another notable thing is free-ing memory in this
early mode will always using slow-path deletion directly into central
free list.

SlowTLS facility is "simply" a generalization of previous
CreateBadTLSCache code. I.e. we have a small fixed-size cache that
holds "exceptional" instances of thread-identitity to
thread-cache+emergency-mode-flag mappings.

We also take advantage of tcmalloc::kInvalidTLSKey we introduced
earlier and remove potentially raceful memory ordering between reading
tls_ready_ and tls_key_.

For emergency malloc detection we previously used thread_local
flag. Which we cannot use on !kHaveGoodTLS systems. So we instead
_remove_ thread's cache from it's normal tls storage and place it
"into" SlowTLS instead for the duration of WithStacktraceScope
call (which is how emergency mode is enabled now).
2024-05-23 13:31:42 -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 fc496c87c4 liberate our tests from makefile setting TCMALLOC_SAMPLE_PARAMETER 2024-03-20 16:06:59 -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 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 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 159c9e5c53 clean up and gtest-ify large_heap_fragmentation_unittest 2024-03-20 16:04:28 -04: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 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 2940450c7a gtestify profiledata_unittest 2024-02-27 16:50:07 -05:00
Aliaksey Kandratsenka bbae941492 gtestify profile-handler_unittest 2024-02-27 16:50:07 -05:00
Aliaksey Kandratsenka f8da159013 add function_ref_test 2024-02-21 21:57:37 -05:00
Aliaksey Kandratsenka bfbfa333eb add cleanup_test
This also let us spot and fix missing include in the header.
2024-02-21 21:37:47 -05:00
Aliaksey Kandratsenka 61b1e05848 unbreak make dist
In 57d6ecc4ae I removed obsolete
src/windows/TODO but failed to remove it from Makefile.am

I also previously failed to arrange distribution of vendored
googletest. And we also failed to distribute headers in src/tests/

This is all fixed now.
2024-02-21 13:44:17 -05:00
Aliaksey Kandratsenka 0906dacc48 gtestify more tests
Those are malloc_hook_test, mmap_hook_test, page_heap_test,
sampler_test, stack_trace_table_test.
2024-02-20 14:34:28 -05:00
Aliaksey Kandratsenka bfa30bf7df gtestify 3 simpler tests
Those are packed-cache_test, pagemap_unittest, safe_strerror_test
2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka ff2dce5e67 gtestify addressmap_unittest 2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka c1799405ae gtestify check_address_test 2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka a46a391b14 gtestify low_level_alloc_unittest 2024-02-20 14:34:20 -05:00
Aliaksey Kandratsenka 6c24a59682 introduce vendor copy of googletest 2024-02-20 14:30:24 -05:00
Aliaksey Kandratsenka 8318e08962 fix missing AM_CXXFLAGS introduced in recent automake refactoring 2024-02-20 12:06:30 -05:00
Aliaksey Kandratsenka 3a2a7e05f6 add missing internal_logging.cc to packed_cache_test
It wasn't caught before because when optimization is enabled ASSERT-s
inside packed-cache-inl get optimized away (because checks are
tautological).
2024-02-17 18:03:41 -05:00
Aliaksey Kandratsenka 8a147b4833 untangle a number of unittests from libtcmalloc_minimal.so 2024-02-07 23:54:03 -05:00
Aliaksey Kandratsenka b0e2928343 mingw: don't add patch_functions.cc in libcommon.la 2024-02-07 20:30:53 -05:00
Aliaksey Kandratsenka 7756b4cc61 don't force TMPDIR on all unittests
Turns out at least on FreeBSD tmpfile will fail if TMPDIR points to
non-existant directory. This also has nice property of leaving it down
to users to set up TMPDIR the way they want.
2024-02-07 19:35:37 -05:00
Aliaksey Kandratsenka c52c321bdd replace raw printer with usage of generic writer facility 2024-02-07 15:46:54 -05:00
Aliaksey Kandratsenka 59f0247033 liberate sampler_test from linking to libtcmalloc
This test is exercising purely sampling interval logic.
2024-02-07 15:45:25 -05:00
Aliaksey Kandratsenka a02ac30bbf rework and optimize structure of Makefile.am
There were far too many intermediate libraries, references to obsolete
libtool bugs and whatnot.

We now have libcommon.la as a convenience archive that contains
spinlock, logging and misc stuff. A number of unit tests that need
those facilities are being linked to this.

Then we have libstacktrace.la convenience archive, since it is used by
libtcmalloc.la and libprofiler.la.

And after that we're simply directly creating our main library
products: libtcmalloc_minimal{,_debug}.la, libtcmalloc_{,debug}.la,
libprofiler.la etc.
2024-02-07 15:45:22 -05:00
Aliaksey Kandratsenka 771a01ed28 rework and simplify emergency malloc integration
We now wrap StackTraceScope thingy in tcmalloc-specific parts, instead
of automagically inside every stacktrace.cc function. TCMalloc bits
all need to grab stacktraces via newly introduced
tcmalloc::GrabBacktrace (which handles emergency malloc wrapping).

New approach eliminates the need for doing fake stacktrace scope. CPU
profiler, being distinct .so library couldn't take advantage of
emergency malloc anyways.

This simplifies the build further and eliminates another potential
point of runtime divergence when stacktrace is linked to both
libprofiler and libtcmalloc.
2024-02-05 14:27:02 -05:00
Aliaksey Kandratsenka 4be76ab707 drop symbols weakening step
It has questionable value and most importantly, it was broken lots of
years without anyone complaining. So lets get things simpler.
2024-02-05 00:00:00 -05:00
Aliaksey Kandratsenka ca50448a1e drop export-symbols-regex stuff for libstacktrace.la
It has no effect, because libstacktrace.la is convenience archive, not
a library we install.
2024-02-04 23:56:08 -05:00
Aliaksey Kandratsenka ba3d790855 drop running pprof -test as part of make check
Not needed anymore.
2024-02-04 23:46:39 -05:00