A method, device, electronic device and storage medium for optimizing program compilation

CN116737158BActive Publication Date: 2026-10-27SHENZHEN WANGYU COMPUTER NETWORK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210194528.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-01
Publication Date
2026-10-27
Estimated Expiration
2042-03-01

AI Technical Summary

Technical Problem

[0007]显然,相关技术下,每次实施PGO时,电子设备均需要产生和获取profile文件,以及对其进行预处理,使得整个PGO实施过程较为复杂,导致整个编译流程较长,降低优化程序编译的效率;并且,相关技术下并未对profile文件进行管理,导致后续获取profile文件对程序进行优化时,可能无法快速获取对应的profile文件,导致对优化程序编译的效率较低

Benefits of technology

[0021]本申请实施例提供的优化程序编译的方法、装置、电子设备和存储介质,由于电子设备将原始程序的profile文件和原始程序的描述信息,传输至目标数据管理服务器,以使目标数据管理服务器,对profile文件进行格式化处理,获得第一版本格式化文件,并将第一版本格式化文件,和原始程序对应的各历史版本格式化profile文件,进行关联保存。这样,电子设备可以基于从目标数据管理服务器中获取的,第一版本格式化文件和至少一个历史版本格式化文件,对原始程序进行优化,获得相应的目标程序。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116737158B_ABST
    Figure CN116737158B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for optimizing program compilation, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: an electronic equipment can use a compilation tool to compile a code file to be compiled to obtain an original program, and run the original program to obtain a profile file of the original program; description information of the profile file and the original program is transmitted to a target data management server, so that the target data management server performs format processing on the profile file to obtain a first version format file, and each historical version format profile file corresponding to the first version format file and the original program is saved in association, and then the electronic equipment can optimize the original program based on the first version format file and at least one historical version format file to obtain a target program. In this way, a version format file can be quickly obtained, and the efficiency of optimizing program compilation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for optimizing program compilation. Background Technology

[0002] With the rapid development of computer technology, objects can be optimized based on the performance optimization method (Profile-guided optimization, PGO) corresponding to the compiler configuration of electronic devices. This can optimize the optimization process for programs and improve the optimization efficiency.

[0003] Currently, there are various programs, and different versions of the same program exist. Therefore, different versions of different programs require different configurations. Thus, when the compiler needs to optimize a new program, it must perform PGO optimization based on the program information of the new program and the configuration corresponding to the current version information. Therefore, a new configuration needs to be determined to implement a new PGO to optimize the aforementioned new program.

[0004] Specifically, under relevant technologies, PGO is generally implemented using the following two steps:

[0005] Step 1: The electronic device receives the code file to be compiled, instrumentes the code in the code file based on the compiler, and runs the instrumented program to obtain a configuration (profile) file. The profile file contains the data information of the program at runtime, which is obtained by writing the data to the disk in the form of a file.

[0006] Step 2: The electronic device preprocesses the profile file to obtain a preprocessed file, and analyzes the preprocessed file. Based on the analysis results, it determines the strategy for extreme optimization of the program corresponding to the code file, and optimizes the program based on the strategy to make the program more compliant with runtime requirements. This preprocessed file must meet the compiler's reading requirements.

[0007] Clearly, under the relevant technologies, each time PGO is implemented, the electronic device needs to generate and obtain a profile file and preprocess it, making the entire PGO implementation process quite complex, resulting in a long compilation process and reducing the efficiency of optimizing program compilation. Furthermore, the relevant technologies do not manage the profile file, which means that when optimizing the program later, it may not be possible to quickly obtain the corresponding profile file, resulting in low efficiency of optimizing program compilation. Summary of the Invention

[0008] This application provides a method, apparatus, electronic device, and storage medium for optimizing program compilation, thereby improving the efficiency of program compilation.

[0009] On the one hand, a method for optimizing program compilation is provided, the method comprising:

[0010] The code file to be compiled is compiled using a compilation tool to obtain the original program, and the original program is run to obtain the configuration profile file of the original program;

[0011] Based on the configuration information corresponding to the compilation tool, a target data management server is determined, and the profile file and the description information of the original program are transmitted to the target data management server; so that the target data management server formats the profile file to obtain a first version formatted file, and associates and saves the first version formatted file with the formatted files of each historical version corresponding to the original program;

[0012] Based on the first version formatted file and at least one historical version formatted file obtained from the target data management server, the original program is optimized to obtain the corresponding target program.

[0013] On the one hand, an apparatus for optimizing program compilation is provided, the apparatus comprising:

[0014] The obtaining unit is used to compile the code file to be compiled using a compilation tool to obtain the original program, and to run the original program to obtain the configuration profile file of the original program;

[0015] The processing unit is configured to determine the target data management server based on the configuration information corresponding to the compilation tool, and transmit the profile file and the description information of the original program to the target data management server; so that the target data management server formats the profile file to obtain a first version formatted file, and associates and saves the first version formatted file with the formatted profile files of each historical version corresponding to the original program.

[0016] An optimization unit is used to optimize the original program based on the first version format file and at least one historical version format file obtained from the target data management server, to obtain a corresponding target program.

[0017] On one hand, an electronic device is provided, including a processor and a memory, wherein the memory stores program code that, when executed by the processor, causes the processor to perform the aforementioned method for compiling the optimized program.

