slobdell | 9 years ago | on: Building a CQRS/ES web application in Elixir using Phoenix
slobdell's comments
slobdell | 9 years ago | on: How to find size of an array in C without sizeof
slobdell | 9 years ago | on: Thread-Safe Lock Free Priority Queues in Golang
slobdell | 9 years ago | on: Thread-Safe Lock Free Priority Queues in Golang
Channels end up locking under the hood as well, so from a purity standpoint I wanted to avoid those...if channels are indeed faster, then clearly I need to rework my approach.
slobdell | 9 years ago | on: Thread-Safe Lock Free Priority Queues in Golang
Average runtime of insertion is constant time because the size of the linked list does not grow beyond a certain size, and inserting into the priority queue is constant. The worst case is not infinity because there is always at least one goroutine making progress.
Thank you for the comment about wanting to see posts like this :)
I do not think this implementation is flawed from the standpoint that at least one goroutine is making progress, there are no locks, and results are returned in order if dequeues are not saturated
This is not something that would make it to a white paper because the implementation does not return deterministic results, and I could not explain from a mathematical standpoint how flawed the results are returned because they're not guaranteed to be in order.
I should have also included the profiling results. Currently 25% of time is spent garbage collecting, which is expected because the priority queues effectively use multi-version concurrency control, but this will come in handy when I want to persist data to the hard drive with as little locking as possible (and for general simplicity in avoiding corruption)
Another 15% or so is spent sleeping, which would be the spinning loop part.