Commit 8919a1c
committed
runtime: remove locks around malloc()/free() in mpmalloc.c for glibc-based systems
This is due to following statement in the glibc manual:
To avoid corruption in multithreaded applications,
mutexes are used internally to protect the memory-management
data structures employed by these functions. In a multithreaded
application in which threads simultaneously allocate and free
memory, there could be contention for these mutexes. To scalably
handle memory allocation in multithreaded applications,
glibc creates additional memory allocation arenas if mutex
contention is detected. Each arena is a large region of memory
that is internally allocated by the system (using brk(2)
or mmap(2)), and managed with its own mutexes.
Having locks around them in the flang runtime library
can ruin optimization effort when tcmalloc is preloaded
to replace standard malloc()/free() implementation with the one
optimized for reducing lock contention.
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>1 parent fe5bda9 commit 8919a1c
1 file changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
| 26 | + | |
22 | 27 | | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| 35 | + | |
29 | 36 | | |
| 37 | + | |
30 | 38 | | |
| 39 | + | |
31 | 40 | | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
| |||
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| 50 | + | |
40 | 51 | | |
| 52 | + | |
41 | 53 | | |
| 54 | + | |
42 | 55 | | |
| 56 | + | |
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
| |||
48 | 62 | | |
49 | 63 | | |
50 | 64 | | |
| 65 | + | |
51 | 66 | | |
| 67 | + | |
52 | 68 | | |
| 69 | + | |
53 | 70 | | |
| 71 | + | |
54 | 72 | | |
55 | 73 | | |
56 | 74 | | |
| |||
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
| 80 | + | |
62 | 81 | | |
| 82 | + | |
63 | 83 | | |
| 84 | + | |
64 | 85 | | |
| 86 | + | |
65 | 87 | | |
0 commit comments