[0018] On one hand, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the aforementioned method of optimizing program compilation.

[0019] This application provides a computer-readable storage medium including program code. When the program product is run on an electronic device, the program code is used to cause the electronic device to execute any of the above-described methods for optimizing program compilation.

[0020] The beneficial effects of this application are as follows:

[0021] The method, apparatus, electronic device, and storage medium for optimizing program compilation provided in this application embodiment transmit the profile file and description information of the original program to a target data management server. The target data management server then formats the profile file to obtain a first-version formatted file and associates and saves the first-version formatted file with corresponding historical version formatted profile files of the original program. In this way, the electronic device can optimize the original program based on the first-version formatted file and at least one historical version formatted file obtained from the target data management server to obtain the corresponding target program.

[0022] As can be seen, in this embodiment, there is no need for electronic devices to format the profile file of the original program. Instead, the first version format file and at least one historical version format file corresponding to the original program are obtained directly from the target data association server. The original program is then optimized to obtain the corresponding target program, thereby improving the efficiency of program optimization and compilation.

[0023] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0025] Figure 1 This is a schematic diagram of the compilation process for an optimized program in the prior art;

[0026] Figure 2 This is an optional schematic diagram of an application scenario in an embodiment of this application;

[0027] Figure 3 This is an optional schematic diagram of a system framework for optimizing program compilation in an embodiment of this application;

[0028] Figure 4 This is a flowchart illustrating a method for optimizing program compilation according to an embodiment of this application;

[0029] Figure 5 This is an optional schematic diagram illustrating the functionality of a compilation tool in an embodiment of this application;

[0030] Figure 6 This is an optional schematic diagram of generating a configuration file in one embodiment of this application;

[0031] Figure 7 This is yet another optional schematic diagram of generating a configuration file in an embodiment of this application;

[0032] Figure 8 This is a schematic diagram illustrating how a data management server manages configuration files in an embodiment of this application.

[0033] Figure 9 This is a schematic diagram illustrating one method of obtaining a historical version formatted file in an embodiment of this application;

[0034] Figure 10 This is a schematic diagram of a local cache and a target data management server cache formatting file in an embodiment of this application;

[0035] Figure 11 This is a schematic diagram illustrating yet another local cache and target data management server cache formatted file in an embodiment of this application;

[0036] Figure 12 This is a schematic diagram of a method for optimizing program compilation according to an embodiment of this application;

[0037] Figure 13 This is a schematic diagram of the composition structure of an apparatus for optimizing program compilation according to an embodiment of this application;

[0038] Figure 14 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0039] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0040] The terms "first" and "second" in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more, and the embodiments of this application do not impose limitations.

[0041] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.

[0042] To facilitate understanding of the technical solutions provided in the embodiments of this application, some key terms involved in the embodiments of this application will be explained here first:

[0043] 1. Compiler: A compiler is a computer program that translates source code (the original language) written in one programming language into another programming language (the target language). During compilation, the compiler can optimize and modify the source code to improve program performance and add additional functionality.

[0044] 2. Compilation Tools: Compilation tools are automated build software. Specifically, they are used to compile source code, generate output code, and then link the output code to generate executable files or library files. For example, the compilation tool for C / C++ is make, and the compilation tool for the fourth generation Unreal Engine is UBT, etc. Furthermore, it also determines dependencies based on the modification time of dependent files, thus achieving the function of checking file dependencies. Of course, it can also call some external software to complete the compilation task.

[0045] 3. Performance optimization methods: In this application, the performance optimization methods are referred to as (Profile-guided optimization, PGO), (profile-directed feedback, PDF), or (feedback-directed optimization, FDO), POGO, etc., which are methods for optimizing program performance using runtime data.

[0046] 4. Profile: Data information during program runtime, which may include the number of objects created, function call information, instruction information, etc. It is a statistical representation of the program's running status.

[0047] 5. Profile file: Writes the program's runtime data to the disk in the form of a file.

[0048] 6. Instrumentation compilation: When compiling code, the compiler inserts code into the program to collect statistics on the program's running status. Generally, a profile file is generated when the program ends.

[0049] 7. Configure guided optimization compilation: Provide the profile file to the compiler when compiling code.

[0050] 8. Software Development Kit (SDK): This refers to a collection of development tools used by software engineers to create application software for specific software packages, software frameworks, hardware platforms, and operating systems. In this article, the PGO Service Plugin can be understood as an SDK.

[0051] 9. Application Programming Interface (API): A computing interface that defines the interaction between multiple software intermediaries, the types of calls or requests that can be made, how to make calls or requests, the data format to be used, and the conventions to be followed.

[0052] 10. Unreal Engine 4 (UE): This engine was primarily designed for developing first-person shooter games, but it has now been successfully applied to the development of various other types of games, including stealth games, fighting games, and role-playing games.

[0053] Currently, PGO optimizations can be implemented during compilation, linking, and even late linking. Specifically, during compilation, optimizations using profiles include register allocation and code block reordering. During linking, optimizations using profiles include indirect call optimization and heuristic references. These optimizations can make programs run more efficiently and improve the program's memory and executor usage.

[0054] Various compilers using related technologies offer PGO optimization, but the methods and effects of PGO vary slightly among different compilers. Furthermore, since runtime data is often generated based on specific scenarios and platforms, using runtime data to optimize general programs may result in negative optimization.

