4 ms·
What about false sharing?
by checker659 13y ago
What about false sharing?
- jjh42 13y agoI only benchmarked and considered the single-threaded case. Multithreading is a whole new can of worms.
- warmfuzzykitten 13y agoTrivially, one could synchronize around the entire tree. However, if modified nodes are always copied, then the only node that matters is the root node (since there can never be a partially modified tree accessible from the root), which boils down to atomic update of a root node pointer. Should be very efficient. There is, of course, a performance implication of node copying, but it only affects add/delete/replace performance - read access runs at full speed - and it is cache-friendly, as well.
- jjh42 13y agoIf you want different threads to see the same data structure then I think you would also need a mechanism to prevent multiple threads modifying the same node and clobbering each other's changes.
- warmfuzzykitten 13y agoYes, of course. But there is a difference between read, which only requires synchronization at the root node, and write, which requires synchronization at the modified leaf and potentially all the way back up the path from leaf to root.
- hyc_symas 13y agoLMDB was written specifically for multi-threading; all of its shared data structures are cache-line aligned to prevent false sharing. This is also essential to allowing readers to run with no locks.