Re: [go-nuts] Re: Upgradable RLock

2023-02-13 Thread Robert Engels
ConcurrentHashMap works that way in Java. Multiple write locks on portions of the table and CAS/atomic reading. > On Feb 13, 2023, at 1:45 PM, 'drc...@google.com' via golang-nuts > wrote: > > Could you use an applicative data structure? (e.g., a balanced binary tree > where you allocate a n

Re: [go-nuts] Re: Upgradable RLock

2023-02-13 Thread 'drc...@google.com' via golang-nuts
Could you use an applicative data structure? (e.g., a balanced binary tree where you allocate a new spine for each insertion/deletion) That has log N overhead to read, log N storage allocated per write, but I think if you CAS the writes, the reads can proceed with a lightweight barrier. On Sun

Re: [go-nuts] Re: Upgradable RLock

2023-02-05 Thread Ian Lance Taylor
On Sun, Feb 5, 2023, 4:34 AM Juliusz Chroboczek wrote: > >> I took some time to put this to a test. The Go program here > >> https://go.dev/play/p/378Zn_ZQNaz uses a VERY short holding of the > >> lock - but a large % of runtime holding the lock. > > > Thanks for the benchmark. You're right: if

[go-nuts] Re: Upgradable RLock

2023-02-05 Thread Juliusz Chroboczek
>> I took some time to put this to a test. The Go program here >> https://go.dev/play/p/378Zn_ZQNaz uses a VERY short holding of the >> lock - but a large % of runtime holding the lock. > Thanks for the benchmark. You're right: if you have hundreds of > goroutines doing nothing but acquiring a re