APP下载

面向异步机制的自动重构方法研究

2021-01-07纪铭涵齐林张杨董士程李朝帅

河北科技大学学报 2021年5期

纪铭涵 齐林 张杨 董士程 李朝帅

摘 要:為了解决并行处理中同步阻塞会浪费系统资源和影响程序性能的问题,提出了一种基于CompletableFuture异步机制的自动重构方法。首先,使用WALA静态程序分析工具进行访问者模式分析、逃逸分析、别名分析以及数据流分析等静态程序分析技术,确定共享变量数据的操作方式;然后,基于CompletableFuture机制设置4种异步重构模式;最后,根据不同模式实现异步机制的自动重构。基于此方法,在Eclipse平台下开发了自动重构工具AsynRef,并对HSQLDB,Jenkins,JGroups和SPECjbb2005等4个大型实际应用程序进行自动重构,从重构个数、改变的代码行数、准确性和重构后程序性能等方面对AsynRef进行评估,对4个程序所包含的919个同步方法共完成387个异步机制转换。结果显示,使用AsynRef进行异步机制重构后,程序执行性能有8%到39%的不同程度的提升。AsynRef可以有效完成代码异步化自动重构,与传统手动重构相比,有效提升了异步化的重构效率。

关键词:并行处理;同步机制;异步机制;静态程序分析;自动重构

中图分类号:TP311   文献标识码:A

doi:10.7535/hbkd.2021yx05008

收稿日期:2021-06-15;修回日期:2021-09-22;责任编辑:王淑霞

基金项目:国家自然科学基金(61440012);河北省自然科学基金(18960106D);河北省高等学校科学研究计划重点项目(ZD2019093)

第一作者简介:纪铭涵(1997—),女,河北邢台人,硕士研究生,主要从事并发处理、软件自动重构方面的研究。

通讯作者:张 杨副教授。E-mail:zhangyang@hebust.edu.cn

An automated refactoring approach for asynchronous mechanism

JI Minghan,QI Lin,ZHANG Yang,DONG Shicheng,LI Chaoshuai

(School of Information Science and Engineering,Hebei University of Science and Technology,Shijiazhuang,Hebei,050018,China)

Abstract:As synchronous blocking wastes system resources and affects program performance in concurrent processing,an automatic refactoring approach based on the asynchronous mechanism of CompletableFuture was proposed.Firstly,several static analyses by Wala static program analysis tool,such as visitor pattern analysis,alias analysis,and data flow analysis were used in this approach,so that the operation mode of shared variable data was determined.Then four asynchronous refactoring modes were set based on the asynchronous mechanism of CompletableFuture.Finally,the code was refactored according to different modes.An automatic tool AsynRef was implemented by Eclipse and four large-scale practical applications such as HSQLDB,Jenkins,JGroups,and SPECjbb2005 were automatically refactored by AsynRef.AsynRef was evaluated via the number of refactored locks,changed lines of code,accuracy,program performance after refactoring.Among the 919 synchronous methods contained in the four programs,387 asynchronous mechanism conversions were completed.After Asynref was used for asynchronous mechanism refactoring,the program execution performance was improved by 8% to 39%.AsynRef can refactor for aynchronized mechanism effectively.Compared to manual refactoring,the refactoring efficiency is improved significantly.

Keywords:

concurrent processing;synchronization mechanism;asynchronous mechanism;static program analysis;automatic refactoring

随着并发程序设计方法越来越多地被应用于多线程程序开发,为了保证程序的正确性,开发人员通过使用同步机制的方法进行控制,确保了程序正确稳健地运行。……

登录APP查看全文