Search Typeahead Q: Can frequent writes affect read efficiency?
But in our design goals we have not given importance to consistency right.
as consistency is not that important, a write doesnt have to lock anything, in the worst case, it will not be taken into account when somebody wants to read the same node (he will get an outdated most frequent completion that was one of the 5 most frequent couple of seconds ago, but isnt anymore - not a big deal)
Read efficiency can be optimized by caching. The problem here is write efficiency which is more difficult to optimize without decreasing consistency by sampling. Trie persistency should also be considered.
Also, as nodes are never deleted, we do not need to lock the whole node, but only child node pointers and top5 vector of node, although this can increase memory usage. These granular locks will decrease probability of waiting for a lock.