Mastodon Feed: Post

Mastodon Feed

dysfun@treehouse.systems ("gaytabase") wrote:

hey @jsbarretto my bestie bestie, here's 200 lines of terrifying lock free dysfuncode in a language you've probably never programmed before, could you please review it for correctness, particularly the fences? :blobfoxpleading:

seriously though, i would most appreciate it if you have the time :blobfoxheart:

it's heavily inspired by epoch based reclamation, but it isn't quite that. it's relatively straightforward and about as simple as i can reasonably make it - i think it's pretty neat, dare i even say elegant?

  • single writer copy on write
  • monotonically increasing transaction ids.
  • reclamation of pages is bounded by the lowest active transaction id.
  • up to 64 reader threads arranged over 8 shards
  • readers maintain their shard's conservative approximation of lowest active txid when updating their slot.
  • new readers recheck against the current transaction id to ensure consistency
  • writer takes min over the approximations.
  • monotonic is llvm-speak for relaxed

https://gist.github.com/jjl/5a1f4bb4f1f802b42abef6d2e973c77d

as an aside, you can probably guess where i'll be going next with this - each thread will have a local set of pinned tasks or whatever the fuck it is we use instead of them in zig. but that's much easier than this of course.