Online binary optimization method and system supporting multiple platforms and application

Through the multi-platform online binary optimization method, the program dynamic behavior information collection and offline binary optimization are used to achieve efficient optimization of multi-platform binary executable files, solving the impact of optimization performance, source code required, and matching degree in the existing technology High and unsupported emerging architectures.

CN119493573AActive Publication Date: 2025-02-21EAST CHINA NORMAL UNIV

Patent Information

Application Number
CN202311052652.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-21
Publication Date
2025-02-21
Estimated Expiration
2043-08-21

AI Technical Summary

Technical Problem

The existing technology will affect performance when optimizing programs, and requires source code, and the optimization matching is not high, and it cannot be optimized online, and does not support emerging instruction set architectures.

Method used

Provide a multi-platform online binary optimization method, which realizes the optimization of multi-platform binary executable files through dynamic program behavior information collection, offline binary optimization and online code replacement.

Benefits of technology

It realizes efficient binary optimization without affecting program performance, supports multi-platform and emerging instruction set architecture, avoids the need for redeployment and real-time updates, and improves program performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493573A_ABST
    Figure CN119493573A_ABST
Patent Text Reader

Abstract

The invention discloses a binary optimization method supporting multiple platforms, and the method comprises the following steps: 1, starting a target application load in a process, and collecting and analyzing program dynamic behavior information in the process; 2, taking the program dynamic behavior information and the target application load obtained in the step 1 as input, disassembling a corresponding binary code, optimizing, and outputting an optimized application load after linking is completed; and 3, replacing the original code of the application load with the optimized code of the application load to realize online code replacement. The invention further discloses a system for realizing the binary optimization method. The system comprises a program dynamic behavior information acquisition module, an offline binary optimization module and an online code replacement module. The invention further discloses application of the binary optimization method or the binary optimization system in multi-platform binary code optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of compilation optimization, and relates to an online binary optimization method guided by program dynamic operation information of multiple platforms, an optimization system and an application. Background Art

[0002] Program optimization guided by program dynamic running information is an important compilation optimization technology. According to the different stages of dynamic behavior information, program optimization guided by program dynamic running information can be divided into profile guided optimization (PGO) and post-link program optimization (PLO). Profile guided optimization collects dynamic behavior information during program operation through program instrumentation, dynamic binary instrumentation, or sampling technology based on performance events. In the process of recompiling the source code to generate an executable file, this method uses the previously collected program dynamic behavior information to perform more targeted compilation optimization on the program. However, PGO also has the following disadvantages:

[0003] 1.) After the PGO mode is turned on, the program performance may be affected during the first run because the program dynamic behavior information needs to be collected when the program is run for the first time;

[0004] 2.) PGO requires recompiling the application under the guidance of the program's dynamic behavior information, so PGO optimization can only be performed if the source code is available;

[0005] 3.) PGO uses the behavior information of the program during its running phase to optimize the source code or intermediate representation of the program. The program dynamic behavior information actually obtained by PGO and the code actually optimized by PGO may not completely match, thus affecting the final optimization effect.

[0006] The input of post-link program optimization is usually a binary executable file, and the output is a binary executable file with better performance after post-link optimization. The program dynamic behavior information collected by the post-link optimizer is the dynamic running behavior of the binary executable file, and the object of the post-link optimizer is also the binary executable file. The high matching of this running information and the optimized code enables post-link binary optimization to make more accurate optimizations compared with PGO, thereby enabling some large applications to achieve more obvious performance improvements.

[0007] The post-link binary optimizer is usually used for offline optimization. The complete optimization process using the post-link optimizer includes starting the application load, collecting program dynamic behavior information, terminating the application load, generating the optimized application load, and restarting the optimized application load. Currently, there are two post-link binary optimizers that are relatively active in the open source community and widely used. One is Meta's BOLT [1] , and the other is Google's Propeller [2] Both optimizers perform offline application load optimization according to the above process. The collection of program dynamic behavior information and the execution of optimized binary executable files are two completely independent processes in the optimization process. Using an offline post-link binary optimizer to optimize workloads will bring two potential problems: 1) the optimized application needs to be redeployed; 2) the program dynamic behavior information needs to be updated in real time. These two problems reduce the convenience of the post-link binary optimizer in the optimization process.

[0008] In addition, the compatibility of the post-link binary optimizer with processors of different instruction set architectures is also a problem to be considered. In recent years, many domestic manufacturers have been promoting the research and development of processors. In addition to the original Intel64 and AMD64 instruction set architectures that occupy the main market share, the research and development of processors based on instruction set architectures such as ARM, RISC-V, MIPS and Alpha is also constantly advancing. For example, there are now Kunpeng processors and Feiteng processors based on ARM architecture, Xuantie processors based on RISC-V, Loongson processors based on MIPS architecture, and Shenwei processors based on Alpha architecture on the market. The research and development of post-link binary optimizers in academia and industry are mainly aimed at instruction set architectures with higher market shares such as Intel64 and AMD64, which has led to the lack of such basic software on some emerging instruction set architecture platforms. Summary of the invention

[0009] In order to solve the shortcomings of the prior art, such as program optimization affecting program performance, requiring source code, low optimization matching, inability to perform online optimization, and lack of support for emerging instruction set architectures, the purpose of the present invention is to provide a scalable multi-platform online binary optimization method and system. The technical problems to be solved mainly include multi-platform program dynamic behavior information collection, multi-platform offline binary executable file optimization, and multi-platform online executable code replacement.

[0010] The present invention provides a binary optimization method supporting multiple platforms, the method comprising the following steps:

[0011] Step 1: Start the target application load in the process, collect and analyze the dynamic behavior information of the program in the process;

[0012] Step 2: using the program dynamic behavior information and target application load obtained in step 1 as input, disassembling the binary code corresponding to the application load, optimizing it, and outputting the optimized application load after linking;

[0013] Step 3: Replace the original application load code with the optimized application load code to achieve online code replacement, thereby optimizing the application load.

[0014] In step one, the program dynamic behavior information refers to the information related to the behavioral characteristics of the binary file collected by the application of the present invention during the execution process. This information can be used to guide the performance optimization of the binary file; including the execution frequency of the function, the calling relationship between functions, the execution frequency and hit status of the program branch instructions, and the access mode of the program memory access instructions, etc.

