Global Variable Initialization Optimization for Application Launch Time
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional programming techniques result in prolonged application launch times due to the inability to determine if global variables will be used, leading to unnecessary initialization code execution, and inefficient placement of initialization code, which slows down the launch process.
Innovation Solution
Converting global variables to local static variables by wrapping them with newly created functions, allowing initialization only when the respective function is called, and using a link order file to efficiently order the initialization code, reducing the need for disk access during launch.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If initialization code for global variables is always generated during compilation, then all global variables are prepared for potential use, but application launch time increases due to executing unnecessary initialization code
Solution Approach 1:
The patent applies preliminary action by moving variable initialization from runtime (launch time) to compile-time. The system analyzes source code during compilation to identify which global variables are actually used, and only generates initialization code for those variables. This eliminates the need to initialize unused variables at launch time, thereby reducing application launch time while ensuring all actually-used variables are properly initialized.
Solution Approach 2:
The patent changes the parameter of initialization timing from runtime to compile-time. By performing static analysis during compilation to determine variable usage, the system transforms the initialization process from a runtime operation that affects launch time to a compile-time operation that optimizes the final executable. This parameter change allows the system to eliminate unnecessary initialization code while maintaining initialization completeness for used variables.
2Device complexity
If initialization code is placed randomly in the application program, then code placement flexibility is maintained, but disk access time increases due to paging different sections during launch
Solution Approach 1:
The patent applies merging by consolidating all necessary initialization code into a single contiguous section at the beginning of the application program. Instead of scattering initialization code throughout the executable, the system collects and combines all initialization operations into one location. This allows the entire initialization sequence to be loaded into memory in a single disk operation during launch, eliminating the need to page different sections and significantly reducing disk access time.
3Adaptability or versatility
If many global variables are defined in source code, then program functionality and data management are enhanced, but initialization code size and execution time increase proportionally
Solution Approach 1:
The patent applies extraction by removing unnecessary initialization operations from the initialization code section. The system performs static analysis to identify which global variables are actually used by the program, and extracts only those variables' initialization code into the launch-time initialization section. Unused variable initializations are completely removed, thereby reducing initialization code size and execution time while maintaining all necessary program functionality.
Data Source
AI summary
Modification of source code reduces a launch time associated with an application program so that the application program more quickly responds to input from a user after startup. One technique of modifying source code includes converting globally defined variables in the source code to local static variables associated with respective newly created functions. Inclusion of the globally defined variables in the source code impacts application launch time because a compiler creates initialization code associated with the globally defined variables that must be run at launch time to initialize the variables in case they are used by functions in the application program. On the other hand, local static variables are initialized when the function that contains them is first called. Thus, use of local static variables in respective newly created functions in lieu of globally defined variables reduce application program launch time.


