summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Watson <davejwatson@fb.com>2017-10-13 17:27:13 (GMT)
committerDave Watson <davejwatson@fb.com>2017-11-14 16:58:18 (GMT)
commitd6feed6e6631d00806607cfe16a796e337752044 (patch)
tree4186aaf4ba5c325312f3faaa709a955b15be253c /src
parentcb3b72b9756d124565ed12e005065ad6f0769568 (diff)
downloadjemalloc-d6feed6e6631d00806607cfe16a796e337752044.zip
jemalloc-d6feed6e6631d00806607cfe16a796e337752044.tar.gz
jemalloc-d6feed6e6631d00806607cfe16a796e337752044.tar.bz2
Use tsd offset_state instead of atomic
While working on #852, I noticed the prng state is atomic. This is the only atomic use of prng in all of jemalloc. Instead, use a threadlocal prng state if possible to avoid unnecessary cache line contention.
Diffstat (limited to 'src')
-rw-r--r--src/tsd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tsd.c b/src/tsd.c
index f968992..c143068 100644
--- a/src/tsd.c
+++ b/src/tsd.c
@@ -71,6 +71,16 @@ tsd_data_init(tsd_t *tsd) {
*/
rtree_ctx_data_init(tsd_rtree_ctxp_get_unsafe(tsd));
+ /*
+ * A nondeterministic seed based on the address of tsd reduces
+ * the likelihood of lockstep non-uniform cache index
+ * utilization among identical concurrent processes, but at the
+ * cost of test repeatability. For debug builds, instead use a
+ * deterministic seed.
+ */
+ *tsd_offset_statep_get(tsd) = config_debug ? 0 :
+ (uint64_t)(uintptr_t)tsd;
+
return tsd_tcache_enabled_data_init(tsd);
}