[0015] In step 2, the binary file of the input application load is disassembled, and then the program dynamic behavior information collected in step 1 is analyzed and sorted. Different categories of binary files are optimized according to the differences in input information (including program dynamic behavior information, target application load, etc.). Binary executable files are roughly divided into two categories: compute-intensive and memory-intensive. Computation-intensive binary executable files mainly perform complex scientific computing, data analysis, and image rendering tasks. This type of task mainly focuses on the execution of instructions and the operation of data, which requires a large amount of CPU resources. For this type of binary executable file, function inlining, indirect call elimination, and instruction folding are mainly optimized. Memory-intensive binary executable files mainly involve application scenarios such as large data set processing, file processing, and database operations. Such applications need to retain a large amount of information in memory for timely access. Such binary executable files mainly perform code layout, data layout, and other optimizations. The specific optimizations implemented can be program inline optimization guided by function execution frequency and calling relationship between functions, code layout optimization guided by program branch instructions and hit conditions, data layout optimization guided by memory access mode of program memory access instructions, instruction folding optimization guided by program execution flow information, indirect call elimination optimization guided by program indirect branch target address information, etc. Finally, the optimized disassembled file is relinked into an executable binary file.

[0016] The program inline optimization guided by the function execution frequency and the calling relationship between functions can determine which functions should be inlined by analyzing the function execution frequency and the calling relationship between functions, thereby optimizing the execution efficiency and performance of the program.

[0017] The program branch instruction and hit situation-guided code layout optimization refers to reorganizing the arrangement of program code to reduce the number of executions of branch instructions and the probability of branch prediction failure, thereby improving program performance. This optimization technology requires the compiler to perform static or dynamic analysis on the structure and execution of the program and make an appropriate trade-off between code size and performance.

[0018] The data layout optimization guided by the memory access pattern of the program memory access instruction refers to optimizing the layout of the data in the program to make the program's memory access pattern more efficient, thereby improving the program's performance. This optimization technique requires the compiler to perform static or dynamic analysis on the program's data access pattern and make an appropriate trade-off between code size and performance.

[0019] The instruction folding optimization guided by the program execution flow information can obtain the dependencies between data under the guidance of data flow information, replace register variables whose calculated values ​​are already known with constants, and reduce the calculation overhead and code size during operation.

[0020] The indirect call elimination optimization guided by the program indirect branch target address information can analyze the usage of function pointers and function references in the code. If the specific function pointed to by the function pointer or reference can be determined, the indirect call will be replaced by a direct call, thereby improving the execution efficiency of the program.

[0021] In step three, during the execution of the target program, the present invention can replace the original binary file whose performance needs to be improved with the optimized binary file through methods such as process control, process call stack analysis, machine code extraction and injection, thereby improving the performance of the target program without affecting the normal execution of the program.

[0022] Process control refers to the effective management of the creation, execution, suspension, resumption and termination of a process, and the control of the application is achieved through the management of the target process. The main purpose of the process control implemented by the present invention is to suspend the target program, implement code replacement, and then resume the execution of the program after replacement. Process call stack analysis refers to extracting the functions currently on the call stack during the process suspension, using these functions as entry points, changing the target address pointed to by the function call instructions inside the current call stack function, and changing the target address pointed to by the original function to the optimized new function to achieve code replacement. Machine code extraction refers to extracting the machine code of the optimized function from the BOLT optimized binary file, and machine code injection refers to allocating a new specified address space for these new optimized machine codes, and making the function call instructions inside the current call stack function point to the new address space, so as to achieve the function of code replacement.

[0023] In order to implement the above binary optimization method, the present invention also provides a binary optimization system supporting multiple platforms, the binary optimization system comprising: a program dynamic behavior information collection module, an offline binary optimization module, and an online code replacement module; the program dynamic behavior information collection module, the offline binary optimization module, and the online code replacement module are connected and controlled by a control program;

[0024] The program dynamic behavior information collection module is used to collect and analyze the program dynamic behavior information in the process;

[0025] The program dynamic behavior information collection module further includes a hardware detector, an information collection module, and an information integration module;

[0026] The hardware detector is used to detect whether the processor used to execute the target application load has a hardware register associated with the program dynamic behavior information to be collected;

[0027] The information collection module selects an execution information collection path according to whether a hardware register exists;

[0028] The information integration module is used to integrate the collected program dynamic behavior information into program specific dynamic behavior information in the format required by the offline binary optimization module for input.

[0029] When there are hardware registers associated with the program dynamic behavior information to be collected in the processor used to execute the target application load, a hardware-based performance event sampling scheme is used to obtain the specific dynamic behavior information of the program; when there are no hardware registers associated with the program dynamic behavior information to be collected in the processor used to execute the target application load, a dynamic binary instrumentation scheme is used to obtain the program's dynamic behavior information to be collected.

[0030] The offline binary optimization module is used to optimize the target application load;

[0031] The offline binary optimization module further includes a binary file disassembler, a code optimizer, and a binary file relinker;

[0032] The binary file disassembler is used to disassemble the binary executable file corresponding to the collected program dynamic behavior information;

[0033] The code optimizer is used to optimize platform-independent codes; code optimization methods include code layout optimization, instruction folding optimization, indirect call elimination optimization, data layout optimization, inline optimization, etc.;

[0034] The binary file relinker is used to relink the optimized disassembled binary code into a new binary executable file, which can run normally and has better performance than the original binary executable file.

[0035] The online code replacement module is used to replace the source code with the code of the optimized target application load online.

[0036] The online code replacement module further includes a process controller, a machine code acquirer, and a code reconstructor;

[0037] The process controller is used to suspend the process where the target workload is located before code replacement and extract the current function call stack information of the process, and to resume the target process and continue to execute the optimized application workload after code replacement is completed;

[0038] The machine code acquirer is used to compare and acquire the modified virtual function table and the machine code of the function in the optimized binary executable file, and write them to a designated directory, and re-encode the machine code of the function call instruction inside the call stack function of the current process in the original binary executable file, so that the target function pointed by the machine code is the optimized function, and the optimized machine code pointed by the modified function is also written to the designated directory;

[0039] The code reconstructor is used to allocate additional virtual address space in the target process, and then write the optimized machine code information recorded by the machine code acquirer into the newly allocated address space.

[0040] The beneficial effects of the present invention include:

