Commit Graph

988 Commits

Author SHA1 Message Date
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
Aliaksey Kandratsenka
144c118f92 drop outdated comment in Makefile.am 2024-02-04 23:42:58 -05:00
Aliaksey Kandratsenka
e262ebc741 ship everything under vsprojects/ in make dist
We also drop all those WINDOWS_PROJECTS amends and simplify makefile.
2024-02-04 23:38:18 -05:00
Aliaksey Kandratsenka
b49920ea64 don't bother listing every header in Makefile.am
For compiling things automake never needs to be given a full set of
headers. Usually headers are specified so that make dist includes them
into archive, but we can achieve this goal easier.

This reduces size and complexity of our Makefile.am stuff.
2024-02-04 23:20:35 -05:00
Aliaksey Kandratsenka
1331c0e0d1 drop long deprecated google/ headers 2024-02-04 21:54:46 -05:00
Aliaksey Kandratsenka
a05bab586a align CentralFreeList on cache line size instead of just 64
We had hardcoded size alignment on 64 bytes, seemingly to avoid
cacheline contention when taking per-size-class central free list
locks. But it makes more sense to do platform specific alignment.

I did consider std::hardware_constructive_interference_size, but
practical values seem to differ from what we have configured at least
on some platforms.
2024-02-04 19:33:12 -05:00
Aliaksey Kandratsenka
353816fd9d drop LINKER_INITIALIZED in favor of constexpr constructors 2024-02-04 19:18:33 -05:00
Aliaksey Kandratsenka
247b7f3370 use std::thread when spawning threads in tests 2024-02-04 16:39:02 -05:00
Aliaksey Kandratsenka
2e5ecb4de6 amputate src/base/simple_mutex.h
Use standard mutex instead
2024-02-04 16:38:21 -05:00
Aliaksey Kandratsenka
885dd867bc liberate code base from legacy fixed size int types
I.e. all those int32 etc type (without _t at the end). We stick to
standard. Google/Abseil code base has long been liberated as well.
2024-02-04 15:47:21 -05:00
Aliaksey Kandratsenka
de22f024fb globally replace COMPILE_ASSERT with static_assert 2024-02-04 15:05:45 -05:00
Aliaksey Kandratsenka
c56764c3e6 tcmalloc_unittest: do 64-bit shift when computing alignment
Thanks goes to MSVC for warning about this.
2024-02-04 14:55:25 -05:00
Aliaksey Kandratsenka
329e9adfa6 fix MSVC warning on flexible data member extension 2024-02-04 14:55:10 -05:00
Aliaksey Kandratsenka
f910729012 turn inline ATTRIBUTE_ALWAYS_INLINE -> ALWAYS_INLINE
gcc needs both inline and __attribute__((always_inline)), while MSVC
only needs __forceinline. So relevant correct combination is now just
ALWAYS_INLINE macro.
2024-02-04 14:53:52 -05:00
Aliaksey Kandratsenka
57660e6a54 fix MSVC warning on thread annotations 2024-02-04 14:53:34 -05:00
Aliaksey Kandratsenka
5ec6f60bd7 suppress thread-safety warning for ThreadCachePtr
It is slightly less great that we have to disable thread-safety
analysis, but they explicitly say that optional locking is not
supported. And ours is very explicitly optional locking. I.e. we only
let ourselves resort to slow locking very early during process
startup, when TLS isn't 100% ready and safe to use yet.
2024-02-04 13:43:57 -05:00
Aliaksey Kandratsenka
78e7b959a7 fix clang warning for CreateBadTLSCache 2024-02-04 13:42:38 -05:00
Aliaksey Kandratsenka
21e66f807c enable -Wthread-safety for clang 2024-02-04 13:37:53 -05:00
Aliaksey Kandratsenka
2d35232cfa avoid unused variable warning for bucket_count 2024-02-04 13:23:16 -05:00
Aliaksey Kandratsenka
c59b431b28 use std::get_new_handler when handling OOM
Previously when dealing with OOM condition we couldn't use
std::get_new_handler (it didn't exist until c++ 11). Now we can and it
simplifies logic a bit.

We also detect -fno-exceptions case via standard __cpp_exceptions
define. Also I've rearranged the logic and even found and fixed one
bug in -fno-exceptions case.
2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka
04a8a4bae6 actually verify that we're deallocating thread caches 2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka
6691226953 split and rewrite TLS access for thread caches
Logic was removed from thread_cache.{h,cc} into
thread_cache_ptr.{h,cc}.

Separation will help possible future evolution, and we already changed
the logic quite a bit:

* early access (when TLS isn't initialized yet) now uses global
ThreadCache instance. We therefore have ThreadCachePtr instances
managing required locking. This eliminates unnecessary complication of
PTHREADS_CRASHES_IF_RUN_TOO_EARLY logic, and any other danger of
touching TLS too early. BTW previous implementation actually leaked
initial early-initialized ThreadCache instance(!)

* old configure-time HAVE_TLS logic is amputated. Config-time part of
it made little sense as C++ 17 guarantees availability of
thread_local, but we have manually curated deny-list of "bad" OSes,
that we tested (via compile checks!) at configure time. Now this
is all compile time. There is now compile-time kHaveGoodTLS variable
and we're using it mostly via if constexpr.

* kHaveGoodTLS case of creating thread cache is simplified and made
more straightforward (no need to have in_setspecific logic).

* !kHaveGoodTLS case if fixed and improved too. We avoid
std:🧵:get_id, as it deadlocks on mingw. We use errno address as
a portable and (usually) async-signal safe 'my thread' identifier. We
also eliminate linear searching of thread's cache and replace it with
straightforward hash table lookup.
2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka
104e2dd228 improve page_allocator debug diagnostics
Lets clear objects that we're freeing. Helps catch use-after free for
our internal memory allocations.
2024-02-03 14:20:07 -05:00
Aliaksey Kandratsenka
d0b0134c45 drop perftools_vsnprintf wrapper
Because everyone now has functional and standards compiliant vsnprintf.
2024-01-30 17:18:12 -05:00
Aliaksey Kandratsenka
51d3340b39 avoid -Wunused-results warnings from read/write
glibc with _FORTIFY_SOURCE sets those up to give warnings on unused
results. We used to disable this warning globally, but lets do better.
2024-01-30 17:08:29 -05:00
Aliaksey Kandratsenka
1eb2d1a604 bump msvc projects to VS2019 and c++ 17 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka
82a36a6fcd bump required c++ standard to c++-17 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka
faf96cd81e reflect renaming src/tcmalloc{,_internal}.h in MSVC projects 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka
71b3a0c6c4 unreak gperftools/tcmalloc.h inclusion in MSVC projects 2024-01-30 15:53:10 -05:00
Aliaksey Kandratsenka
5db2adc4e7 drop stale workaround for ancient solaris issue 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
5ce342e1c8 fix generic_writer_test and proc_maps_iterator_test on cmake+msvc 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
468ccf3d0d refactor and cleanup proc_maps_iterator.cc
We don't need messed up ProcMapsIterator class. Since our API has been
simplified we simply have one "for-each" function for each
implementation.
2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
a3080fa8d6 extract proc-maps iteration into own file and cover it by tests
This allows us, later, to avoid building this stuff in configurations
that don't use it. I have also reduced API and ABI surface to enable
further refactorings.
2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
fa5c61f52e stop trying to declare madvise on solaris
It isn't needed on modern opensolaris. And in fact it breaks the
build. And I am not entirely sure how to accomodate both old and new
behavior. So lets keep things simple and assume that old
behavior (where madvise needs to be declared) is ancient enough.
2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
f22f5b2a63 workaround broken mmap allocator on solaris 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
7d37882df0 implement GetProgramInvocationName for solaris 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
689752dc38 generate vsprojects/gperftools/tcmalloc.h from our main tcmalloc.h
This will save me from risk of forgetting to update this file manually
when bumping package version.
2024-01-29 21:00:20 -05:00
Aliaksey Kandratsenka
d6728a0b4c drop unused PACKAGE_XYZ defines from {cmake/vsproject}/config.h
Automake or autoconf adds them automagically, but we don't really need
them. Main effect of this change is that MSVC version of config.h
doesn't duplicate package version.
2024-01-29 20:58:02 -05:00
Aliaksey Kandratsenka
1eeea50f89 don't use config.h PACKAGE_{VERSION,STRING} in tcmalloc_unittest
It makes a lot more sense to test our public API which is
TC_VERSION_STRING.
2024-01-29 20:57:12 -05:00
Aliaksey Kandratsenka
3e328e4058 unbreak make dist 2024-01-29 20:16:39 -05:00
lennoxho
9a6848de8a A number of cleanups
* Remove build dependency on HAVE_PTHREAD
* Remove build dependency on HAVE_STD_ALIGNED_VAL_T and ENABLE_ALIGNED_NEW_DELETE
* Remove redundant tcmalloc.h files & ensure there are no cross-build-tool references
* Adopt automake commit 26927d1 in the CMake build
2024-01-29 17:15:53 -08:00
Aliaksey Kandratsenka
8b34e9425c unbreak freebsd build 2024-01-26 17:03:20 -05:00
lennoxho
96f34120fe Several build fixes and cleanups
- Fix CMake builds for MinGW and MSVC
- Ensure the Autotools, CMake and VSProj builds do not reference each others' config.h
- Use std:🧵:id instead of our own thread ID wrappers
- Moved explicit TLS wrapper functions into the tcmalloc:: namespace and change their visibility to hidden
Resolves #1486
2024-01-26 16:56:17 -05:00
Aliaksey Kandratsenka
ec4aa0367c support %zx format in TracePrintf 2024-01-26 16:56:17 -05:00
Aliaksey Kandratsenka
d7dd9ea824 added missing include in generic_writer.cc
We use std::min which require <algorithm> to be included.
2024-01-26 16:52:32 -05:00
Aliaksey Kandratsenka
79b6ad2ab5 amputate HAVE_FORK checking
Pretty much everything has fork, except windows. Which is much simpler
to test at compile time, then duplicating and complicating the test at
configure time.
2024-01-25 16:10:30 -05:00
Aliaksey Kandratsenka
8cc2d93055 drop unnecessary pid_t/getpid dependencies
It simplifies our windows story because pids stuff is different
there. And we're not really using it anyways.
2024-01-25 16:04:31 -05:00
Aliaksey Kandratsenka
789fadc763 drop pid_t dependency in ProcMapsIterator and simplify it
Original code was lifted from google-internal bits and perhaps those
needed that feature (dumping other process-es proc-maps files). But
our usage which is long-forked from theirs has always been to dump our
own maps. So this complexity was never useful for us.
2024-01-25 16:04:31 -05:00
Aliaksey Kandratsenka
913f70b66e drop disabled chunk of tcmalloc_unittest.cc 2024-01-25 16:04:31 -05:00