The current impl is quite simple: hold a lock briefly while allocating new memory.
(Conceptually the bump-allocator can be implemented without locks using atomic incr', but looking at the current impl, I kind of got discouraged as it seemed too complex)
Performace data: (profiling chromium-framework):
x ./lld_macho_base
+ ./lld_macho_safe_alloc
SYSTEM CPU time:
N Min Max Median Avg Stddev
x 5 0.73 0.83 0.79 0.79 0.037416574
+ 5 0.71 0.88 0.77 0.784 0.062689712
No difference proven at 95.0% confidence
USER CPU time:
N Min Max Median Avg Stddev
x 5 3.62 3.73 3.65 3.66 0.043588989
+ 5 3.74 3.86 3.84 3.816 0.053665631
Difference at 95.0% confidence
0.156 +/- 0.0712998
4.2623% +/- 1.94808%
(Student's t, pooled s = 0.0488876)
WALL time:
N Min Max Median Avg Stddev
x 5 4.56 4.61 4.59 4.588 0.019235384
+ 5 4.68 4.74 4.72 4.714 0.024083189
Difference at 95.0% confidence
0.126 +/- 0.031786
2.74629% +/- 0.692808%
(Student's t, pooled s = 0.0217945)Use case:
LLD-macho occasionally allocate memory in multiple threads.