[0041] The present invention proposes a multi-platform online binary optimization method and system guided by program dynamic behavior information, and the present invention includes three modules: program dynamic behavior information collection module, offline binary optimization module and online code replacement module. The program dynamic behavior information collection module can obtain program dynamic behavior information by hardware-level performance event sampling or software-level dynamic binary instrumentation; the offline binary optimization module optimizes the original workload by using program dynamic behavior information to generate a binary executable file with better performance; the online code replacement module is the code for executing the optimized binary executable file during program operation without the need to restart the workload.

[0042] The present invention optimizes binary executable files based on post-link binary optimization technology, and solves the problem that the collected program dynamic behavior information does not match the final optimization target in the traditional PGO technology. The present invention can achieve more accurate and effective code optimization at the binary executable file level, and further improve the performance of the optimized binary executable file. In addition, the present invention proposes a set of online code replacement solutions, which can replace the code of the original application load with the optimized application load code during the application load operation process, avoiding the problem that large workloads need to be redeployed after optimization. The difficulty of online code replacement is to execute the optimized code before and after the optimization in the same process and ensure the smooth connection before and after the code replacement. If the above difficulties are not handled well, it will cause the problem of program crash after code replacement. The present invention uses the system call of ptrace to realize the control of the target process, suspends the target program before code replacement, first obtains the function information on the current process call stack during the code replacement process, and then inserts the optimized code with these functions as the entry point, and resumes the execution of the program after code replacement. In addition, the program dynamic behavior information collection module, offline binary optimization module and online code replacement module of the present invention can all support multiple platforms, so the present invention can be deployed and optimized on processors of various instruction set architectures, and further optimize the target workload without source code. The present invention uses a disassembly method to decompose the binary executable file, and then optimizes it, and finally generates an optimized binary executable file through a relinker. The above process of regenerating the optimized executable file does not require source code support, thus achieving optimization without source code. The present invention internally supports hardware detectors, and can select the collection path of program dynamic execution information based on whether there are hardware registers. In the absence of hardware registers for recording the program dynamic behavior information to be collected, a platform-independent dynamic binary plugging method can be used to collect program dynamic behavior information, thereby achieving a binary optimization module supported by multiple platforms. The optimization method in the present invention can achieve more than 30% performance improvement in certain database and big data application scenarios.

[0043] For cloud vendors, in order to ensure efficient business development and improve customer experience, many cloud vendors are performing performance optimization work on cloud applications such as MYSQL and Redis. The present invention can help cloud vendors optimize the performance of cloud applications such as MYSQL and Redis on processors with multiple instruction set architectures. For processor vendors, the present invention can fill the gaps in the basic software level for processors with instruction set architectures with a low market share and enrich the basic software ecosystem. Only a few developers will specifically develop basic software that supports instruction set architectures with a low market share, and these processors lack performance optimization tools such as binary optimization modules. Therefore, under the same other conditions, the performance of programs running on these processors will be lower than that of processors running on mature instruction set architectures, resulting in users being unwilling to run their workloads on processors with instruction set architectures with a low market share. The online binary optimization module that supports multiple platforms can generate optimized application loads with the same instruction set architecture as the input application load on multiple platforms, and replace the code of the running application load with the code of the optimized application load during program operation. Therefore, the binary optimization module that supports multiple platforms also helps promote processors with instruction set architectures with a low market share. For users, the present invention optimizes the application load, and the optimization of the entire application load is completed during the program running process, avoiding the problem that the user needs to redeploy the application during the optimization process. At the same time, the process of program running information collection, offline binary optimization, and online code replacement are all automatically completed in the present invention, and the user of the present invention does not need to additionally collect dynamic program running information and redeploy the optimized binary executable file, which enhances the user's operating convenience and reduces the user's operating difficulty. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0045] Figure 1 It is a schematic diagram of the implementation principle of the online binary optimization system of the present invention.

[0046] Figure 2 It is a schematic diagram of the implementation principle of the program dynamic behavior information collection module of the present invention.

[0047] Figure 3 It is a schematic diagram of the implementation principle of the offline binary optimization module of the present invention.

[0048] Figure 4It is a schematic diagram of the implementation principle of the online code replacement module of the present invention.

[0049] Figure 5 It is a schematic diagram of an implementation scheme of embodiment 1 of the present invention.

[0050] Figure 6 It is a schematic diagram of an implementation scheme of embodiment 2 of the present invention.

[0051] Figure 7 It is a schematic diagram of an implementation scheme of embodiment 3 of the present invention.

[0052] Figure 8 It is a schematic diagram of an implementation scheme of embodiment 4 of the present invention.

[0053] Fig. 9 It is a schematic diagram of an implementation scheme of Example 5 of the present invention.

[0054] Fig.10 It is a schematic diagram of an implementation scheme of Example 6 of the present invention. DETAILED DESCRIPTION

[0055] The present invention is further described in detail with reference to the following specific examples and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art and are not particularly limited by the present invention.

[0056] The post-link binary optimization involved in the present invention is a compilation optimization method guided by program dynamic behavior information. Some program-specific dynamic behavior information is obtained by using hardware registers on the processor that are specifically responsible for performance event sampling, but some processors of instruction set architectures do not have similar proprietary hardware, so they cannot perform relevant post-link binary code optimization based on the specific dynamic operation information collected by these proprietary hardware; some post-link optimizers use hardware-independent dynamic binary instrumentation methods to collect program dynamic behavior information, but dynamic binary instrumentation will generate a large performance overhead in the process of collecting information, thereby offsetting the optimization effect of the code generated by the binary optimization module. The present invention needs to design an efficient program dynamic behavior information collection tool that supports multiple instruction set architecture processors.

[0057] After obtaining the program dynamic behavior information, the present invention also needs to further develop an offline binary optimization module that supports multiple platforms for different instruction set architectures. The front end of the binary optimization module can receive binary executable files of different instruction set architectures and perform disassembly operations on these binary executable files. The middle end needs to perform platform-independent code optimization, and the back end needs to generate an optimized binary executable file of the same instruction set architecture as the input executable file by relinking.

[0058] In order to solve the problem that the post-link optimizer of offline optimization needs to redeploy the application load during the optimization process, the present invention also proposes a set of binary code online replacement solutions that can be applied to multiple platforms. The online binary code replacer needs to obtain the dynamic behavior information of the running program during the program running process, and update the memory image of the program running according to the new executable file generated by the post-link optimization, and replace the original insufficiently optimized code with the optimized code without affecting the correctness of the program, so that the program after the code update can obtain higher performance. In addition, the factors affecting performance improvement are relatively complex, and are related to the operating system version, instruction set architecture, the type of optimized binary executable file, and the specific execution scenario of the binary file. In some database and big data application scenarios, more than 30% performance improvement can be achieved.

