In general, in one aspect, embodiments of the invention relate to a method for generating executable binary. The method includes analyzing a test executable binary generated from source code, wherein the source code comprises a plurality of functions, generating, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, and determining, using the code call tree, a function order of the plurality of functions. The method further includes generating, using the function order, a call tree order map, generating a call tree ordered executable binary using the source code and the call tree order map, and executing the call tree ordered executable binary on a processor.
|
1. A method for generating executable binary comprising:
analyzing a test executable binary generated from source code, wherein the source code comprises a plurality of functions, and wherein the plurality of functions comprises a first function, a second function, and a third function;
generating, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, wherein the code call tree indicates that, while executing the first function, the second function has a higher call duration than the third function;
determining, using the code call tree, a function order of the plurality of functions;
generating, using the function order, a call tree order map;
generating a call tree ordered executable binary using the source code and the call tree order map, wherein generating the call tree ordered executable binary using the source code and the call tree order map comprises:
placing a binary for the second function after a binary for the first function and before a binary for the third function in the call tree ordered executable binary; and
executing the call tree ordered executable binary on a processor.
13. A system for generating executable binary comprising:
an analyzer configured to:
analyze a test executable binary generated from source code, wherein the source code comprises a plurality of functions, and wherein the plurality of functions comprises a first function, a second function, and a third function; and
generate, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, wherein the code call tree indicates that, while executing the first function, the second function has a higher call duration than the third function;
a conversion engine configured to
determine, using the code call tree, a function order of the plurality of functions; and
generate, using the function order, a call tree order map;
a call tree order linker configured to:
generate a call tree ordered executable binary using the source code and the call tree order map, wherein generating the call tree ordered executable binary using the source code and the call tree order map comprises:
placing a binary for the second function after a binary for the first function and before a binary for the third function in the call tree ordered executable binary; and
a processor configured to execute the call tree ordered executable binary.
7. A non-transitory computer-readable medium comprising software instructions that, when executed by a processor, perform a method for generating executable binary comprising:
analyzing a test executable binary generated from source code, wherein the source code comprises a plurality of functions, and wherein the plurality of functions comprises a first function, a second function, and a third function;
generating, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, wherein the code call tree indicates that, while executing the first function, the second function has a higher call duration than the third function;
determining, using the code call tree, a function order of the plurality of functions;
generating, using the function order, a call tree order map;
generating a call tree ordered executable binary using the source code and the call tree order map, wherein generating the call tree ordered executable binary using the source code and the call tree order map comprises:
placing a binary for the second function after a binary for the first function and before a binary for the third function in the call tree ordered executable binary; and
executing the call tree ordered executable binary on a processor.
2. The method of
3. The method of
generating a first set of pages comprising the binary for the first function and the binary for the second function;
generating a second set of pages comprising the binary for the third function;
storing the first set of pages in a cache memory for the processor; and
storing the second set of pages in a non-cache memory.
4. The method of
5. The method of
6. The method of
wherein the ordering policy dictates that functions with greater call durations precede functions with lower call durations in the call tree ordered executable binary.
8. The non-transitory computer-readable medium of
9. The non-transitory computer-readable medium of
generating a first set of pages comprising the binary for the first function and the binary for the second function;
generating a second set of pages comprising the binary for the third function;
storing the first set of pages in a cache memory for the processor; and
storing the second set of pages in a non-cache memory.
10. The non-transitory computer-readable medium of
11. The non-transitory computer-readable medium of
12. The non-transitory computer-readable medium of
14. The system of
15. The system of
generating a first set of pages comprising the binary for the first function and the binary for the second function;
generating a second set of pages comprising the binary for the third function;
storing the first set of pages in a cache memory for the processor; and
storing the second set of pages in a non-cache memory.
16. The system of
17. The system of
|
Computers are designed to execute computer programs written in a format understood by the computer, such as machine code. However, programmers typically do not write computer programs in machine code. Instead, programmers typically write computer programs using human readable programming languages referred to as source code. The resulting computer program is then compiled to generate a computer program in a format understood by the computer. The process of compilation is performed by a compiler. Compilers typically use the source code (e.g., computer program written in a human readable programming language) as input and generate object code, which is able to be transformed by another program into an executable (e.g., a format understood by the computer).
In general, in one aspect, embodiments of the invention relate to a method for generating executable binary. The method includes analyzing a test executable binary generated from source code, wherein the source code comprises a plurality of functions, generating, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, and determining, using the code call tree, a function order of the plurality of functions. The method further includes generating, using the function order, a call tree order map, generating a call tree ordered executable binary using the source code and the call tree order map, and executing the call tree ordered executable binary on a processor.
In general, in one aspect, embodiments of the invention relate to a non-transitory computer-readable medium comprising software instructions that, when executed by a processor, perform a method for generating executable binary. The method includes analyzing a test executable binary generated from source code, wherein the source code comprises a plurality of functions, generating, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions, and determining, using the code call tree, a function order of the plurality of functions. The method further includes generating, using the function order, a call tree order map, generating a call tree ordered executable binary using the source code and the call tree order map, and executing the call tree ordered executable binary on a processor.
In general, in one aspect, embodiments of the invention relate to a system for generating executable binary. The system includes an analyzer, a conversion engine, a call tree order linker, and a processor. The analyzer is configured to analyze a test executable binary generated from source code, wherein the source code comprises a plurality of functions, and generate, based on analyzing the test executable binary, a code call tree comprising a plurality of call durations for the plurality of functions. The conversion engine is configured to determine, using the code call tree, a function order of the plurality of functions, and generate, using the function order, a call tree order map. The call tree order linker is configured to generate a call tree ordered executable binary using the source code and the call tree order map. The processor is configured to execute the call tree ordered executable binary.
Other aspects of the invention will be apparent from the following description and the appended claims.
Specific embodiments of the invention will now be described in detail with reference to the accompanying figures. Like elements in the various figures are denoted by like reference numerals for consistency.
In the following detailed description of embodiments of the invention, numerous specific details are set forth in order to provide a more thorough understanding of the invention. However, it will be apparent to one of ordinary skill in the art that the invention may be practiced without these specific details. In other instances, well-known features have not been described in detail to avoid unnecessarily complicating the description.
In general, embodiments of the invention provide a method and system for ordering text in a binary. Specifically, embodiments of the invention may be used to generate executable binary code from source code using a call tree ordered by the function execution time of a training program. Call tree ordered executable binaries may run more efficiently than executable binaries generated using other procedures.
In one or more embodiments of the invention, source code (100) is a static file that includes uncompiled software instructions. Specifically, the source code (100) may be a set of uncompiled software instructions that have not been compiled into object files (104) by the compiler (102) or converted into executable binary (e.g., test executable binary (100), call tree ordered executable binary (122)) by a linker (e.g., generic linker (106), call tree order linker (120)). The source code (100) may be a set of software instructions that induce a computer to perform a task. In one or more embodiments of the invention, the source code (100) includes human-readable software instructions.
In one or more embodiments of the invention, call tree ordered executable binary (122) is a static file that includes software instructions in a form executable by hardware elements of a computer system (e.g., processor, etc.). Specifically, the call tree ordered executable binary (122) may be a set of compiled software instructions generated from object files (104) and a call tree order map (118). that has been compiled by the call tree compiler (100). Further, the call tree ordered executable binary (122) may include objects and functions that correspond to sets of software instructions of the source code (100). Such objects and functions may be arranged from the source code (100) so as to minimize the resources necessary to execute the call tree ordered executable binary (122) (e.g., to reduce execution time, etc.). The call tree ordered executable binary (122) may be executed by a processor.
In one or more embodiments of the invention, the source code (100) includes a number of functions. In one or more embodiments of the invention, a function is a callable unit/subset of the source code (100) that, once compiled linked, is executed as a unit (i.e., routine, subroutine, method, procedure, etc.). In one or more embodiments of the invention, a function is called (i.e., set for execution) by another function or by initializing the execution of the call tree ordered executable binary (122). Further, each function may call one or more other functions during its execution.
In one or more embodiments of the invention, the linkers (generic linker (106), call tree order linker (120)) are a processes or group of processes with functionality to generate executable binary (test executable binary (110), call tree ordered executable binary (122)) using the object files (104). In one or more embodiments of the invention, the linkers (generic linker (106), call tree order linker (120)) orders the functions from the source code (100) and object files (104) according to a map file (generic map (108), call tree order map (118)).
In one or more embodiments of the invention, the generic linker (106) generates the test executable binary (110) from the object files (104) without a map. Specifically, the generic linker (106) may generate the test executable binary (110) without purposefully reordering the functions from the object files (104). Alternatively, the generic linker (106) may use a generic map (108) to impart some order upon the functions from the object files (104). The generic map (108) may instruct the generic linker (106) to order the functions according to metrics obtainable from the object files (104) and/or the source code (100) (e.g., number of lines in a function, type of function, etc.).
In one or more embodiments of the invention, the analyzer (112) is a process or group of processes with functionality to generate a code call tree (114) for the object files (104). Specifically, the analyzer (112) may execute the test executable binary (110) to obtain run-time metrics about the test executable binary (110). Such run-time metrics may include, for example, time spent executing a function, number of threads generated during test-execution, virtual memory size, and amount of time spent waiting by the processor. The time spent executing a function may be referred to as the call duration of a function. The call duration may be measured as a percentage of total time spent executing the binary. In one or more embodiments of the invention, the call duration for the functions in the test executable binary (110) is measured by the analyzer (112) and stored in the code call tree (114).
In one or more embodiments of the invention, a code call tree (114) is a static file that relates functions to call duration. Specifically, the code call tree (114) stores the call durations for functions in the source code (100) indicating the call durations of each function called by other functions. For example, function A, while executing, may call function B or function C depending on the outcome of a variable comparison. The code call tree (114) in this example would indicate the call duration (in terms of percentage of total execution time) of function A, function B, and function C. Assuming no other functions, function A may have a call duration of 100% (i.e., the binary spent 100% of the execution time executing function A). The time spent executing function A is spent executing function B or executing function C. For example, (and discounting any time spent executing the code within function A that is not a part of function B or function C) during the execution of function A, 80% of the total execution time may have been spent executing function B (i.e., function B has a call duration of 80%), and 20% of the total execution time may have been spent executing function C (i.e., function C has a call duration of 20%).
Continuing with the example, assume further that function B may call function D or function E depending on a network metric. Function B has a call duration of 80% (i.e., 80% of the total execution time is spent executing function B). Half of the time spent executing function B is spent executing function D, and half is spent execution function E. Function D would have a call duration of 40% (i.e., 40% of the total execution time is spent executing function D). Function E would similarly have a call duration of 40% (i.e., 40% of the total execution time is spent executing function E).
Continuing with the example, assume that function C and function E each call the same function, function F, during their execution. Assume also that function C and function E only call function F (and no other functions) during their executions. Function F would, therefore, have a call duration under C of 20%, and a call duration under function E of 40%, for a total call duration of 60%.
In one or more embodiments of the invention, the conversion engine (116) is a process or group of processes with functionality to generate a call tree order map (118). In one or more embodiments of the invention, a call tree order map (118) is a static file that instructs the linker (118) regarding the order in which the compiled functions are to be arranged in the call tree ordered executable binary (122). In one or more embodiments of the invention, the conversion engine (116) generates the call tree order map (118) using the call durations stored in the code call tree (114). Specifically, the conversion engine (116) uses the call durations stored in the code call tree (114) to determine a function order that is stored in the call tree order map (118). In one or more embodiments of the invention, the conversion engine (116) generates the call tree order map (118) according to an ordering policy.
In one or more embodiments of the invention, an ordering policy is a set of rules for ordering functions in the call tree order map (118) to further a system goal. For example, an ordering policy with a system goal of minimizing the resources used by the call tree compiler may dictate that functions are ordered in the call tree order map (118) using the same order in which they appear in the source code (100). As another example, an ordering policy with a system goal of minimizing the resources used by executing the call tree ordered executable binary (122) may dictate that each function is immediately followed by the function it spends the greatest amount of time executing (i.e., the function with the highest call duration).
In one or more embodiments of the invention, cache memory (202) is memory from which instructions (i.e., portions of functions) are read and executed by the processor (not shown). In one or more embodiments of the invention, cache memory (204) is implemented as volatile memory (e.g., random access memory). In one or more embodiments of the invention, non-cache memory (202) is memory in which the executable binary (206) is stored prior to transfer into cache memory (204). In one or more embodiments of the invention, Non-cache memory (202) is implemented as volatile memory, non-volatile memory (e.g., persistent storage), or a combination of volatile memory and non-volatile memory. In one or more embodiments of the invention, the executable binary (206) is divided into pages that may be copied into the cache memory (206) as they are needed by the processor. In one or more embodiments of the invention, the size of the cache memory (204) is less than the size of the executable binary (206) (i.e., the cache memory (204) and on-chip translation lookaside buffer (TLB) is unable to store all pages which make up the executable binary (206) at one time).
In one or more embodiments of the invention, each page (page A (212A), page B (212B), page N (212N)) includes one or more binaries for functions (binary for function A (208A), binary for function B (208B), binary for function N (208N)) and/or a portion of one or more functions (binary for function A (208A), binary for function B (208B), binary for function N (208N)).
In one or more embodiments of the invention, a processor (not shown) may attempt to access the binary for a function (binary for function A (208A), binary for function B (208B), binary for function N (208N)) from the cache memory (204). Such access attempts may be made using a TLB. If the binary for the function requested by the processor is stored in a page currently loaded in cache memory (i.e., a page hit) or mapped by the TLB (i.e., a TLB hit), then it may be read immediately. If the binary for the function requested by the processor is stored in a page that is not currently loaded in cache memory (i.e., a page miss) or not mapped by the TLB (i.e., a TLB miss), then the page with the requested binary for function must be located in non-cache memory (202) and loaded into cache memory (204) or mapped by the TLB. Misses are expensive in terms of system resources, and the ordering policy implemented by a conversion engine (116 in
In Step 310, the compiler obtains the source code. In Step 312, the compiler compiles the source code into object files. In one or more embodiments of the invention, functions in the source code are compiled into object files as units. In Step 314, the generic linker generates test executable binary from the object files. In one or more embodiments of the invention, the generic linker uses a generic map to order the functions from the object file into the test executable binary.
In Step 316, the analyzer analyzes the test executable binary to generate a code call tree. In one or more embodiments of the invention, the analyzer test-executes the test executable binary to obtain a set of metrics about the test executable binary and stores the metrics in the code call tree.
In Step 318, the conversion engine generates the call tree order map using the code call tree and the ordering policy. In one or more embodiments of the invention, the conversion engine orders the functions in the call tree order map by applying an ordering policy to the metric data stored in the code call tree.
In one or more embodiments of the invention, the ordering policy implemented by the conversion engine is configured to reduce the number of misses by placing child functions with a higher call duration adjacent to the parent function and placing child functions with a lower call duration elsewhere in the call tree ordered executable binary. An ordering policy as described above may increase the likelihood that a called function will be stored on the same page or set of pages as the calling function, thus reducing misses by increasing the likelihood that a parent function currently loaded in cache memory will call a child function also currently loaded in cache memory.
In Step 320, the call tree order linker generates call tree ordered executable binary using the object files and the call tree order map. In one or more embodiments of the invention, functions in the source code are compiled into object files and binaries in the call tree ordered executable binary as units, and the compiled functions are ordered according to the call tree order map.
In Step 410, the call tree ordered executable binary is divided sequentially into pages. In Step 412, the first set of pages is loaded into cache memory and/or is mapped by the TLB. In Step 414, the processor executes the instructions corresponding to the first function binary in the cache memory. In Step 416, the processor attempts to access a child function called by the currently executing parent function.
In Step 418, the memory management unit determines whether the binary for the child function is stored in a page currently loaded in cache memory and/or is mapped by the TLB. If in Step 418, the memory management unit determines that the binary for the child function is not stored in a page currently loaded in cache memory and/or is not mapped by the TLB, and a miss has occurred, then in Step 420, the miss is resolved. In one or more embodiments of the invention, a page miss is resolved by loading the page containing the requested function binary into cache memory. In one or more embodiments of the invention, a TLB miss is resolved by calculating the mapping for the memory location containing the appropriate page and storing the mapping in the TLB.
If in Step 418, the memory management unit determines that the binary for the child function is stored in a page currently loaded in cache memory and/or is mapped by the TLB, and a hit has occurred, then in Step 422, the processor executes instructions corresponding to the binary for the called child function. In Step 424, the processor determines whether the execution of the call tree ordered executable binary has stopped (i.e., the application generated by the executing call tree ordered executable binary has been terminated by a user or system process). If in Step 424, the processor determines that the execution of the call tree ordered executable binary has not stopped, then the process returns to Step 416. If in Step 424, the processor determines that the execution of the call tree ordered executable binary has stopped, then the process ends.
During the execution of function A (502A), function A (502A) calls function G (502G) and function P (502P). Of the 82% of the total execution time spent executing function A (502A), 81% of the total execution time is spent executing function G (502G) and 19% of the execution time is spent executing function P (502P). When function C (502C) was called, function C (502C) called function K (502K) in every tested instance, and so function K (502K) has the same call duration (6%) as function C (502C).
Continuing with the discussion of
Continuing with the discussion of
Continuing with the discussion of
For the purposes of the example, assume that the conversion engine implements an ordering policy configured to reduce the number of misses by placing the child functions with the highest call duration (under its parent function) adjacent to its parent function. The remaining functions are added after all functions under the child functions with higher call durations are added to the function order. If the function has previously been added, the function is not added a second time.
There is an increased likelihood that the next function called by the call tree ordered executable binary generated as shown in
Embodiments of the invention may be implemented on virtually any type of computing system regardless of the platform being used. For example, the computing system may be one or more mobile devices (e.g., laptop computer, smart phone, personal digital assistant, tablet computer, or other mobile device), desktop computers, servers, blades in a server chassis, or any other type of computing device or devices that includes at least the minimum processing power, memory, and input and output device(s) to perform one or more embodiments of the invention. For example, as shown in
Software instructions in the form of computer readable program code to perform embodiments of the invention may be stored, in whole or in part, temporarily or permanently, on a non-transitory computer readable medium such as a CD, DVD, storage device, a diskette, a tape, flash memory, physical memory, or any other computer readable storage medium. Specifically, the software instructions may correspond to computer readable program code that when executed by a processor(s), is configured to perform embodiments of the invention.
Further, one or more elements of the aforementioned computing system (600) may be located at a remote location and connected to the other elements over a network (612). Further, embodiments of the invention may be implemented on a distributed system having a plurality of nodes, where each portion of the invention may be located on a different node within the distributed system. In one embodiment of the invention, the node corresponds to a distinct computing device. Alternatively, the node may correspond to a computer processor with associated physical memory. The node may alternatively correspond to a computer processor or micro-core of a computer processor with shared memory and/or resources.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this disclosure, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as disclosed herein. Accordingly, the scope of the invention should be limited only by the attached claims.
Patent | Priority | Assignee | Title |
10782934, | Jan 03 2018 | Amazon Technologies, Inc | Migrating computer programs to virtual compute services using annotations |
Patent | Priority | Assignee | Title |
5500948, | Oct 29 1991 | Intel Corporation | Translating instruction pointer virtual addresses to physical addresses for accessing an instruction cache |
5815720, | Mar 15 1996 | Hewlett-Packard Company | Use of dynamic translation to collect and exploit run-time information in an optimizing compilation system |
6260131, | Nov 18 1997 | Apple Inc | Method and apparatus for TLB memory ordering |
6298411, | Jan 05 1999 | SAMSUNG ELECTRONICS CO , LTD | Method and apparatus to share instruction images in a virtual cache |
6324634, | Apr 19 1994 | Hitachi, Ltd. | Methods for operating logical cache memory storing logical and physical address information |
6772315, | May 24 2001 | Rambus Inc | Translation lookaside buffer extended to provide physical and main-memory addresses |
7769974, | Sep 10 2004 | Microsoft Technology Licensing, LLC | Increasing data locality of recently accessed resources |
8019944, | Sep 28 2005 | Sun Microsystems, Inc; Sun Microsystems Technology LTD | Checking for a memory ordering violation after a speculative cache write |
8244979, | Jul 13 2007 | International Business Machines Corporation | System and method for cache-locking mechanism using translation table attributes for replacement class ID determination |
20040117592, | |||
20060101299, | |||
20060215481, | |||
20090254709, | |||
20110138363, | |||
20110258416, | |||
20120072423, | |||
20120144374, | |||
20130111184, | |||
20140096114, | |||
20150089483, | |||
WO2006098701, |
Executed on | Assignor | Assignee | Conveyance | Frame | Reel | Doc |
Sep 14 2013 | GUTHRIDGE, KARSTEN | Oracle International Corporation | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 031298 | /0299 | |
Sep 26 2013 | Oracle International Corporation | (assignment on the face of the patent) | / |
Date | Maintenance Fee Events |
May 30 2019 | M1551: Payment of Maintenance Fee, 4th Year, Large Entity. |
May 31 2023 | M1552: Payment of Maintenance Fee, 8th Year, Large Entity. |
Date | Maintenance Schedule |
Dec 15 2018 | 4 years fee payment window open |
Jun 15 2019 | 6 months grace period start (w surcharge) |
Dec 15 2019 | patent expiry (for year 4) |
Dec 15 2021 | 2 years to revive unintentionally abandoned end. (for year 4) |
Dec 15 2022 | 8 years fee payment window open |
Jun 15 2023 | 6 months grace period start (w surcharge) |
Dec 15 2023 | patent expiry (for year 8) |
Dec 15 2025 | 2 years to revive unintentionally abandoned end. (for year 8) |
Dec 15 2026 | 12 years fee payment window open |
Jun 15 2027 | 6 months grace period start (w surcharge) |
Dec 15 2027 | patent expiry (for year 12) |
Dec 15 2029 | 2 years to revive unintentionally abandoned end. (for year 12) |