[0055] Currently, please refer to Figure 1 As shown, the PGO build process under related technologies generally consists of two main steps. Specifically, the first step is instrumentation compilation, and the program executed after instrumentation compilation will generate a profile file upon completion. The profile file contains detailed statistics on the data from the current program execution; furthermore, through the profile file, we can know information such as the number of objects created, the number of function calls, and the number of loop executions. In addition, after obtaining the profile file, manual preprocessing is required to make it conform to the compiler's reading requirements.

[0056] Specifically, the second step is to perform PGO compilation. In practice, this requires manual selection of profile files to optimize the program. After selecting the target profile file, it needs to be manually copied. During compilation, the compiler can then read the copied target profile file and source code files. By analyzing the profile data, the compiler determines the strategy for extreme optimization, making the program more compliant with runtime requirements.

[0057] As can be seen, collecting profile files and preprocessing are also relatively complex processes. This makes the entire PGO build process more complicated, resulting in a longer compilation process and reduced efficiency of the optimization program compilation. Furthermore, the lack of profile file management in related technologies means that when optimizing the program later, it may not be possible to quickly obtain the corresponding profile file, leading to low efficiency of the optimization program compilation.

[0058] Therefore, this application provides a method for optimizing program compilation. This method allows an electronic device to automatically upload the profile file generated after running the compiled program, without relying on a transmission synchronization script deployed by operations and maintenance. Furthermore, the target data management server automatically preprocesses the profile (i.e., formats it) and manages projects and versions based on the uploaded profile's attributes. Thus, during the extreme compilation step, there's no need to manually input the profile file. The electronic device controls the compilation tool to automatically use the locally cached profile file or retrieve the first-version formatted file and at least one historical version formatted file from the target data management server, based on a strategy. This allows the electronic device to easily and efficiently obtain the first-version formatted file and at least one historical version formatted file, thereby improving the efficiency of optimizing program compilation.

[0059] After introducing the design concept of the embodiments of this application, the following is a brief introduction to the application scenarios to which the technical solutions of the embodiments of this application can be applied. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.

[0060] The embodiments provided in this application can be applied to most scenarios that require program compilation optimization, such as compiling and optimizing game programs, or compiling and optimizing service programs, etc.

[0061] See Figure 2 The diagram illustrates a scenario according to an embodiment of this application. The scenario includes an electronic device 201 and a data management server 202. The electronic device 201 can be, for example, a mobile phone, tablet computer (PAD), personal computer (PC), smart TV, smartwatch, smart speaker, smart vehicle device, and wearable device, but is not limited to these. Each electronic device 201 may include one or more processors 2011, a memory 2012, and an I / O interface 2013 for interacting with the server.

[0062] In this embodiment, the data management server 202 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms, but is not limited to these.

[0063] In this embodiment, electronic devices 201 and data management server 202, as well as various electronic devices 201, can be directly or indirectly connected via one or more networks 203. The network 203 can be a wired network or a wireless network. For example, the wireless network can be a mobile cellular network or a Wireless-Fidelity (WIFI) network, or other possible networks. This application embodiment does not limit the types of networks used.

[0064] In this embodiment, the electronic device 201 can interact with the data management server 202 to implement the optimized program compilation scheme provided in this application. It should be noted that in actual implementation, multiple electronic devices 201 can interact with one data management server 202, or multiple electronic devices 201 can interact with multiple data management servers 202; this application does not limit this.

[0065] In this embodiment, the electronic device 201 can determine the code file to be compiled, then determine the compilation tool corresponding to the code file, and control the compilation tool to instrument and compile the code file to obtain the original program. The original program is then run to obtain a configuration file. Further, the electronic device 201 can determine the data management server 202 based on the configuration information of the compilation tool, and send the configuration file and the description information of the original program to the data management server 202. Thus, the data management server 202 can format the received configuration file to obtain a first version formatted file. Then, based on the description information of the original program, it can determine at least one historical version formatted file corresponding to the original program, and then associate and save the first version formatted file and at least one historical version formatted file. Furthermore, the electronic device 201 can obtain the first version formatted file and at least one historical version formatted file from the data management server 202, and then optimize the original program based on the first version formatted file and at least one historical version formatted file to obtain the corresponding target program.

[0066] Please see Figure 3 , Figure 3This is a schematic diagram of the system architecture of the optimized compiler provided in the embodiments of this application. The system architecture includes: a determining module 301, used to determine the code file to be compiled and the corresponding compilation tool; a compilation module 302, used to compile the code file to be compiled, and can switch between instrumentation compilation and extreme compilation based on electronic device control; the compilation module 302 can also transmit relevant information of the target data management server, and can obtain formatted files from the target data manager based on electronic device control; and a data management module 303, used to format the uploaded configuration file and manage the version of the obtained formatted file.

[0067] In the embodiments of this application, the scheme for compiling the optimized program provided in this application can be implemented collaboratively based on the determination module 301, the compilation module 302 and the data management module 303.

[0068] See Figure 4 The diagram shown is a flowchart of an implementation method for optimizing program compilation according to an embodiment of this application. This method can be executed by an electronic device, and the specific implementation process is as follows:

[0069] Step 401: Use a compilation tool to compile the code file to be compiled to obtain the original program, and run the original program to obtain the configuration profile file of the original program.

[0070] In this embodiment of the application, before executing step 301, the electronic device can determine the compilation tool corresponding to the code file to be compiled based on the type information of the code file to be compiled; wherein, the configuration information of the compilation tool includes at least the address information and interface information of the data management server.

[0071] Specifically, electronic devices can determine the corresponding compilation tool based on the type information of the code file to be compiled. For example, if the code file to be compiled is determined to be a game code file, then the compilation tool can be determined to be UBT. It should be noted that the following explanation uses UBT as the compilation tool.

[0072] Please see Figure 5 The diagram shown is a functional schematic of the compilation tool illustrated in an embodiment of this application. In this embodiment, the compilation tool can be optimized, for example, by optimizing its configuration file. Specifically, the UBT configuration file can pre-configure relevant information about the data management server (PGO service) and description information of the program corresponding to the code file to be compiled.

[0073] Specifically, the information of the data management server includes address information (service IP) and interface information (service port). In the actual implementation process, the electronic device can pre-configure the relevant information of the data management server in the UBT configuration file, such as the address information and interface information of the target data management server. In this way, the target data management server can be determined from multiple data management servers based on the address information and interface information of the target data management server.

[0074] Specifically, the program's description information includes the project name and the current version. For example, the program's description information might be "project.target.cs". In this way, the electronic device can accurately obtain the corresponding formatted file from the target data management server based on the program's description information. It should be noted that, in this embodiment, for ease of description, the file obtained after formatting the profile file is referred to as the formatted file.

[0075] In this embodiment, once the compilation tool, UBT, is determined, the electronic device can switch between two compilation modes: instrumentation compilation and extreme compilation. Instrumentation compilation can be understood as the compilation process that generates a profile file, while extreme compilation can be understood as the compilation process that optimizes the program based on a formatted profile file.

[0076] Specifically, during the instrumentation compilation phase, the relevant information of the aforementioned data management server and the program description information are passed to the code. In this way, the program can transmit runtime data and program description information to the data management server at runtime through the relevant information of the data management server.

[0077] Specifically, during the optimization and compilation phase, electronic devices can remotely obtain formatted profile files via UBT and PGO service information. It should be noted that the size of the formatted profile file is related to the program's workload.

[0078] As can be seen, in this embodiment, the compilation tool can be optimized. This allows the compilation tool to seamlessly apply data management server information during both instrumentation and extreme optimization compilation processes. Consequently, the subsequent uploading and retrieval of profile data becomes transparent to the development object, thereby improving the convenience of PGO builds. 。

[0079] In this embodiment of the application, after the compilation tool is determined, the compilation tool can be used to compile the code file to be compiled to obtain the original program, and the original program can be run to obtain the configuration profile file of the original program.

[0080] In one possible implementation, please refer to Figure 6 As shown, during compilation, the electronic device controls the compiler to inject a piece of code before the original program finishes running. This allows the runtime data collected during program execution to be written to the disk as a file, thus obtaining a profile file. This method provides a simpler and more efficient way to obtain the profile file.

[0081] However, considering that some manual operations are required to implement certain steps of the PGO build under the relevant technologies, we considered using automated pipeline compilation. However, when compiling with an automated pipeline, there are problems such as each project having its own compilation pipeline process, which is difficult to standardize. In addition, there is the problem of deploying additional scripts to collect profile files in different environments. Furthermore, since a profile file is generated for each run, if it is increased without limit, it may lead to disk exhaustion. It can be seen that there are some problems with obtaining and managing profile files under the relevant technologies, which reduces the efficiency of the optimization program compilation.

[0082] Therefore, this application provides a new method for obtaining the configuration profile file of the original program. In the embodiments of this application, an SDK can be provided for the program side, which is, for example, called PGO Service Plugin. Specifically, the PGO Service Plugin can provide two APIs: one API is used to clear the profile before this API is called, and the other API can report the current profile data to the PGO service.

[0083] Please see Figure 7 As shown in this embodiment, the electronic device can use the compiler's management profile file via SDK hook. Specifically, the developer can trigger an instruction to remotely transmit runtime data to the PGO service during program execution based on the API provided by the PGO Service Plugin. This allows the electronic device to respond to interception instructions triggered on the original program during its execution, extracting multiple sub-data from the generated runtime data corresponding to the original program according to a preset duration.

[0084] In one possible implementation, the electronic device can remotely transmit multiple sub-data sets, i.e., multiple profile data sets, to the PGO service before the program terminates or during program execution. This avoids the issue of large numbers of profile files consuming disk space when the program ends. In other words, the API provided by this solution allows for the logical division of runtime data into multiple segments. For example, in a game scenario, each game session can be divided into a segment, and each segment generates corresponding runtime data. This runtime data is then uploaded to the data management server according to the logical segment organization.

[0085] As can be seen, in this embodiment of the application, the running data is no longer stored as a file, but is directly uploaded to the data management server by the program itself.