[0059] The present invention can improve the subsequent execution performance of the application program by replacing the code during the program running process by using the post-link optimization, and the present invention supports multiple instruction set architectures and can support the performance optimization of multi-platform application loads. The present invention divides the online binary optimization system supporting multiple platforms into three modules, namely, a program dynamic behavior information collection module, an offline binary optimization module and an online code replacement module. The three modules themselves are independent of each other. The present invention can use a control program to connect the three modules and use the output of one module as the input of another module. Figure 1 The overall workflow of the present invention is shown. After the target application load is started in the specified process, the program dynamic behavior information collection module starts to collect and parse the program dynamic behavior information during a period of normal operation of the process, and converts the program dynamic behavior information into program dynamic behavior information in a target input format; the offline binary optimization module uses the converted program dynamic behavior information and the target application load as input, performs offline optimization, and disassembles the input binary file to facilitate the optimization of the binary file. After that, the program dynamic behavior information guides the offline binary optimization module to optimize the disassembled binary file, and finally relinks the optimized disassembled file into an optimized application load, outputs the optimized application load after the link is completed, and then the online code replacement module replaces the code of the target application load with the code of the optimized application load, completing the online code replacement work, and the program continues to run to execute the code of the optimized application load.

[0060] The program dynamic behavior information refers to the behavior information collected during the dynamic execution of the program, which can be used to guide the performance optimization of binary files; including the calling frequency of functions, the calling relationship between functions, the execution frequency and hit status of program branch instructions, and the memory access mode of program memory access instructions, etc.; the analysis refers to the aggregation of the original format information collected by the program dynamic behavior information collection module, and the conversion of the information into the format required for the offline binary optimization module to actually guide the optimization of binary files.

[0061] The linking refers to reassembling the optimized disassembled binary codes into a new binary executable file, which can run normally and has better performance than the original binary executable file.

[0062] During the online code replacement process, the ptrace system call is needed to control the target process in order to complete the subsequent tasks of pausing the target process, inserting the optimized machine code, and resuming the target process; and the online binary code replacement module extracts the virtual function table and the machine code of the function of the optimized binary file, and then puts the above machine code into the allocated memory address space; the online binary optimization module also needs to obtain the current call stack function of the target process, and replace the machine code of the call instructions of these functions as the entry point for executing the optimized code.

[0063] The specific principles of the three modules and the detailed workflow within the modules are described as follows.

[0064] 5.1 Program dynamic behavior information collection module

[0065] In order to have the ability to collect program dynamic behavior information on different platforms, the program dynamic behavior information collection module of the present invention has two collection schemes built in: dynamic binary instrumentation at the software level and performance event sampling at the hardware level. From the perspective of reducing collection overhead, if some processors support hardware registers for obtaining specific dynamic behavior information of programs, the present invention preferentially uses the collection and analysis of program dynamic behavior information from the hardware level. For some processors that do not support recording specific dynamic behavior information of programs at the hardware level, the present invention can use the dynamic binary instrumentation method at the software level to obtain program dynamic behavior information.

[0066] like Figure 2 As described above, after the application load is started, the program dynamic behavior information collection module of the present invention needs to be idle for a period of time as a warm-up period, and then the dynamic behavior information collection is performed after the program performance is stable. Before collecting, the present invention first uses a hardware detector to detect whether there is a hardware register associated with the program-specific dynamic behavior information on the processor. If so, in order to reduce the collection overhead, the present invention adopts Figure 2 In the execution path 2, the hardware-based performance event sampling scheme is preferably used to obtain the specific dynamic behavior information of the program; on the contrary, the present invention adopts Figure 2 In the execution path 1, the dynamic binary instrumentation scheme is used to obtain the specific dynamic behavior information of the program. Since the collection principles of the two collection schemes are different, the formats of the specific dynamic program information of the program obtained are also different. Therefore, the present invention further processes the obtained information into the program-specific dynamic behavior information in the format required by the offline binary optimization module for input, so that the obtained program-specific dynamic behavior information can be directly used as the input of the offline binary optimization module.

[0067] The performance event sampling method refers to collecting program dynamic behavior information during program execution using registers associated with performance events. This solution will sample the dynamic behavior information during program execution at specified time intervals and be implemented at the hardware level, so the performance overhead generated is smaller; the dynamic binary instrumentation method refers to collecting program dynamic behavior information using a dynamic binary instrumentation system. This solution will collect all program dynamic execution information during program execution and be implemented at the software level. The performance overhead generated will be greater, but it can be applied to platforms with multiple instruction set architectures.

[0068] During the format conversion process, the present invention associates the collected original information with the function name inside the binary file, uses the symbol name plus the offset to represent the address of the collected information, and aggregates the collected information into the format required by the offline binary optimization module.

[0069] 5.2 Offline Binary Optimization Module

[0070] Since the present invention can collect program dynamic program information by sampling based on performance events or by dynamic binary instrumentation, the input of the offline binary optimization module of the present invention can be binary files of different instruction set architecture platforms. The present invention adds a disassembly front end and a relinking back end for multiple instruction set architectures, and the code optimization part between the front end and the back end is platform-independent. Therefore, the offline binary optimization module of the present invention has a multi-platform support feature and can optimize binary executable programs of different instruction set architectures. The offline binary optimization module further includes a binary file disassembler, a code optimizer, and a binary file relinker, such as Figure 3As shown. After obtaining the program dynamic behavior information in a unified format, the front end of the offline binary optimization module must first receive the binary executable file corresponding to the collected program dynamic behavior information, so that the offline binary optimization module can perform a disassembly operation on the binary executable file. Afterwards, the middle end of the offline binary optimization module combines the program dynamic behavior information to perform platform-independent code optimization. The code optimization implemented in the middle end can be code layout optimization, instruction folding optimization, data layout optimization and inline optimization, indirect call elimination optimization, etc. These optimizations are mature compilation optimization methods in the process of compiling from source code to executable files. The present invention changes the objects of these optimizations from source code or intermediate representation to binary executable files, and uses program dynamic operation information to guide these optimizations. Therefore, the scope of optimization after linking is more precise and the effect is more obvious. The code layout optimization refers to arranging basic blocks / functions with higher execution times together under the guidance of branch instruction execution frequency and hit conditions, optimizing code layout, and improving program locality; the instruction folding optimization refers to obtaining data dependencies under the guidance of data flow information, replacing register variables whose calculation values ​​can be known with constants, and reducing computational overhead and code size during operations; the data layout optimization refers to optimizing the layout of data in the program to make the program's memory access mode more efficient, thereby improving program performance; the inline optimization refers to optimization guided by information about function call frequency and call relationships, reducing the overhead of function calls and function returns, and improving the performance of the optimized program. Finally, the back-end of the offline binary optimization module re-links the mid-end optimized code blocks to generate an optimized binary executable file with the same instruction set architecture as the input executable file. The disassembler at the front end of the binary optimizer and the relinker at the back end are parts related to the instruction set architecture, and the mid-end code optimizer is unrelated to the instruction set architecture. Figure 3 As shown, the input of the offline binary optimizer is the program dynamic behavior information and the application load to be optimized, and the output is the optimized application load. The offline binary optimizer can input binary executable files of application loads of various instruction set architectures such as X86-64, ARM, RISC-V, etc., and output binary executable files of the optimized application load of the corresponding instruction set architecture after being processed by the platform-independent code optimizer. Since the code optimizer in the middle of the module is platform-independent, the optimization implemented by the offline binary optimization module is scalable and can support compilation optimization guided by various program running information, including code layout optimization, data layout optimization, instruction folding optimization, inline optimization, indirect call elimination optimization, etc., and it also allows users to easily add customized optimization methods.

