1. Field of the Invention
The present invention generally relates to a method and apparatus for dynamically optimizing an executable file, and more particularly dynamically optimizing a performance of an executable program having an executable code portion and a dynamic meta-data portion, the executable code portion and the dynamic meta-data portion being hard-linked together.
2. Description of the Related Art
A Java Virtual Machine (JVM) interprets an object code during a program's runtime, allocates memory, and performs other tasks. In order to increase the performance of the JVM, additional information, such as information regarding the behavior of the program to be executed, would be helpful. This information can include statistical data about the typical logical flow of the program. Because this logical flow is the same 90% of the time, and is therefore predictable, this information could lead to an increase in performance using conventional optimization methods.
A JVM is an interpreter that interprets object code during run time. Conventionally, a JVM is optimized by test-running the executable, or program. That is, test runs are executed and statistical data from those test runs are collected. From this test data, a compilation of the source code is optimized. However, in the conventional optimization, this generated executable information is then fixed. That is, it is permanently set, based on the data from the test runs.
In one example of a related, conventional optimization method, U.S. Pat. No. 6,480,862 (incorporated herein by reference) describes a method to organize objects in an object heap based upon access relationships among the data objects (e.g., based upon temporal proximity and/or relative frequencies of access), in order to reduce cache misses and page faults (optimization of object code). The aim of the conventional method is to place objects in the same memory page or cache line respectively when these objects are accessed in a short time range or are accessed frequently. The conventional method could even ensure that garbage collection cycles respect this organization of data objects.
In the conventional method, the information necessary for the placement of the data objects is automatically gathered either during a compiling time or during a runtime, but this information is not stored in the executable itself.
In view of the foregoing, and other, exemplary problems, drawbacks, and disadvantages of the conventional systems, it is an exemplary feature of the present invention to dynamically enhance an executable program by updating meta-data each time the program is executed. Exemplarily, a header containing additional meta-information is added to binary or executable files. Exemplarily, in each run of the program, the binary is executed with new, optimized statistical information, and therefore the executable program improves itself with each run.
In view of the foregoing, and other, exemplary problems, drawbacks, and disadvantages of the conventional systems, it is an exemplary feature of the present invention to dynamically enhance an executable program via a method having a program with an executable code portion and a dynamic meta-data portion, the executable code portion and the dynamic meta-data portion being hard-linked together and the dynamic meta-data portion being configured to enhance an operation of the executable code portion, the method including reading the meta-data, executing the executable code, optimizing the execution of the executable code based on the meta-data, collecting statistical data regarding an operation of the execution of the executable code, and updating the dynamic meta-data with the collected statistical data at an ending portion of the executable code.
An additional benefit of the present invention would be that “hints” are provided to interpreters to improve performance of program execution. These hints, or the meta-data, are stored with the executable itself and updated at each run. In addition, the optimized dynamic files are moved with the executable file and therefore the optimized files remain with the execution files.
Another benefit provided by exemplary aspects of the present invention is that the meta-data would be stored in the executable itself and that the meta-data is updated after each run, this means it improves dynamically with each code execution and cumulates the recorded statistical information.
Accordingly, an exemplary method/apparatus to organize data objects (and optimize the performance using standard prior art methods) based upon stored meta-data in the executable file itself (source code/binary instructions for interpreter) is provided.
The foregoing and other purposes, aspects and advantages will be better understood from the following detailed description of an exemplary embodiment of the invention with reference to the drawings, in which:
Referring now to the drawings, and more particularly to
In an exemplary embodiment of the present invention, a dynamic enhancement of an executable program is provided. Exemplarily, the meta-data of the executable program is enhanced or updated during the runtime of the executable, or program. Additional information that is separate from the program data itself would also be stored with or in the executable. As a result of updating the data, performance will be increased the next time the binary is executed, either as a Java Virtual Machine, or other interpreters.
Thus, executable 100 would include two programming portions, meta-data 110 and binary code instructions 120. Meta-data 110 would be used by the interpreter while executing binary code instructions 120 to increase performance of binary code instructions 120. On the other hand, the interpreter would also be collecting statistical data during the runtime to update meta-data 110 after binary code instructions 120 execution, so that the new, updated meta-data 110 contains improved information regarding an operation of binary code instructions 120.
In this manner, meta-data 110 would be exemplarily improved each time binary code instructions 120 are executed with new statistical information. As a result, a performance of executable 100 would be improved with each run. However, binary code instructions 120 would not be modified. Not modifying binary code instructions 120 guarantees that nothing is changed in the program logic itself. Instead, additional information on “how to execute the binary instructions best” is improved over time.
Because meta-data 110 and binary code instructions 120 are stored in the same executable 100, the two are “hard-linked” together and it is possible to distribute executables which are already optimized after being executed and containing some meta-data.
Exemplary embodiments of the present invention would be used for interpreters in general when executing programs. The behavior of the same software can be different in different environments. As a result of the phenomenon, it is not possible to optimize programs for all possible customer scenarios. A program could be optimized for one particular, or special, environment. However, by specializing that program, the specialized program would perform badly in another environment. Exemplary embodiments would allow the executable to be improved and optimized during its runtime and would be able to adapt itself to new environments.
At Step 210 of method 200, the executable program begins. At the start of the execution of the program in Step 210, Step 220 would then exemplarily include reading the meta-data from the dynamic portion of the program file. Exemplarily, in Step 230, an interpreter uses the meta-data to execute the instruction code, such as binary code instructions, to optimize program execution.
During operation of the executable program by the interpreter, Step 240 would exemplarily collect statistical data. This statistical data would then be used in Step 250 to update the meta-data. In addition, in either of Step 230 or Step 250, an optimization program may analyze the statistical data to further refine the program's execution.
Exemplarily, Step 250 would be performed closely before Step 260 ends the program's execution. Thus, performance and optimization information would be analyzed and stored when the program ends its run.
If Step 320 determines that the program does include the dynamic meta-data file, then method 300 proceeds to Step 330 to read the meta-data. Exemplarily, in Step 340, an interpreter uses the meta-data to execute the instruction code, such as binary code instructions, to optimize program execution.
If Step 320 determines that the program does not include a dynamic meta-data file, then method 300 proceeds to Step 322 to create a new, empty meta-data header to be included in the program file. Therefore, an executable not having an attached meta-data header would be provided with such a header.
Step 330 exemplarily includes reading the meta-data from the dynamic portion of the program file. Exemplarily, in Step 340, an interpreter uses the meta-data to execute the instruction code, such as binary code instructions, to optimize program execution.
After either of Step 322 or Step 340, Step 350 would exemplarily collect statistical data. This statistical data would then be used in Step 360 to update the meta-data.
Referring now to
Such a method may be implemented, for example, by operating a computer, as embodied by a digital data processing apparatus, to execute a sequence of machine-readable instructions. These instructions may reside in various types of signal-bearing media.
Thus, this aspect of the present invention is directed to a programmed product, including signal-bearing media tangibly embodying a program of machine-readable instructions executable by a digital data processor to perform the above method.
Thus, this aspect of the present invention is directed to a programmed product, comprising signal-bearing media tangibly embodying a program of machine-readable instructions executable by a digital data processor incorporating the CPU 310 and hardware above, to perform the method of the invention.
This signal-bearing media may include, for example, a RAM contained within the CPU 510, as represented by the fast-access storage for example. Alternatively, the instructions may be contained in another signal-bearing media, such as a magnetic data storage diskette 600 or CD-ROM 602, (
Whether contained in the computer server/CPU 510, or elsewhere, the instructions may be stored on a variety of machine-readable data storage media, such as DASD storage (e.g., a conventional “hard drive” or a RAID array), magnetic tape, electronic read-only memory (e.g., ROM, EPROM, or EEPROM), an optical storage device (e.g., CD-ROM, WORM, DVD, digital optical tape, etc.), paper “punch” cards, or other suitable signal-bearing media including transmission media such as digital and analog and communication links and wireless. In an illustrative embodiment of the invention, the machine-readable instructions may comprise software object code, complied from a language such as “C,” etc.
While the invention has been described in terms of exemplary embodiments, those skilled in the art will recognize that the invention can be practiced with modification within the spirit and scope of the appended claims.
Further, it is noted that, Applicants' intent is to encompass equivalents of all claim elements, even if amended later during prosecution.