[0086] In one possible implementation, the electronic device can determine corresponding partial profile files based on multiple sub-data; and obtain the configuration profile file of the original program based on the obtained partial profile files. Specifically, the electronic device can determine the encapsulation order of the multiple partial profile files based on the extraction order of the multiple sub-data; then, it encapsulates the multiple partial profile files according to the encapsulation order to obtain the configuration profile file of the original program. This changes the previous process of generating runtime data files only after the program ends, instead of retrieving runtime data from the underlying data at the end of program execution. It allows for the advance retrieval of multiple sub-data and the aggregation and uploading of multiple segments of runtime data during program execution, thus improving the efficiency of runtime data uploading.

[0087] Step 402: Based on the configuration information corresponding to the compilation tool, determine the target data management server, and transfer the profile file and the description information of the original program to the target data management server; so that the target data management server formats the profile file to obtain the first version formatted file, and associates and saves the first version formatted file with the formatted files of each historical version corresponding to the original program.

[0088] In this embodiment, the electronic device can determine the target data management server based on the configuration information corresponding to the compilation tool. Specifically, the target data management server can be determined from multiple data management servers based on the address and interface information of the target data management server in the configuration information.

[0089] In this embodiment of the application, in order to better introduce the processing of profile files and the management of formatted files by the target data management server in this application, the functions of the target data management server provided in this application will be introduced first.

[0090] In this embodiment of the application, as described above, the Target Data Management Server (PGO Service) is the device corresponding to the service used to manage runtime data (profiles). Specifically, the Target Data Management Server mainly provides two interfaces: one interface is used to receive profiles reported by the PGOService Plugin, and the other interface is used to provide a way for UBT to obtain profiles.

[0091] Specifically, the profiles or profiles in the profile files reported by the compilation tool (UBT) are unprocessed and are referred to as raw profiles for ease of description. Therefore, when the compilation tool reports a raw profile, it needs to transmit the raw profile and its associated program name and version information (i.e., program description information) to the target data management server. The target data management server then categorizes and manages the profiles according to program name and version. For example, the program name and version can be understood as forming a key corresponding to a profile. In other words, the target data management server can store the program description information and the corresponding profile as a key-value pair.

[0092] In this embodiment, the target data management server can format each uploaded raw profile to generate a usable profile, i.e., a formatted file. Formatting can be understood as processing the raw profile into a file that can be recognized by the compiler used by the electronic device.

[0093] In this embodiment, the target data management server can perform association processing on the formatted file of the raw profile, i.e., the first version formatted file. For example, the first version formatted file can be associated with the previous historical version formatted file uploaded before it was uploaded to generate a new profile, i.e., progressively merging to generate and save the profile; or, the newly uploaded raw profile can be associated with at least one historical version formatted file uploaded before it was uploaded, i.e., both can be saved in the storage area corresponding to the corresponding program. This application does not limit this.

[0094] In the specific implementation process, considering that if a large number of raw profiles are uploaded for each program version, the disk space of the target data management server can easily become full. Therefore, the data management server can only retain the latest N profiles of the same version, thus leaving sufficient space for profile rollback. Here, N is a positive integer greater than 1, for example, it could be retaining the latest 3 profiles of the same version, or the latest 5 profiles, etc. It should be noted that "same version" in the aforementioned latest N profiles of the same version refers to which version of the same program, such as the first version of the Android version or the third version of the iOS version. The program optimization method provided in this application embodiment can be for Android versions or iOS versions of the program; this application embodiment does not impose any restrictions on this.

[0095] In this embodiment, when an electronic device calls the profile acquisition interface, it needs to pass the program name and version of the required profile to the data management server. This allows the data management server to accurately and quickly provide the electronic device with the required formatted file.

[0096] In this embodiment, as mentioned earlier, the size of the profile file is related to the complexity of the program. For example, generating a medium to large profile file takes approximately 10 to 30 seconds. During the generation process, although the file is created, it is incomplete. If this file is passed to UBT, it will lead to catastrophic consequences. Therefore, we need to pay attention to concurrency security issues.

[0097] Please see Figure 8 As shown, the data management server uses a concurrent read, queued write approach to handle the large number of profile files sent. Specifically, when no profile file needs formatting, the latest profile file can be read concurrently. When a profile file needs formatting, the next newest profile file is read concurrently. Furthermore, formatted files that need to be written to the data management server are queued and processed incrementally. In other words, for concurrent scenarios involving the same version of the program, i.e., when profile files are large and generation takes a long time, a write-heavy, read-light strategy can be implemented.

[0098] As can be seen, in this embodiment, the data management service automates the management of operational data for different projects and versions, greatly simplifying the management of operational data. Furthermore, the data management service employs a concurrent read-queue-write concurrency security strategy, effectively improving the processing efficiency of the data management server.

[0099] Step 403: Based on the first version format file and at least one historical version format file obtained from the target data management server, optimize the original program to obtain the corresponding target program.

[0100] Please see Figure 9 The diagram illustrates the acquisition of a historical version formatted file according to an embodiment of this application. In this embodiment, considering the time and bandwidth consumed in transmitting formatted files of different sizes, as well as the reliability of data transmission, before the electronic device directly obtains the first version formatted file and at least one historical version formatted file from the target data management server, the electronic device can determine whether a formatted file is cached locally, and then determine the method for acquiring the first version formatted file and at least one historical version formatted file based on this.

[0101] For example, in the TK project, a formatted file can be 200MB to 300MB, so transferring formatted files will generate significant bandwidth and consume considerable transfer time. Therefore, it's worth considering whether to retrieve the required formatted file from a local cache.