[0071] The program inline optimization known by the function execution frequency and the calling relationship between functions is a compiler optimization technology, which is mainly used to improve the execution efficiency of the program. In programming languages, a function is a set of code blocks that perform specific tasks. Functions in a program can call each other to form a function call relationship. Function inlining refers to copying and inserting the code of a called function to the place where it is called, thereby avoiding the overhead of function calls and improving the performance of the program. The key point of this optimization technology is to determine which functions should be inlined and which functions should be retained as independent function calls based on the execution frequency of the function and the calling relationship between the functions. Generally, functions with high execution frequency and relatively small size will be preferred to be inlined, because this can reduce the overhead of function calls and reduce unnecessary jumps during execution. When performing this optimization, the compiler needs to perform static or dynamic analysis based on the structure and execution of the code to determine which function inlining can bring actual performance improvements, while also considering the side effects of code expansion. Because inlining increases the length of the code, it may cause more cache misses and instruction cache misses, so it is necessary to balance code size and performance.

[0072] The program branch instruction and the code layout optimization guided by the hit situation are also a compiler optimization technology, which aims to minimize the number of executions of branch instructions and branch prediction failures by reasonably arranging the code layout in the program, thereby improving the performance of the program. In a computer program, branch instructions are instructions used to select different code paths for execution based on conditions. Branch instructions may cause the processor to make prediction errors during execution, because the processor predicts the direction of the branch when encountering a branch instruction. If the prediction is wrong, the processor will clear the pipeline and re-execute the instructions after the prediction error. This process is called "branch prediction failure". Code layout refers to the way program instructions are organized in memory. Optimizing code layout can try to arrange the order of instructions in memory to minimize the number of executions of branch instructions and prediction failures, thereby improving the performance of the program. Specifically, this optimization technology involves the following aspects: 1) Code alignment: Aligning the code according to a specific boundary can align the branch target address, thereby reducing the performance loss caused by the misalignment of the branch target address. 2) Branch target location selection: Try to place the target locations of frequently executed branches within a relatively short distance, thereby reducing the distance of branch jumps and the probability of branch prediction failure. 3) Code reordering: By reordering the order of the code, frequently executed code is placed together to reduce unnecessary branches. 4) Loop unrolling: Copy the code in the loop body several times to reduce the number of branch instructions in the loop. 5) Function inlining: Insert the code in the function directly into the place where the function is called to avoid branch instructions and overhead caused by function calls.

[0073] The data layout optimization guided by the memory access mode of the program memory access instruction is also a compiler optimization technology, which aims to optimize the program's access mode to memory by reasonably arranging the data layout in the program, thereby improving the performance of the program. In computer programs, memory access is an important operation, but different memory access modes may result in different memory access efficiencies. For example, sequential memory access is usually more efficient than random and scattered memory access, because modern computers usually use caches to cache continuous memory data blocks, thereby reducing the delay in accessing memory. This optimization technology mainly involves the following aspects: 1) Locality optimization: According to the program's memory access mode, frequently accessed data is laid out on continuous memory addresses as much as possible to utilize the locality principle of the cache. This can reduce the number of accesses to the main memory, thereby speeding up the execution of the program. 2) Data alignment: Aligning data according to specific boundaries can make data more efficient when accessing, especially for SIMD (Single Instruction, Multiple Data) instruction sets and vectorized operations, aligned data layout can improve the performance of parallel computing. 3) Loop reordering: By rearranging the order of calculations in the loop, memory access is made more continuous, thereby reducing memory access latency. 4) Data structure optimization: For complex data structures, the layout of the data can be reorganized to make the memory instructions that access the data more efficient. 5) Prefetch optimization: By predicting the program's access pattern to memory, data is loaded into the cache in advance to reduce memory access latency.

[0074] The instruction folding optimization is also a compiler optimization technology, which aims to reduce the number of instructions in the program by merging adjacent instructions, thereby improving the execution efficiency and performance of the program. In a computer program, instructions are basic operations performed by a computer processor. Each instruction represents a specific calculation or operation. Optimizing the number of instructions in a program can effectively reduce the execution time of the program, because fewer instructions mean fewer instruction cache accesses, fewer pipeline pauses, and less execution overhead. Instruction folding optimization mainly involves the following aspects: 1) Instruction merging: Merge multiple adjacent instructions into a more complex instruction, thereby reducing the total number of instructions. This optimization usually occurs when the processor instruction set contains some support for composite operations. 2) Constant folding: Merge constant operations in instructions with operation instructions to avoid repeated loading of constant data. 3) Copy propagation: Copy the results of operations with the same value in instructions to other places, thereby reducing repeated calculations. 4) Loop unrolling: Repeat the instructions in the loop body to expand multiple times, reduce the number of executions of loop control instructions, and thus reduce loop overhead. Instruction folding optimization is a part of compiler optimization. It rewrites and rearranges the generated instruction sequence during code generation to make the final generated machine code more compact and efficient. This optimization technique requires the compiler to statically analyze the instruction sequence of the program and perform corresponding optimizations based on the characteristics of the instruction set to balance code size and performance.

