Commit Graph

29 Commits

Author SHA1 Message Date
Bartosz Taudul
a90004b983 Move Set/GetThreadName() to Tracy API. 2020-01-25 16:36:58 +01:00
Bartosz Taudul
3c4a7463b8 Retrieve proper thread ids on BSD. 2019-11-21 02:29:17 +01:00
Bartosz Taudul
6bbf273581 Partial header inclusion cleanup. 2019-11-05 20:09:40 +01:00
Bartosz Taudul
fd245bb5df Fix includes for gettid() on android. 2019-08-19 15:09:47 +02:00
Bartosz Taudul
71b54dd48a Always collect thread names.
This fixes an issue when a thread was destroyed before its name could be
retrieved.
2019-08-14 16:52:04 +02:00
Bartosz Taudul
92b6da7cc2 SetThreadName() only works on the current thread.
This breaking change is required, because kernel trace facilities use
kernel thread ids, which are inaccessible from the pthread_t level.
2019-08-14 02:22:45 +02:00
Bartosz Taudul
339b7fd2a6 Use kernel thread ids on linux. 2019-08-14 01:57:36 +02:00
Bartosz Taudul
8ce41b3543 Proper init order of thread local thread handle. 2019-06-26 19:32:52 +02:00
Bartosz Taudul
bc7f2c49c8 GetThreadHandle() might be used by application's code. 2019-06-25 15:44:49 +02:00
Bartosz Taudul
a56c47a6a0 Store thread handle in a thread local variable.
This saves us a non-inlineable function call. Thread local block is
accessed anyway, since we need to get the token, so we already have the
pointer and don't need to get it a second time (which is done inside
Windows' GetCurrentThreadId()). We also don't need to store the thread
id in ScopedZone anymore, as it was a micro-optimization to save us the
second GetThreadHandle() call.

This change has a measurable effect of reducing enqueue time from ~10 to
~8 ns.

A further optimization would be to completely skip thread handle
retrieval during zone capture and do it instead on retrieval of data
from the queue. Since each thread has its own producer ("token"), the
thread handle should be accessible during the dequeue operation. This is
a much more invasive change, that would require a) modification of the
queue, b) additional processing of dequeued data to inject the thread
handle.
2019-06-24 19:19:47 +02:00
Bartosz Taudul
46b75c5a19 Only enable tracy-internal GetThreadHandle if tracy is enabled. 2019-06-24 19:18:52 +02:00
Rokas Kupstys
9bd1037347 Clean up imported functions in multi-dll projects. 2019-06-07 19:50:08 +03:00
Bartosz Taudul
d560f7a203 Cosmetics. 2019-02-19 19:36:30 +01:00
Rokas Kupstys
01df5aa840 Fix targetting lower windows versions when using W10 SDK that is older than redstone2. 2018-07-19 11:08:41 +03:00
Rokas Kupstys
d290e04d45 Fix build when targeting earlier windows versions by defining _WIN32_WINNT. 2018-07-17 20:15:27 +03:00
Arvid Gerstmann
ebd1d00178 Correctly forward declare Win32 functions
_WINDOWS_ is the macro defined by the windows.h header guard,
checking it whether the symbols have already been included before
forward declaring our own.
2018-07-13 23:39:58 +02:00
Bartosz Taudul
94c9c89ad0 Enable thread name collection on old windows SDKs. 2018-06-22 00:23:50 +02:00
Bartosz Taudul
48e82ea135 Workaround pthreads thread name limit. 2018-03-31 01:22:21 +02:00
Bartosz Taudul
7ecc6b54d4 Proper pthread_threadid_np call. 2017-11-03 11:12:17 +01:00
Bartosz Taudul
c7cb89307f Use proper __APPLE__ macro. 2017-11-03 11:09:31 +01:00
Bartosz Taudul
1d9542ea25 Fix thread ids on osx, iphone. 2017-11-03 10:49:49 +01:00
Bartosz Taudul
7b8747ce21 Collect thread names on osx, iphone. 2017-11-02 13:02:04 +01:00
Bartosz Taudul
3aaa718741 Enable thread name collection on cygwin.
It was working before, because there was _GNU_SOURCE define injection.
Without this macro defined pthread_[gs]etname_np() functions are not
exposed in the API.
2017-10-30 21:57:45 +01:00
Bartosz Taudul
cf3d8eb810 Manual collection of thread names on android. 2017-10-30 20:45:00 +01:00
Bartosz Taudul
1788408ceb Allow setting thread name using thread handle. 2017-10-16 21:17:58 +02:00
Bartosz Taudul
75457c1465 Remove +x flag from files. 2017-10-10 21:56:15 +02:00
Bartosz Taudul
809d98162b Do the same trick as concurrentqueue.h for GetCurrentThreadId(). 2017-09-26 00:46:46 +02:00
Bartosz Taudul
206305fbd2 Merge TracyThread.hpp to TracySystem.cpp.
Keeping threading functions inside a source file prevents poisoning by
including windows.h.
2017-09-25 21:13:59 +02:00
Bartosz Taudul
45646c4f45 Move TracySystem to a common directory. 2017-09-13 01:32:11 +02:00