Skip to content

Commit 1a28e35

Browse files
committed
Use good locks in dlmalloc
Using mere spin locks causes runitd.com to go painstakingly slow on NetBSD for reasons that aren't clear yet.
1 parent 80fca1f commit 1a28e35

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

third_party/dlmalloc/dlmalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define HAVE_MREMAP 0
3333
#define HAVE_MORECORE 0
3434
#define USE_LOCKS 2
35+
#define USE_SPIN_LOCKS 0
3536
#define MORECORE_CONTIGUOUS 0
3637
#define MALLOC_INSPECT_ALL 1
3738
#define ABORT_ON_ASSERT_FAILURE 0

third_party/dlmalloc/locks.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
*/
3131

32-
#ifdef USE_SPIN_LOCKS
32+
#if USE_SPIN_LOCKS
3333

3434
#define MLOCK_T atomic_uint
3535

@@ -62,11 +62,13 @@ static int malloc_wipe(MLOCK_T *lk) {
6262
}
6363

6464
static int malloc_lock(MLOCK_T *lk) {
65+
if (!__threaded) return 0;
6566
nsync_mu_lock(lk);
6667
return 0;
6768
}
6869

6970
static int malloc_unlock(MLOCK_T *lk) {
71+
if (!__threaded) return 0;
7072
nsync_mu_unlock(lk);
7173
return 0;
7274
}

0 commit comments

Comments
 (0)