[0075] The indirect call elimination optimization is also a compiler optimization technology, which aims to convert indirect function calls in the program into direct function calls, thereby improving the execution efficiency of the program. In programming languages, function calls are implemented by the name of the function. A direct function call refers to calling the function directly by its name in the program, and the compiler can determine the function to be called at compile time. An indirect function call refers to a function call implemented by a function pointer or function reference. The compiler cannot determine the specific function to be called at compile time, and needs to determine it according to the value of the pointer or reference at runtime. Indirect function calls may cause program execution efficiency to decrease due to the additional runtime overhead and the inability to perform static analysis optimization. The "indirect call elimination optimization" is to try to convert indirect function calls into direct function calls to avoid these performance losses. The optimizer analyzes the use of function pointers and function references in the code. If the specific function pointed to by the function pointer or reference can be determined, the indirect call will be replaced by a direct call. This optimization may need to be implemented through reverse engineering or specific information at runtime in some cases, because the target function of the function pointer or reference cannot be fully determined in all cases. Through indirect call elimination optimization, the compiler can encode function calls directly into instructions when appropriate, reducing function call overhead and the number of jumps, thereby improving program performance and execution speed. However, it should be noted that this optimization may also increase code size, because direct calls may be repeated many times, while indirect calls only need to be represented in one place. Therefore, the compiler usually weighs the trade-off between code size and performance to choose the most appropriate optimization strategy.

[0076] 5.3 Online Code Replacement Module

[0077] The online code replacement module is responsible for replacing the code of the original application load with the code of the optimized application load during program operation. The online code replacement module mainly includes a process controller, a machine code acquirer and a code reconstructor. The process controller is mainly responsible for pausing the process where the target workload is located before code replacement and extracting the current function call stack information of the process. The process controller is also responsible for restoring the target process after completing the code replacement and continuing to execute the work of the optimized application load. The machine code acquirer is mainly responsible for two parts of work. One part of the work is to compare the newly generated binary executable file with the original binary executable file, obtain the changed virtual function table and function machine code in the optimized binary executable file, and write it to the user-defined directory. The other part of the work is to obtain the machine code of the function call instruction inside the call stack function of the current process from the original binary executable file, and re-encode this part of the machine code so that the target function it points to is the optimized function, and then write these machine codes to the user-defined directory. The code reconstructor is mainly used to allocate additional virtual address space in the target process, and then write the optimized machine code information recorded by the machine code acquirer into the allocated virtual address space. Since the present invention has changed the target function address pointed to by the function call instruction in the machine code acquirer, after the process is restored, the executed machine code will be replaced with the optimized machine code, so that the present invention successfully completes the work of online code replacement.

[0078] The execution process of the online code replacement module is as follows Figure 4 As shown, in order to replace the code of the running application load with the code of the optimized application load, the online code replacement module first uses the process controller to suspend the process where the target application load is located and obtain the function call stack information of the current process. Then the machine code acquirer in the online code replacement module combines the application load information before and after optimization with the function call stack information of the process to obtain the machine code information corresponding to the optimized function, virtual function table and function call instruction. After that, the code reconstructor writes the above machine code information into the virtual address space. Finally, the process control module can run the optimized code after resuming the target process again.

[0079] The specific implementation of the present invention is described through the following embodiments. In the following embodiments, A, B, C, D, and E represent different types of processor models, respectively. Figure 5 and Figure 7 A and C in the above specifically refer to processors with hardware registers that record certain dynamic behavior information of programs; Figure 6 and Figure 8 B and D in the table specifically refer to processors that do not have hardware registers that record certain dynamic behavior information of the program. X, Y, Z1, Z2, Z3, W1, W2, W3, and H represent computing platforms based on the above-mentioned processor types. Figure 7 and Figure 8 Represents a multi-machine deployment scenario. The computing platforms represented by Z1, Z2, and Z3 (W1, W2, and W3) refer to computing platforms with the same processor architecture and the same software and hardware environment configurations. In addition, the Z1, Z2, and Z3 (W1, W2, and W3) computing platforms all perform the same type of computing or memory access tasks for the same workload. Fig. 9 Represents an example of binary code optimization using code layout optimization methods. Fig.10 Represents an optimized example of MYSQL application workload on Intel64 platform using code layout optimization method.

[0080] Embodiment 1:

[0081] Single-machine sampling, optimization and deployment, there are hardware registers on the target processor for collecting program-specific dynamic behavior information. The computing platform X of processor model A has a workload to be optimized, and the computing platform where processor model A is located has hardware registers for recording program-specific dynamic behavior information. Embodiment 1 hopes to complete the collection of program dynamic behavior information, binary optimization based on the post-link optimizer, and online deployment of the optimized workload on a single computing platform.

[0082] The execution process of Example 1 is as follows Figure 5 As shown, first, the target application load is started in the specified process, and then the program dynamic behavior information collection module starts to collect and parse the program dynamic behavior information in the specified interval of the process. During the collection process, according to the hardware detector of the program dynamic behavior information collection module, it is found that there are hardware registers on the computing platform X that record the program-specific dynamic behavior information, so the hardware-level performance event sampling technology is used on the computing platform X to collect the program-specific dynamic behavior information. After that, the offline binary optimization module takes the program dynamic behavior information and the target application load as input, and outputs the optimized application load after the link is completed. Finally, the online code replacement module replaces the code of the target application load with the code of the optimized application load, completing the online code replacement work. The program continues to run and can execute the code of the optimized application load, achieving the goal of improving the performance of the specific application load on the computing platform X.

[0083] Embodiment 2:

[0084] Single-machine sampling, optimization and deployment, there is no hardware register on the target processor to collect program-specific dynamic behavior information. The computing platform Y of processor model B has a workload to be optimized, and the computing platform where processor model B is located does not have a hardware register to record program-specific dynamic behavior information. Example 2 hopes to complete the collection of program dynamic behavior information, binary optimization based on the post-link optimizer, and online deployment of the optimized workload on a single computing platform.