[0102] Optionally, when the electronic device determines that the compilation tool is to perform extreme compilation, it can determine whether the local cache contains a formatted file obtained from the target data management server. If the local cache contains a formatted file, the formatted file is processed to obtain a message digest to obtain the corresponding cache digest information. Based on the cache digest information, if it is determined that there is matching target digest information in the data management server, the original program is optimized based on the corresponding formatted file in the local cache and the first version formatted file obtained from the data management server to obtain the corresponding target program. The target digest information is the digest information corresponding to at least one historical version formatted file.

[0103] In this embodiment of the application, the electronic device can perform message digest processing on the formatted file. For example, the MD5 message digest algorithm can be used to process the formatted file to obtain the corresponding MD5 value. The electronic device can then send the MD5 value to the PGO service for comparison. When the PGO service determines that the MD5 value corresponding to at least one historical version of the formatted file in its cache is consistent with the MD5 value cached locally by UBT, it will notify UBT to directly use the formatted file in the local cache of the electronic device and the first version of the formatted file to optimize the original program and obtain the corresponding target program.

[0104] For example, please see Figure 10Assuming the local cache contains a first historical version formatted file and a second historical version formatted file corresponding to version A of program 1, and the target data management server stores the first historical version formatted file and the second historical version formatted file corresponding to version A of program 1, the target data management server can determine that the MD5 value corresponding to the formatted file in the local cache is the same as the MD5 value corresponding to version A of program 1 stored in the local cache. Therefore, the comparison is successful, meaning that the local cache stores the latest historical version formatted file corresponding to the latest version A of program 1.

[0105] In this way, the electronic device can optimize the original program based on the latest historical version of the formatted file in the local cache, and the first version of the formatted file, to obtain the corresponding target program. That is, by using the runtime data after this instrumentation compilation and the runtime data from the previous instrumentation compilation, the original program is optimized, thereby obtaining the corresponding target program.

[0106] Optionally, when it is determined that no formatted file is cached in the local cache, the electronic device can directly obtain the first version formatted file and at least one historical version formatted file from the target data management server; based on the first version formatted file and at least one historical version formatted file, the original program is optimized to obtain the corresponding target program.

[0107] Optionally, when no matching target summary information exists in the data management server, the electronic device can obtain a first version formatted file and at least one historical version formatted file from the target data management server. Based on the first version formatted file and at least one historical version formatted file, the original program is optimized to obtain the corresponding target program.

[0108] For example, please see Figure 11 Suppose that the local cache contains the third and fourth historical version format files corresponding to version A of program 1, and the target data management server stores the fifth historical version format file corresponding to version A of program 1. In this case, the target data management server can determine that the MD5 value of the format file in the local cache is different from the MD5 value of the version A of program 1 stored in the local cache. Therefore, the comparison fails, meaning that the local cache does not store the latest historical version format file corresponding to the latest version A of program 1.

[0109] In this way, the electronic device can obtain a first version formatted file and at least one historical version formatted file from the target data management server. Based on the first version formatted file and at least one historical version formatted file, the original program is optimized to obtain the corresponding target program.

[0110] In this embodiment, by using message digest processing for pre-proofing, network transmission traffic is saved, and a local caching strategy is provided to cope with situations such as network outages and service anomalies, thereby improving the reliability of obtaining formatted files and ensuring that the purpose of optimizing program compilation can be achieved accurately and efficiently.

[0111] In this application embodiment, to better illustrate the method for optimizing program compilation provided by this application embodiment, a specific example is provided below to describe the method. It should be noted that this method is based on the aforementioned... Figure 3 The system architecture implementation is shown.

[0112] Please see Figure 12 As shown, Figure 12 This is a schematic diagram illustrating a method for optimizing program compilation provided in an embodiment of this application. In this embodiment, the electronic device can determine the code file to be compiled. Then, the electronic device can use UBT to instrument the code in the code file to be compiled, obtain the original program, and control UBT to pass the configured PGOService information to the PGO Service plugin.

[0113] Furthermore, the electronic device can run the raw program to obtain a profile. When the program is about to end or reaches a time set by the developer, the electronic device can automatically transmit the profile data and program description information, such as the project name and current version number, to the PGO Service. In this way, the PGO Service can process the raw profile and write the raw profile and the newly generated formatted file to the PGO Service's disk for management.

[0114] Furthermore, the electronic device can perform extreme optimization compilation of the original program based on UBT. Specifically, UBT retrieves at least one historical version format file and one first version format file from the local cache or the PGO Service, according to the configured PGO Service information. Finally, the electronic device can optimize and compile the original program using at least one historical version format file and one first version format file to generate a new program, i.e., the target program.

[0115] Based on the same inventive concept, embodiments of this application also provide an apparatus for optimizing program compilation. For example... Figure 13 As shown, this is a schematic diagram of the structure of the apparatus 1300 for optimizing program compilation, which may include:

[0116] Unit 1301 is used to compile the code file to be compiled using a compilation tool, obtain the original program, run the original program, and obtain the configuration profile file of the original program.

[0117] The processing unit 1302 is used to determine the target data management server based on the configuration information corresponding to the compilation tool, and transmit the profile file and the description information of the original program to the target data management server; so that the target data management server formats the profile file to obtain a first version formatted file, and associates and saves the first version formatted file with the formatted profile files of each historical version corresponding to the original program.

