Open varungandhi-src opened 1 year ago
Writing down some design notes here, because I think we should do this, but there are non-trivial data dependencies.
(Nw = number of workers)
One potential design which avoids fine-grained synchronization:
pair<SymbolName, PointerUnion<SymbolInformation *, SymbolInformationBuilder *>>
vectors in a Nw x Nw matrix, rows for workers, columns based on hash(SymbolName) % Nw.PointerUnion<SymbolInformation *, SymbolInformationBuilder *>
) maps based on hash(SymbolName) % N.We could perhaps have some abstraction similar to the WorkerPool in Sorbet, utilizing an SPMC/MPMC queue for implementing work-stealing.
Potential tweaks to above:
flat_hash_map
, since values are required to be MoveConstructible, but a mutex doesn't satisfy that. We could use a separate vector holding pair<absl::Mutex, PointerUnion<...>>
and store indexes into that as the map values in step 2.
Preliminary numbers (based on indexing LLVM):
(The 100/1000 scaling figure should not be taken literally due to varying amounts of code across TUs.)
This is for a 10 core machine (dev MacBook Pro). The ratio will go down for higher core count machines.
We should be able to parallelize merging based on documents.
For communicating between threads, we could probably use https://github.com/rigtorp/SPSCQueue