[0085] The execution process of Example 2 is as follows Figure 6 As shown, first, the target application load is started in the specified process, and then the program dynamic behavior information collection module starts to collect and parse the program dynamic behavior information in the specified interval of the process. During the collection process, according to the hardware detector of the program dynamic behavior information collection module, it is found that the computing platform Y does not have a hardware register that records the program-specific dynamic behavior information, so the software-level dynamic binary instrumentation technology is used on the computing platform Y to collect the program-specific dynamic behavior information. After that, the offline binary optimization module takes the program dynamic behavior information and the target application load as input, and outputs the optimized application load after the link is completed. Finally, the online code replacement module replaces the code of the target application load with the code of the optimized application load, completing the online code replacement work. The program continues to run and can execute the code of the optimized application load, thereby achieving the goal of improving the performance of specific application loads on computing platform Y.

[0086] Embodiment three:

[0087] Single-machine sampling and optimization, multi-machine deployment, and hardware registers on the target processor that collect program-specific dynamic behavior information. The computing platforms Z1, Z2, and Z3 of processor model C have workloads to be optimized. The computing platforms Z1, Z2, and Z3 are all used to perform specific types of computing / memory access tasks for the same application load, and the computing platform where processor model C is located has hardware registers that record program-specific dynamic behavior information. Embodiment 3 hopes to collect program dynamic behavior information on a single computing platform and optimize the target program by means of post-link optimization, and deploy the optimized workload online on multiple computing platforms. Thus, Embodiment 3 can improve the performance of application loads running on multiple computing platforms while only one computing platform bears the additional performance overhead during the optimization process.

[0088] The execution process of Example 3 is as follows Figure 7 As shown, first, the same workload is started on computing platforms Z1, Z2, and Z3 and the same type of computing / memory access tasks are performed. Then, computing platform Z1 completes the collection of program dynamic behavior information of a single computing platform and the optimization of the target application load based on the offline link optimizer by sampling performance events according to the process in Example 1. Then, the optimized application load of computing platform Z1 is sent to computing platforms Z2 and Z3. Finally, the online code replacement module can be started simultaneously on computing platforms Z1, Z2, and Z3, and Example 3 completes the work of performing online code replacement on multiple computing platforms at the same time.

[0089] Embodiment 4:

[0090] Single-machine sampling and optimization, multi-machine deployment, no hardware registers exist on the target processor to collect program-specific dynamic behavior information. The computing platforms W1, W2, and W3 of processor model D have workloads to be optimized. The computing platforms W1, W2, and W3 are all used to perform specific types of computing / memory access tasks for the same application load, and the computing platform where processor model D is located does not have hardware registers to record program-specific dynamic behavior information. Example 4 hopes to collect program dynamic behavior information on a single computing platform and optimize the target program through post-link optimization, and deploy the optimized workload online on multiple computing platforms. Therefore, in the case where only one computing platform bears the additional performance overhead in the optimization process, Example 4 can improve the performance of application loads running on multiple computing platforms.

[0091] The execution process of Example 4 is as follows Figure 8 As shown, first, the same workload is started on computing platforms W1, W2, and W3 and the same type of computing tasks are performed. Then, computing platform W1 completes the collection of program dynamic behavior information of a single computing platform and the optimization of the target application load based on the offline link optimizer by means of dynamic binary instrumentation according to the process in Example 2. Then, the optimized application load of computing platform W1 is sent to computing platforms W2 and W3. Finally, the online code replacement module is started on computing platforms W1, W2, and W3 at the same time, and Example 4 completes the work of performing online code replacement on multiple computing platforms at the same time.

[0092] Embodiment five:

[0093] For single-machine sampling, optimization and deployment, the offline binary optimizer mainly performs code layout optimization. The computing platform H of processor model E has a workload to be optimized. Example 5 hopes to complete the collection of program dynamic behavior information, binary optimization based on the post-link optimizer, and online deployment of the optimized workload on a single computing platform. Specifically, Example 5 hopes to use the program dynamic branch information to optimize the code layout of the binary executable file. Compared with the original application load, the optimized application load can improve the CPU's instruction cache hit rate during execution, reduce the pressure on the front end of the processor pipeline, and enable the target application load to obtain a more obvious performance improvement.

[0094] The execution process of Example 5 is as follows Fig. 9As shown, first, the target application load is started in the specified process, and then the program dynamic behavior information collection module starts to collect and parse the program dynamic branch information in the specified interval of the process. This information mainly includes the starting address of the branch jump of the basic block / function, the ending address of the branch jump, and the number of times the branch jump occurs during the program execution. After that, the offline binary optimization module takes the program dynamic branch information and the target application load as input, and after completing the code layout optimization such as basic block rearrangement and function rearrangement, the offline binary optimization module outputs a new application load with higher performance. Finally, the online code replacement module replaces the code of the target application load with the code of the optimized application load, completing the online code replacement work. The program continues to run and can execute the code of the optimized application load, achieving the goal of improving the performance of specific application loads on the computing platform H through post-link optimization.

[0095] This embodiment takes code layout optimization as an example. The implementation of other code optimizations is similar to this embodiment, except that the information collected by the information collection module and the optimization performed by the offline binary optimization module are different.

[0096] Embodiment six:

[0097] This embodiment provides an optimization example in a specific implementation scenario, which is as follows:

[0098] Single machine sampling, optimized deployment, offline binary optimizer mainly performs code layout optimization. Processor model is Gold 5218R processor, there is a MYSQL (version number: 8.0.11) workload to be optimized on the Linux computing platform based on the processor (operating system version: Ubuntu 20.04.5LTS), and the computing platform mainly applies MYSQL to the scenario where only data is read in the database (read-only scenario). This embodiment hopes to complete the collection of program dynamic behavior information, binary optimization based on the post-link optimizer, and online deployment of optimized MYSQL on a single computing platform. Specifically, this embodiment hopes to use the program dynamic branch information to optimize the code layout of the MYSQL application in a read-only scenario. The Gold 5218R processor belongs to the Intel64 instruction set architecture and can use Intel LBR hardware to collect program dynamic branch information and use this information to optimize code layout.

[0099] The execution process of this embodiment is as follows Fig.10As shown, first start MYSQL in the specified process, then the program dynamic behavior information collection module starts to collect and parse the program dynamic branch information in the specified interval of the process, which mainly includes the starting address of the branch jump of the basic block / function, the ending address of the branch jump, and the number of times the branch jump occurs during the program execution process. After that, the offline binary optimization module takes the program dynamic branch information and the MYSQL application as input, and after completing the code layout optimization such as basic block rearrangement and function rearrangement, the offline binary optimization module outputs the optimized MYSQL application. Finally, the online code replacement module replaces the original MYSQL code with the optimized MYSQL code, completes the online code replacement work, and the program continues to run to execute the optimized MYSQL program, achieving the goal of improving the MYSQL application load performance through post-link optimization. Before and after the optimization of the present invention, Sysbench is used to test the transaction processing volume of MYSQL per second in the read-only scenario. Compared with before the optimization of the present invention, the transaction processing volume of the optimized MYSQL per second in the read-only scenario is improved by 32%. The performance improvement data of this embodiment is for the case where the code layout is optimized for MYSQL in a read-only application scenario on the Intel64 platform. The performance improvement data obtained by performing different types of optimization for different workloads on different platforms may vary.

