170 likes | 289 Views
This document presents a verification study of a concurrent priority queue algorithm based on the lock-free Skip-List data structure. The review includes an exploration of the algorithm's design, which employs atomic compare-and-swap operations to ensure non-blocking behavior. Additionally, it details the verification process using a modified Java Path Finder (JPF), test implementation, challenges encountered (including memory errors), and future work to enhance reliability and efficiency. The analysis highlights significant findings, including the performance of existing solutions and the potential for thread interleaving.
E N D
Verification of a Concurrent Priority Queue Bart Verzijlenberg
Agenda • Brief Review • Verification Overview • Verification Results • Errors • Further Work • Conclusion
Brief Review • Priority Queue • Lock-free • Relies on atomic Compare and Swap operations
Algorithm Review • The algorithm uses the Skip-List data structure • Extends the Skip-List for concurrent use • The Skip-List is sorted on the priority of the nodes • The algorithm is lock-free • No blocking • Prevent dead locks • Always progress by at least one operation • Risk of starvation
Algorithm ReviewSkip-List • Multi-layer linked list • H forward pointers for a node of height h • Each pointer i points to the next node with a height of at least i
Inserting in a Skip-List Inserting 17 in the list
Verification Overview • Java Path Finder • Breadth-First Search • Depth-First Search • Modified JPF script • Increased stack size to 1536Mb • Vary the number of inserts/deletions • At what point does JPF crash?
Test Classes • Driver Class • Creates • N insertThreads • M deleteThreads • Insert Thread • Inserts a single number into the queue • Delete Thread • Loops until a single number removed from queue • Use of sleep important
Code Modifications • Maximum Level = 3 • Probabilistic level selection replaced with a random level • Probabilistic function calls random multiple times • Too many additional paths for JPF • Removed back-off period
A Note • At the end of the code • Print “End of Code” • Marks each time JPF reaches the end of a potential execution path • I consider each “End of Code” to correspond with a different thread interleaving (i.e. a path)
Verification Results • (1,2) = 1 Insert Thread, 2 Delete Threads
By Comparison • Implemented simple priority queue test • java.util.PriorityQueue • Not safe for concurrency • Synchronized insert statement using a lock on the queue • Able to test inserting 8 numbers quickly • 3713 Paths • Tested in 45 Min • Inserting 10 numbers • Crashed after 60791 Paths
What is the Difference? • Using synchronized method • Very few points where a thread can take over • I.e. When one thread is inserting, none of the others can insert at the same time • Lock Free • Threads can be interrupted after every instruction • This results in many more potential interleavings
Errors ! • java.lang.OutOfMemoryError: • GC overhead limit exceeded • More than 98% of time spent on GC • Recovering less than 2% of the heap • java.lang.OutOfMemoryError: • Java heap space • [SEVERE] JPF out of memory • [SEVERE] JPF exception, terminating: • class java.lang.NullPointerException: null
Further Work • Reduce Max level to 2 • Further reducing number of paths • Enable back-off function • Find linearization points in the code • Add each number into two queues at the same time • Try some of the other search classes
Conclusion • Testing at this point has not found errors • When inserting up to 2 numbers • When inserting 3 numbers (before crashing) • More work needed to reduce the chance of errors further • Will not eliminate completely
Thank You Questions?