[0118] The optimization unit 1303 is used to optimize the original program based on a first version format file and at least one historical version format file obtained from the target data management server, so as to obtain the corresponding target program.

[0119] Optionally, unit 1301 is obtained, specifically for:

[0120] During the execution of the original program, in response to the interception command triggered against the original program, multiple sub-data are extracted from the generated running data corresponding to the original program according to a preset duration.

[0121] Based on multiple sub-data, the corresponding partial profile files are determined respectively;

[0122] Based on the obtained partial profile files, the configuration profile file of the original program is obtained.

[0123] Optionally, unit 1301 is obtained, specifically for:

[0124] The encapsulation order of multiple partial profile files is determined based on the order in which multiple sub-data are extracted.

[0125] Following the encapsulation order, multiple profile files are encapsulated to obtain the original program's configuration profile file.

[0126] Optionally, optimization unit 1303 is used for:

[0127] Determine if the local cache contains formatted files that were retrieved from the target data management server;

[0128] When it is determined that a formatted file is cached in the local cache, the formatted file is processed into a message digest to obtain the corresponding cache digest information;

[0129] Based on cached digest information, when it is determined that there is matching target digest information in the data management server, the original program is optimized based on the corresponding formatted file in the local cache and the first version formatted file obtained from the data management server to obtain the corresponding target program; wherein, the target digest information is the digest information corresponding to at least one historical version formatted file.

[0130] Optionally, the optimization unit 1303 is also used for:

[0131] When it is determined that no formatted file is cached in the local cache, or when no matching target digest information exists in the data management server;

[0132] Obtain the first version formatted file and at least one historical version formatted file from the target data management server;

[0133] Based on the first version format file and at least one historical version format file, the original program is optimized to obtain the corresponding target program.

[0134] Optionally, the apparatus further includes a determining unit for:

[0135] Based on the type information of the code file to be compiled, determine the compilation tool corresponding to the code file to be compiled; wherein, the configuration information of the compilation tool includes at least the address information and interface information of the data management server.

[0136] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0137] Having described the method and apparatus for compiling an optimization program according to an exemplary embodiment of this application, we will now describe an electronic device according to another exemplary embodiment of this application.

[0138] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0139] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. In this embodiment, the structure of the electronic device can be as follows: Figure 14 As shown, embodiments of this application also provide an electronic device, such as... Figure 14As shown, the electronic device in this embodiment includes at least one processor 1401, a memory 1402 connected to the at least one processor 1401, and a communication interface 1403. This embodiment does not limit the specific connection medium between the processor 1401 and the memory 1402. Figure 14 Taking the connection between processor 1401 and memory 1402 via bus 1400 as an example, bus 1400 in... Figure 14 The connections between other components are shown in thick lines only and are not intended to be limiting. The Bus 1400 can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 14 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0140] In this embodiment of the application, the memory 1402 stores instructions that can be executed by at least one processor 1401. By executing the instructions stored in the memory 1402, at least one processor 1401 can perform the steps included in the aforementioned method of compiling an optimized program.

[0141] The processor 1401 is the control center of the electronic device. It can connect to various parts of the electronic device through various interfaces and lines. By running or executing instructions stored in the memory 1402 and calling data stored in the memory 1402, it realizes various functions of the electronic device and processes data. Optionally, the processor 1401 may include one or more processing units. The processor 1401 may integrate an application processor and a modem processor. The processor 1401 mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1401. In some embodiments, the processor 1401 and the memory 1402 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.

[0142] Processor 1401 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0143] Memory 1402, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 1402 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 1402 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 1402 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0144] Communication interface 1403 is a transmission interface that can be used for communication. Data can be received or sent through communication interface 1403.

[0145] In addition, the electronic device also includes a basic input / output system (I / O system) 1404 that helps transmit information between various devices within the electronic device, and a large-capacity storage device 1408 for storing the operating system 1405, application programs 1406 and other program modules 1407.

[0146] The basic input / output system 1404 includes a display 1409 for displaying information and an input device 1410 for user input, such as a mouse or keyboard. Both the display 1409 and the input device 1410 are connected to the processor 1401 via the basic input / output system 1404 connected to the system bus 1400. The basic input / output system 1404 may also include an input / output controller for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller also provides output to a display screen, printer, or other types of output devices.

[0147] Specifically, mass storage device 1408 is connected to processor 1401 via a mass storage controller (not shown) connected to system bus 1400. Mass storage device 1408 and its associated computer-readable media provide non-volatile storage for the server package. That is, mass storage device 1408 may include computer-readable media (not shown) such as hard disk drives or CD-ROM drives.

[0148] According to various embodiments of this application, the electronic device can also be connected to a remote computer on a network such as the Internet. That is, the electronic device can be connected to the network 1411 through the communication interface 1403 connected to the system bus 1400, or the communication interface 1403 can be used to connect to other types of networks or remote computer systems (not shown).

[0149] In some possible implementations, various aspects of the optimization program compilation method provided in this application can also be implemented as a program product comprising program code. When the program product is run on an electronic device, the program code causes the electronic device to perform the steps of the optimization program compilation method according to the various exemplary embodiments of this application described above. For example, the electronic device can perform actions such as... Figure 4 The steps are shown in the figure.

