I think you have to go a bit more and use a RW mutex to ensure memory 
consistency (for the simple solution). 

> On Jan 5, 2021, at 8:52 PM, joseph.p...@gmail.com 
> <joseph.p.mcguc...@gmail.com> wrote:
> 
> Well, I think I only need to lock on writes, and it'll be easier if I just 
> lock the entire tree on writes. Reads will be the majority of the operations 
> by far. This is for a bit of caching before we go to a K/V database like 
> REDIS, etc.
> 
>> On Tuesday, January 5, 2021 at 5:16:36 PM UTC-8 k.alex...@gmail.com wrote:
>>> On Tue, Jan 5, 2021, 6:59 PM Nathan Fisher <nfi...@junctionbox.ca> wrote:
>> 
>>> Does write only locking provide read correctness? I would’ve thought based 
>>> on the memory model it could cause issues?
>>> 
>>> https://golang.org/ref/mem#tmp_2
>> 
>> 
>> It depends on your notion of "read correctness", specifically when you 
>> consider each read to have occurred with respect to its concurrent writes. 
>> Linearizability may be a weaker guarantee than you want, and that's okay.
>> 
>> Linearizability requires that, for each operation, you can pick some point 
>> between the start and end of an operation when it can be said to have 
>> "occurred". When you consider all the operations in that order, the results 
>> you see must be the same as a sequential execution.
>> 
>> In the case I have described, we can pick a linearization point for reads 
>> just before the last write which they passed on their way down the tree. The 
>> reads should then see all the writes which happened prior to this point.
>> 
>> This isn't the order the operations enter the root, but linearizability 
>> doesn't care. It doesn't have an opinion on when overlapping operations 
>> "occur" with respect to one another.
>> 
>> I don't think using a happens-before relation for the program order seen by 
>> each goroutine is going to cause a problem with respect to choosing these 
>> linearization points, but maybe I'm missing something.
>> 
>> Maybe also there is a standardized notion of read correctness that you're 
>> referring to which I am not aware of.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/8d97ad06-f7e6-4fdd-8ec4-0803e0ad3dd1n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/D6C66957-9435-45E3-9D7C-BE654F1A578B%40ix.netcom.com.

Reply via email to