Zulip Chat Archive

Stream: general

Topic: Reference counting and multithreading


Oleg M (Feb 03 2023 at 12:44):

I am sorry if this question appears to be stupid or already answered, but how exactly Lean does reference counting on multithreaded programs? Is it like Koka with atomics? Or there is something else?

Sebastian Ullrich (Feb 03 2023 at 12:57):

As far as I know Koka did not diverge from Lean 4 in that regard, yes. Objects marked as multi-threaded use acquire/release atomic operations. I don't know any realistic alternative.

Oleg M (Feb 03 2023 at 13:33):

Okay, I see, thank you!
I am just thinking that there might be another option, maybe with some lock-free approach. I think atomics might slow down things too much.

Sebastian Ullrich (Feb 03 2023 at 13:40):

Atomics are lock-free. Atomics are how you do lock-free usually.

Henrik Böving (Feb 03 2023 at 13:47):

Yeah lock free usually means you reduce your state to 64 bit and start having atomic read compare update ops.

Oleg M (Feb 03 2023 at 13:49):

I see. Thank you for answering.


Last updated: Dec 20 2023 at 11:08 UTC