[0150] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0151] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a computing device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0152] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0153] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0154] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0155] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0156] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for optimizing program compilation, characterized in that, The method includes: The code file to be compiled is compiled using a compilation tool to obtain the original program, and the original program is run to obtain the configuration profile file of the original program; Based on the configuration information corresponding to the compilation tool, a target data management server is determined, and the profile file and the description information of the original program are transmitted to the target data management server; so that the target data management server formats the profile file to obtain a first version formatted file, and associates and saves the first version formatted file with the formatted profile files of each historical version corresponding to the original program. Determine whether the local cache contains a formatted file that has been obtained from the target data management server; the target data management server processes the formatted file using concurrent read operations and queued write operations; When it is determined that the formatted file is cached in the local cache, the formatted file is processed to obtain the corresponding cache digest information; Based on the cached digest information, when it is determined that there is matching target digest information in the data management server, the original program is optimized based on the corresponding formatted file in the local cache and the first version formatted file obtained from the data management server to obtain the corresponding target program; wherein, the target digest information is the digest information corresponding to at least one historical version formatted profile file.

2. The method as described in claim 1, characterized in that, The step of running the original program to obtain its configuration profile file includes: During the execution of the original program, in response to the interception command triggered for the original program, multiple sub-data are extracted from the generated running data corresponding to the original program according to a preset duration. Based on the aforementioned multiple sub-data, corresponding partial profile files are determined respectively; Based on the obtained partial profile files, the configuration profile file of the original program is obtained.

3. The method as described in claim 2, characterized in that, The process of obtaining the configuration profile file of the original program based on the obtained multiple partial profile files includes: Based on the order in which the multiple sub-data were extracted, the encapsulation order of the multiple partial profile files was determined; The multiple partial profile files are encapsulated according to the encapsulation order to obtain the configuration profile file of the original program.

4. The method as described in claim 1, characterized in that, The method further includes: When it is determined that the formatted file is not cached in the local cache, or when there is no matching target digest information in the data management server; Obtain the first version formatted file and the at least one historical version formatted profile file from the target data management server; Based on the first version format file and the at least one historical version format profile file, the original program is optimized to obtain the corresponding target program.

5. The method according to any one of claims 1-4, characterized in that, Before using a compilation tool to compile the code file to be compiled, the method includes: Based on the type information of the code file to be compiled, the compilation tool corresponding to the code file to be compiled is determined; wherein, the configuration information of the compilation tool includes at least the address information and interface information of the data management server.

6. An apparatus for optimizing program compilation, characterized in that, The device includes: The obtaining unit is used to compile the code file to be compiled using a compilation tool to obtain the original program, and to run the original program to obtain the configuration profile file of the original program; The processing unit is configured to determine the target data management server based on the configuration information corresponding to the compilation tool, and transmit the profile file and the description information of the original program to the target data management server; so that the target data management server formats the profile file to obtain a first version formatted file, and associates and saves the first version formatted file with the formatted profile files of each historical version corresponding to the original program. An optimization unit is used to determine whether a formatted file obtained from the target data management server is cached in the local cache; the target data management server processes the formatted file using concurrent read operations and queued write operations; when it is determined that the formatted file is cached in the local cache, the formatted file is processed to obtain corresponding cache digest information; based on the cache digest information, when it is determined that matching target digest information exists in the data management server, the original program is optimized based on the corresponding formatted file in the local cache and the first version formatted file obtained from the data management server to obtain the corresponding target program; wherein, the target digest information is the digest information corresponding to at least one historical version formatted profile file.

7. The apparatus as claimed in claim 6, characterized in that, The obtaining unit is specifically used for: During the execution of the original program, in response to the interception command triggered for the original program, multiple sub-data are extracted from the generated running data corresponding to the original program according to a preset duration. Based on the aforementioned multiple sub-data, corresponding partial profile files are determined respectively; Based on the obtained partial profile files, the configuration profile file of the original program is obtained.

8. The apparatus as claimed in claim 7, characterized in that, The obtaining unit is specifically used for: Based on the order in which the multiple sub-data were extracted, the encapsulation order of the multiple partial profile files was determined; The multiple partial profile files are encapsulated according to the encapsulation order to obtain the configuration profile file of the original program.

9. The apparatus as claimed in claim 6, characterized in that, The optimization unit is further configured to: When it is determined that the formatted file is not cached in the local cache, or when there is no matching target digest information in the data management server; Obtain the first version formatted file and the at least one historical version formatted profile file from the target data management server; Based on the first version format file and the at least one historical version format profile file, the original program is optimized to obtain the corresponding target program.

10. The apparatus according to any one of claims 6-9, characterized in that, The device further includes a determining unit for: Based on the type information of the code file to be compiled, the compilation tool corresponding to the code file to be compiled is determined; wherein, the configuration information of the compilation tool includes at least the address information and interface information of the data management server.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1-5.

12. A computer-readable storage medium, characterized in that, It includes program code that, when the program product is run on an electronic device, causes the electronic device to perform the steps of the method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Automatic compiling method and compiling device for continuous integration

    CN104077140A

  • Page component development method and system, terminal and computer readable storage medium

    CN112527258A

  • Configuration file optimization method and device, server and storage medium

    CN112559088A