Automatic time-bound analysis for a higher-order language

Gustavo Gómez, Yanhong A. Liu
2002 Proceedings of the 2002 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation - PEPM '02  
Analysis of program running time is important for reactive systems, interactive environments, compiler optimizations, performance evaluation, and many other computer applications. It has been extensively studied in many elds of computer science: algorithms 21, 12, 1 3 , 4 0 , programming languages 38, 2 2 , 3 1 , 35, 3 4 , and systems 36, 2 9 , 3 3 , 3 2 . Being able to predict accurate time bounds automatically and e ciently is particularly important for many applications, such as reactive
more » ... ems. It is also particularly desirable to be able to do so for high-level languages 36, 2 9 . Since Shaw proposed timing schema for analyzing system running time based on high-level languages 36 , a n umb e r o f p e o p l e h a ve extended it for analysis in the presence of compiler optimizations 29, 9 , pipelining 16, 2 3 , cache memory 3, 23, 1 1 , etc. However, there is still a serious limitation of the timing schema, even in the absence of low-level complications. This is the inability t o p r o vide loop bounds, recursion depths, or execution paths automatically and accurately for the analysis 28, 2 . For example, the inaccurate loop bounds cause the calculated worst-case time to be as much as 67 higher than the measured worst-case time in 29 , while the manual way o f providing such information is potentially an even larger source of error, in addition to being inconvenient 28 . Various program analysis methods have been proposed to provide loop bounds or execution paths 2, 10, 1 5 , 1 7 . However, they apply only to some classes of programs or use approximations that are too crude for the analysis. Also, separating the loop and path information from the rest of the analysis is in general less accurate than an integrated analysis 27 . Liu and G omez 24 studied a general approach for automatic and accurate time-bound analysis that combines methods and techniques studied in theory, languages, and systems. They call it a language-based approach since it primarily exploits methods and techniques for static program analysis and transformation. However, the particular analysis there handles only rst-order functions. Being able to handle higher-order functions is important for analyzing most functional languages and for analyzing methods in object-oriented languages with inheritance. This paper extends the language-based approach to a higher-order language. As before 24 , the approach consists of transformations for building time-bound functions in the presence of partially known input structures, symbolic evaluation of the time-bound function based on input parameters, optimizations to make the analysis e cient a s w ell as accurate, and measurements of primitive parameters, all at the source-language level. To handle higher-order functions, special transformations are needed to build lambda expressions for computing running times, to optimize the construction of the time lambda expressions, and to optimize the symbolic evaluation. We describe analysis and transformation algorithms and explain how they work. We have implemented this approach and performed a large number of experiments analyzing Scheme programs. The measured worst-case times are closely bounded by the calculated bounds. We describe our prototype system, ALPA, as well as the analysis and measurement results.
doi:10.1145/503032.503039 dblp:conf/pepm/GomezL02 fatcat:w2rwyd5zqrfejfychqispze55a