Skip to content

Commit 4b0a3e3

Browse files
committed
data_race_checker: Added a note about performance
1 parent bdfcc89 commit 4b0a3e3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/scl/utils/data_race_checker.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@
4141
//
4242
// Wait-free? (maybe the CMPX is only lock-free?)
4343

44+
/** @note
45+
* There's a bit of a debate if using the stack pointer (address of a local variable)
46+
* is quicker than getting the thread ID. A rudimentary benchmark (below) shows
47+
* getting this is the same on clang 17 and GCC 13.2:
48+
* https://quick-bench.com/q/iTnk1X3mGYUQ2yryuK_Wcg6JJ6Q
49+
*
50+
* When detecting if there is a data-race, comparing thread IDs is very quick. I
51+
* would expect finding if two addresses are on the same stack is more costly as
52+
* it involves extra calls to get the base stack address. It's also more complex
53+
* in terms of code. Ultimately however, real-word benchmarks would need to be
54+
* created to compare without a data_race_checker, one using thread IDs and one
55+
* using addresses.
56+
*/
57+
4458
namespace scl {
4559

4660
#ifndef DATA_RACE_DETECTED

0 commit comments

Comments
 (0)