[0100] References

[0101] [1]Panchenko M,Auler R,Nell B,et al.Bolt: a practical binary optimizer for data centers and beyond[C] / / 2019IEEE / ACM International Symposium on CodeGeneration and Optimization(CGO).IEEE,2019:2-14.

[0102] [2]Shen H, Pszeniczny K, Lavaee R, et al. Propeller: A Profile Guided, Relinking Optimizer for Warehouse-Scale Applications[C] / / Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages ​​and Operating Systems, Volume 2.2023:617-631.

[0103] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the present invention, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the attached claims.

Claims

1. A binary optimization method supporting multiple platforms, characterized in that: The method comprises the following steps: Step 1: Start the target application load in the process, collect and analyze the dynamic behavior information of the program in the process; Step 2: using the program dynamic behavior information and target application load obtained in step 1 as input, disassembling the binary code corresponding to the application load, optimizing it, and outputting the optimized application load after linking; Step 3: Replace the original application load code with the optimized application load code to achieve online code replacement, thereby optimizing the application load.

2. The binary optimization method according to claim 1, characterized in that: In step one, the program dynamic behavior information refers to the behavior information collected during the dynamic execution of the program, which is used to guide the performance optimization of the binary file; the program dynamic behavior information includes the calling frequency of the function, the calling relationship between functions, the execution frequency and hit status of the program branch instructions, and the memory access mode of the program memory access instructions.

3. The binary optimization method according to claim 1, characterized in that: In step 2, the binary file of the input application load is disassembled, and then the program dynamic behavior information collected in step 1 is analyzed and sorted, different categories of binary files are optimized according to the difference in input information, and finally the optimized disassembled file is relinked into an executable binary file; the optimization includes program inline optimization guided by function execution frequency and calling relationship between functions, code layout optimization guided by program branch instructions and hit conditions, instruction folding optimization guided by program execution flow information, indirect call elimination optimization guided by program indirect branch target address information, and data layout optimization guided by memory access mode of program memory access instructions.

4. The binary optimization method according to claim 1, characterized in that: In step three, during the execution of the target program, the original binary file whose performance needs to be improved is replaced with the optimized binary file using methods including process control, process call stack analysis, and machine code extraction and injection, thereby improving the performance of the target program without affecting the normal execution of the program. The target program will be paused before the replacement operation, and during the code replacement process, the function information on the current process call stack will be first obtained, and then the optimized code will be inserted with the function on the current process call stack as the entry point, and the execution of the program will be resumed after the code replacement.

5. A binary optimization system supporting multiple platforms, characterized in that: The binary optimization system comprises: a program dynamic behavior information collection module, an offline binary optimization module, and an online code replacement module; the program dynamic behavior information collection module, the offline binary optimization module, and the online code replacement module are connected and controlled by a control program; The program dynamic behavior information collection module is used to collect and analyze the program dynamic behavior information in the process; The offline binary optimization module is used to optimize the target application load; The online code replacement module is used to replace the source code with the code of the optimized target application load online.

6. The binary optimization system according to claim 5, characterized in that: The program dynamic behavior information collection module further includes a hardware detector, an information collection module, and an information integration module; The hardware detector is used to detect whether the processor used to execute the target application load has a hardware register associated with the program dynamic behavior information to be collected; The information collection module selects an execution information collection path according to whether a hardware register exists; The information integration module is used to integrate the collected program dynamic behavior information into program specific dynamic behavior information in the format required by the offline binary optimization module for input.

7. The binary optimization system according to claim 6, characterized in that: When there is a hardware register associated with the program dynamic behavior information to be collected in the processor used to execute the target application load, a hardware-based performance event sampling scheme is used to obtain specific dynamic behavior information of the program; When there is no hardware register associated with the program dynamic behavior information to be collected in the processor used to execute the target application load, a dynamic binary instrumentation solution is used to obtain the program dynamic behavior information to be collected.

8. The binary optimization system of claim 5, wherein: The offline binary optimization module further includes a binary file disassembler, a code optimizer, and a binary file relinker; The binary file disassembler is used to disassemble the binary executable file corresponding to the collected program dynamic behavior information; The code optimizer is used to optimize platform-independent codes; the code optimization methods include code layout optimization, instruction folding optimization, indirect call elimination optimization, data layout optimization, and inline optimization; The binary file relinker is used to relink the optimized code blocks to generate an optimized binary executable file with the same instruction set architecture as the input executable file.

9. The binary optimization system of claim 5, wherein: The online code replacement module further includes a process controller, a machine code acquirer, and a code reconstructor; The process controller is used to suspend the process where the target workload is located before code replacement and extract the current function call stack information of the process, and to resume the target process and continue to execute the optimized application workload after code replacement is completed; The machine code acquirer is used to compare and acquire the modified virtual function table and the machine code of the function in the optimized binary executable file, and write them to a designated directory, and re-encode the machine code of the function call instruction inside the call stack function of the current process in the original binary executable file, so that the target function pointed by the machine code is the optimized function, and the optimized machine code pointed by the modified function is also written to the designated directory; The code reconstructor is used to allocate additional virtual address space in the target process, and then write the optimized machine code information recorded by the machine code acquirer into the newly allocated address space.

10. Application of the binary optimization method according to any one of claims 1 to 4, or the binary optimization system according to any one of claims 5 to 9 in multi-platform binary code optimization.

Citation Information

Patent Citations

  • Binary translation method combining static optimization

    CN101452396A

  • Method for injecting test codes for Linux system

    CN101984409A

  • Program migration method and system for dynamic and static binary translation and storage medium

    CN114115990A

  • Method for optimizing network security scene based on fuzzy test technology

    CN115270124A

  • Binary program vulnerability static analysis method based on man-machine collaboration

    CN115563627A

Cited By

  • Post-link optimization method and device based on software and hardware collaboration and storage medium

    CN120872788A