I want to use llvm::DenseSet
in libswift_Concurrency.dylib
to optimise copying task-locals. Currently it is implemented using std::set
, which gives O(n*long(n))
performance. Usage of llvm::DenseSet
makes it O(n)
and improves constant factor.
std::set
- copying 10 items - 50ns/item, copying 1000 items - 80ns/itemllvm::DenseMap
- 35ns/item regardless of number of items
Surprisingly, std::unordered_set
has similar performance to std::set
.
But when trying to use it, I'm getting a linking error about missing __swift::__runtime::llvm::allocate_buffer(unsigned long, unsigned long)
. AFAICS, Swift has its own copy of the LLVMSupport
library with customised sources. And one of the customisation is that allocate_buffer
is not inline
.
LLVMSupport
compiles into a static library which then is linked into libswiftCore.dylib
and libswiftRemoteMirror
which do not link with each other.
But I need to use it in the libswift_Concurrency.dylib
which already links with libswiftCore.dylib
.
Should I make allocate_buffer
exported from libswiftCore.dylib
or should I link LLVMSupport
into libswift_Concurrency.dylib
?