Font Size: a A A

An Automated Refactoring Approach For Fine-grained Lock

Posted on:2021-09-09Degree:MasterType:Thesis
Country:ChinaCandidate:S ShaoFull Text:PDF
GTID:2518306461470304Subject:Computer Science and Technology
Abstract/Summary:PDF Full Text Request
Lock is frequently used to guarantee the correctness of shared resources access in concurrent programs.However,concurrent programs based on locks are susceptible to lock contention which would result in low performance and poor scalability.Inappropriate granularity of a lock makes lock contention even worse.It is generally accepted that employing a coarse-grained lock may exacerbate lock contention while a fine-grained lock may mitigate lock contention by decreasing the waiting time of other threads that attempt to acquire the lock.However,writing a program based on a fine-grained lock is much more difficult compared with that based on a coarse-grained lock,which requires careful design and expertise.Furthermore,when developers are required to maintain existing code that has coarse-grained locks,it would be error-prone and tedious to convert existing coarse-grained locks to fine-grained ones manually.This inspires us to develop an automation tool to help developers refactor code by converting coarse-grained locks into the fine-grained lock with the hope of reducing lock contention.As coarse-grained locks have a negative impact on the scalability of concurrent programs and shortcomings of manual refactoring,this paper proposes an automatic refactoring approach to convert a coarse-grained lock into a fine-grained one.Several static analyses,such as visitor pattern analysis,alias analysis,and side-effect analysis are employed in this approach.The read and write pattern of a critical section is inferred by side effect analysis,and then a pushdown automaton is proposed to identify the read and write pattern.Finally,refactoring is conducted based on these results.We implement an automatic tool FLock as the Eclipse plug-in.Our approach is evaluated by eleven open-source projects including HSQLDB,Jenkins and Cassandra,by presenting results such as the number of refactored locks,changed lines of code,refactoring time,accuracy,program performance after refactoring.We also compare FLock with the existing tools Relocker and CLOCK.The experimental results show that a total of 1757 built-in monitors are refactored and each refactoring takes an average of 17.5 seconds.The experiments reveal that our tool can help developers convert coarse-grained locks into fine-grained locks effectively.
Keywords/Search Tags:Fine-grained lock, Read-write lock, Refactoring, Pushdown automaton, Program analysis
PDF Full Text Request
Related items