Speech translation program optimization method and device, computer, medium and program product
By constructing control flow graph data and performing inline processing and sequential adjustments, the problem of long compilation time and poor optimization results in the source code optimization process of voice translation service programs in the prior art is solved, and the effect of improving the processing performance and operation efficiency of voice translation service is achieved.
Patent Information
- Application Number
- CN202311548785.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-17
- Publication Date
- 2025-05-20
AI Technical Summary
When optimizing the program source code of voice translation services, the existing technology faces the problems of long compilation time, large resource consumption and complex adjustments, which are prone to introduce runtime errors, resulting in poor optimization results.
By obtaining the program source code corresponding to the voice translation service in the game application, the control flow diagram data is constructed, the data is processed inline and sequence adjustment is performed based on the data, the optimization program is generated, and the target program is determined through effect detection.
Improves the processing performance and operation efficiency of voice translation services, reduces the running time of a single request, increases the number of requests per second (QPS), and reduces the cost of service deployment and use.
Smart Images

Figure CN120020703A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a computer, a medium, and a program product for optimizing a voice translation program. Background Art
[0002] With the development of the Internet and the like, the program codes used in the background services of game applications are becoming increasingly complex and the content is increasing, but the requirements for voice translation services are getting higher and higher. Therefore, it is necessary to optimize the program source codes corresponding to the voice translation services. However, due to the complexity of the program source codes and the call logic between different code statements, the compilation of the program source codes will consume a large amount of time and resources, and it is easy to cause loopholes in the program source codes when changing the program source codes. Therefore, generally, the compiler is adjusted and configured to achieve the effect of optimizing the program source codes. However, the threshold for adjusting and configuring the compiler is very high, and it is also easy to introduce very complex runtime errors, resulting in poor program optimization effects and low efficiency of voice translation services. Summary of the Invention
[0003] Embodiments of the present application provide a method, an apparatus, a computer, a medium, and a program product for optimizing a voice translation program, which can improve the processing performance of the voice translation service program.
[0004] On the one hand, an embodiment of the present application provides a method, which includes:
[0005] Obtain the program source code corresponding to the voice translation service in the game application, compile the program source code with the first voice data to obtain the execution times and execution times of the code instructions in the program source code, and construct the control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code;
[0006] According to the call logic relationship and execution times between the code instructions in the program source code indicated by the control flow graph data, perform inlining processing and sequence adjustment on the code instructions in the program source code to generate an optimized program;
[0007] Run the optimized program with the first voice data, detect the effect of the optimized program based on the runtime information generated when the optimized program runs, and determine the optimized program that passes the detection as the target program corresponding to the voice translation service;
[0008] When the second voice data generated by the first object is collected through the game application, call the target program corresponding to the voice translation service, convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application.
[0009] One aspect of the embodiments of the present application provides a device, which includes:
[0010] An information acquisition module, configured to acquire the program source code corresponding to the voice translation service in the game application;
[0011] A code compilation module, configured to compile the program source code using the first voice data to obtain the execution times and execution times of the code instructions in the program source code, and construct the control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code;
[0012] A compilation optimization module, configured to perform inlining processing and sequential adjustment on the code instructions in the program source code according to the call logic relationship and execution times between the code instructions in the control flow graph data, and generate an optimized program;
[0013] An optimization verification module, configured to run the optimized program using the first voice data, detect the effect of the optimized program based on the running information generated when the optimized program runs, and determine the optimized program that passes the detection as the target program corresponding to the voice translation service;
[0014] A program call module, configured to call the target program corresponding to the voice translation service when the second voice data generated by the first object is collected through the game application, convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application.
[0015] Among them, the code compilation module includes:
[0016] A data acquisition unit, configured to add detection nodes to the code instructions in the program source code, generate instrumented code, compile the instrumented code N times using the first voice data, obtain the execution times and execution times of the code instructions in the program source code based on the detection nodes, and perform structure parsing on the program source code to obtain the call logic relationship between the code instructions in the program source code;
[0017] A flow graph generation unit, configured to generate nodes based on the code instructions in the program source code, and the execution times and execution times of the code instructions in the program source code, generate directed edges based on the call logic relationship between the code instructions in the program source code, and form the control flow graph data of the program source code by combining the nodes and the directed edges.
[0018] Among them, the compilation optimization module includes:
[0019] An information search unit for searching, in the control flow graph data, for the child nodes of the node corresponding to the i-th code instruction. If at least two first child nodes of the node corresponding to the i-th code instruction are found, the execution counts included in the at least two first child nodes are obtained; the parent-child relationship between the nodes in the control flow graph data is used to represent the call logic relationship between the code instructions in the program source code; i is a positive integer;
[0020] A data sorting unit for sorting the code instructions corresponding to the at least two first child nodes in the program source code based on the execution counts included in the at least two first child nodes respectively, to obtain an intermediate program i including a branch instruction sequence; the code instructions corresponding to the at least two first child nodes respectively are the branch instructions of the i-th code instruction; the branch instruction sequence includes at least two branch instructions;
[0021] A data adjustment unit for adjusting the branch instruction sequence in the intermediate program i to obtain the i-th adjusted program corresponding to the program source code;
[0022] An information determination unit for, if the i-th code instruction indicates that the adjustment of the code instructions in the program source code is completed, determining the i-th adjusted program as the optimized program.
[0023] Among them, the data adjustment unit is specifically configured to, if the first branch instruction is a function call instruction, search for the function code indicated by the first branch instruction and add an inline modifier to the function code to obtain the i-th adjusted program corresponding to the program source code; the inline modifier is used to indicate that the function code is an inline function; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i.
[0024] Among them, the data adjustment unit is specifically configured to, if at least two branch instructions in the branch instruction sequence in the intermediate program i are conditional detection instructions and the first branch instruction does not include an execution condition, obtain the first execution condition included in the second branch instruction and determine a second execution condition based on the first execution condition; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i, and the second branch instruction is the remaining branch instructions in the branch instruction sequence in the intermediate program i except the first branch instruction; add the second execution condition to the first branch instruction and update the conditional control symbols in the at least two branch instructions to obtain the i-th adjusted program.
[0025] Among them, the optimization verification module includes:
[0026] A running information determination unit is configured to obtain a first running result generated by compiling a program source code, determine a first running parameter of the program source code based on the execution times and execution times of code instructions in the program source code; obtain first voice data used when compiling the program source code, run an optimized program N times using the first voice data to obtain a second running result of the optimized program, and determine a second running parameter of the optimized program based on the execution times and execution times of code instructions in the optimized program; the first running result refers to source text data obtained by translating the first voice data through the program source code; the second running result refers to optimized text data obtained by translating the first voice data through the optimized program; N is a positive integer;
[0027] A data verification unit is configured to determine that the detection of the optimized program passes and determine the optimized program as a target program corresponding to the voice translation service if the second running result is the same as the first running result and the second running parameter is better than the first running parameter.
[0028] Wherein, it further includes:
[0029] An optimization modification module is configured to find a node corresponding to a second branch instruction from control flow graph data. If there are at least two second child nodes in the node corresponding to the second branch instruction, an optimization stop flag is added at the branch node corresponding to the second branch instruction in the control flow graph data; the optimization stop flag is used to indicate that in the control flow graph data, the code instructions of the nodes included in the subtree rooted at the branch node are not detected; if the i-th code instruction indicates that the code instructions in the program source code have not been adjusted completely, based on the optimization stop flag, find the (i + 1)-th code instruction from the control flow graph data and the child nodes of the node corresponding thereto in the control flow graph data.
[0030] On the one hand, an embodiment of the present application provides a computer device, including a processor, a memory, and an input / output interface;
[0031] The processor is respectively connected to the memory and the input / output interface. Wherein, the input / output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device including the processor executes the method in an embodiment of the present application on the one hand.
[0032] On the one hand, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program is adapted to be loaded and executed by a processor so that a computer device having the processor executes the method in an embodiment of the present application on the one hand.
[0033] One aspect of the embodiments of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in various alternative manners in one aspect of the embodiments of the present application. In other words, when the computer instructions are executed by the processor, the methods provided in various alternative manners in one aspect of the embodiments of the present application are implemented.
[0034] Implementing the embodiments of the present application will have the following beneficial effects:
[0035] In the embodiments of the present application, based on the program source code corresponding to the voice translation service in a game application, the execution times and execution times of the code instructions in the program source code are obtained, the control flow graph data of the program source code is constructed, and the program source code is recompiled based on the information in the control flow graph data. The program source code is optimized by adjusting the code instruction order and performing inlining processing on the code instructions, etc., so that the adjustment of the program source code is carried out on the basis of the execution logic of the program source code (i.e., the call logic relationship), so that the execution logic of the program source code will not be chaotic after the adjustment, ensuring the executability of the program source code, and then realizing the optimization of the program source code and improving the accuracy of program optimization. Moreover, based on the execution times and execution times of the code instructions, the code instructions are adjusted to obtain the target program corresponding to the voice translation service, so that the adjustment of the code instructions can take into account the execution frequency and time consumption of the code instructions, thereby improving the service performance and running efficiency of the program. During the target program corresponding to the voice translation service in the game application, voice data can be quickly translated into text data, improving the efficiency of the voice translation service and reducing the cost of the multimedia service. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0037] Figure 1 It is a network interaction architecture diagram of a voice translation program optimization method provided by the embodiments of the present application;
[0038] Figure 2 It is a scenario schematic diagram of a voice translation program optimization method provided by the embodiments of the present application Figure 1 ;
[0039] Figure 3 It is a schematic diagram of the scenario of an optimized method for a voice translation program provided by an embodiment of the present application Figure 2 ;
[0040] Figure 4 It is a flowchart of an optimized method for a voice translation program provided by an embodiment of the present invention Figure 1 ;
[0041] Figure 5 They are two schematic diagrams of control flow graph data generated by a computer device provided by an embodiment of the present application;
[0042] Figure 6 It is a flowchart of an optimized method for a voice translation program provided by an embodiment of the present application Figure 2 ;
[0043] Figure 7 It is a flowchart of an optimized method for a voice translation program provided by an embodiment of the present application Figure 3 ;
[0044] Figure 8 It is a schematic diagram of an optimized device for a voice translation program provided by an embodiment of the present application;
[0045] Figure 9 It is a schematic diagram of the structure of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0046] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0047] Among them, if it is necessary to collect data of an object (such as a user, etc.) in the present application, a prompt interface or a pop-up window is displayed before and during the collection. The prompt interface or the pop-up window is used to prompt the user that some data is being collected currently. Only after obtaining the confirmation operation of the user on the prompt interface or the pop-up window, the relevant steps of data acquisition are started, otherwise it ends. Moreover, the obtained user data will be used in reasonable, legal scenarios or uses, etc. Optionally, in some scenarios where user data needs to be used but the user's authorization has not been obtained, authorization can also be requested from the user, and the user data will be used only when the authorization is passed.
[0048] Among them, the following explanations are given for some nouns involved in the present application:
[0049] 1. Gcov Data File: A file format used to collect feedback information during program execution.
[0050] 2. Inline function optimization: A compiler optimization technique that can convert the overhead of function calls into code within the function body, thereby improving the execution efficiency of the program.
[0051] 3. Branch prediction: A technique in computer architecture used to predict the execution results of branch instructions in a program to improve the execution efficiency of the program.
[0052] 4. LLVM: An open-source compiler infrastructure project that includes a set of modular compiler tools and libraries and can be used to build compilers, debuggers, static analysis tools, code optimization tools, etc.
[0053] 5. Query Per Second (QPS): The number of requests per second.
[0054] 6. Code instruction: The smallest execution unit generated by code compilation.
[0055] 7. Inline function: A programming language feature used to directly expand the function body at the point of function call instead of executing the function through function call. The purpose of inline functions is to reduce the overhead of function calls and improve the execution efficiency of the program.
[0056] In the embodiments of the present application, please refer to Figure 1 , Figure 1 is a network interaction architecture diagram of an optimized method for a voice translation program provided by the embodiments of the present application. The embodiments of the present application can be implemented by a computer device, and the computer device includes but is not limited to a terminal device or a server. In other words, the computer device can be a server or a terminal device, or a system composed of a server and a terminal device. Among them, the network architecture diagram may include a computer device 101 and one or more service devices, such as Figure 1 shown in the service device 102a, service device 102b, service device 102c, etc. The computer device 101 has a communication connection with the service device 102a, service device 102b, and service device 102c, so as to indirectly implement the communication connection between the service devices through the computer device 101, and each service device can achieve data transmission through the computer device 101. Among them, the above-mentioned service devices may be an electronic device, including but not limited to mobile phones, tablet computers, desktop computers, laptop computers, palmtop computers, etc. The above-mentioned communication connection is not limited to the connection method, and can be directly or indirectly connected through a wired communication connection, or can be directly or indirectly connected through a wireless communication method, or can be connected through other methods, and the present application does not make any restrictions here.
[0057] It should be understood that Figure 1 the computer device 101 as shown maintains the program source code corresponding to the voice translation service in the game application, compiles the program source code based on the first voice data, obtains the instruction execution information of the code instructions in the program source code, constructs the control flow graph data of the program source code based on the execution time and execution times of the code instructions in the instruction execution information; performs inlining processing and sequential adjustment on the code instructions in the program source code according to the call logic relationship and execution times between the code instructions indicated in the control flow graph data to generate an optimized program; runs the optimized program using the first voice data, performs effect detection on the optimized program based on the running information generated during the running of the optimized program, and determines the optimized program that passes the detection as the target program corresponding to the voice translation service. If the computer device receives any data information of the same type as the above-mentioned first voice data (i.e., the second voice data) sent by a service device connected to the computer device, taking the service device 102c as an example here, the computer device 101 receives the second voice data sent by the service device 102c, and based on the second voice data, the computer device 101 directly calls the target program corresponding to the voice translation service to convert the second voice data, obtains the target text data, and returns the second data information to the service device 102c so that the service device 102c can display the target text data on the display interface. If the service device 102c determines that the target text data is correct and can perform the next sending operation, then based on the computer device 101 forwards the second data information to the remaining service devices that are directly or indirectly communicatively connected to the service device 102c, so that the remaining service devices can display the second data information on the display page. The above-mentioned remaining service devices include but are not limited to the service device 102a and the service device 102b.
[0058] That is to say, the computer device 101 can optimize the program source code stored locally or the program source code sent by any service device to obtain the target program corresponding to the program source code. When the computer device 101 receives an execution request for the program source code, it can directly execute the target program to obtain the request result corresponding to the execution request, and can output the request result. Among them, the execution request can be triggered locally on the computer device 101 or sent by any service device. If the execution request is sent by the service device 102a, the request result can be sent to the service device 102a. Through the above process, the processing process of the computer device 101 for processing the first data information into the second data information is more efficient, reducing the running time of a single information processing service request, improving the QPS, and reducing the costs of service deployment and use.
[0059] It is understandable that the computer device in the embodiments of the present application includes, but is not limited to, a terminal device or a server. In other words, the computer device can be a server or a terminal device, or a system composed of a server and a terminal device. Among them, the above-mentioned terminal device can be an electronic device, including but not limited to a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a vehicle-mounted device, an Augmented Reality / Virtual Reality (AR / VR) device, a head-mounted display, a smart TV, a wearable device, a smart speaker, a digital camera, a camera, and other mobile internet devices (MID) with network access capabilities, or terminal devices in scenarios such as trains, ships, and flights. As Figure 1 shown in Figure 1 , the terminal device can be a laptop computer, a mobile phone, a vehicle-mounted device, etc.,
[0060] Only some of the devices are listed. Among them, the above-mentioned server can be an independent physical server, or 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 communications, middleware services, domain name services, security services, vehicle-road collaboration, Content Delivery Network (CDN), and big data and artificial intelligence platforms.
[0061] Specifically, please refer to Figure 2 , Figure 2 which is a scenario schematic diagram of a method for optimizing a voice translation program provided by an embodiment of the present application. Figure 1 As Figure 2 shown in Figure 2, the optimization service involved in the embodiments of this application is implemented in the voice interaction service of a game application. The computer device 201 maintains the program source code that provides the voice interaction service. Based on the first voice data, it compiles the program source code that provides the voice interaction service, performs optimization processing on the program source code, and obtains the target program corresponding to the program source code of the voice interaction service. Further, when the service device 202c receives an audio message of "ready to surround" through the microphone icon on its display interface, it sends the audio message to the computer device corresponding to the computer device 201 that carries the target program for translation processing. The computer device 201 can directly call the optimized target program. Based on this target program, the computer device 201 can quickly obtain the text message "ready to surround" corresponding to the audio message and return it to the service device 202c. The service device 202c can display the text message "ready to surround" in the game interface. Among them, there are game objects 2021 corresponding to the service device 202c, game objects 2022 corresponding to the service device 202a, and game object 2023 on the display interface of the service device 202c; there are also game objects 2021 corresponding to the service device 202c, game objects 2022 corresponding to the service device 202a, and game object 2023 on the display interface of the service device 202a.
[0062] When the game objects 2021 and 2022 are in the same group of game objects, at this time, the text message sent by the service device 202c (i.e., the game object 2021) can only be viewed by the game objects in the same group (i.e., the game object 2022). At this time, the service device 202c receives a request to send information, and sends the text message "ready to surround" to the service device 202a that has a communication connection with the service device 202c through the computer device 201, so that the service device 202a can display it in its display interface, as Figure 2 shown, the content of the text message "ready to surround" and the sender 2021 (corresponding to the service device 202c) of the text message are displayed in the game interface of the service device 202a. Now, many game players communicate through voice in game applications, and the voice translation service is an extremely important part. Since there are a large number of operation characteristics with business characteristics in the voice translation service, there are many logics that may be repeated and concentrated. By optimizing the program source code corresponding to the voice translation service, when the voice translation service is called later, the optimized target program can be directly used to provide the voice translation service. The optimization of the target program improves the operation efficiency of the voice translation service, reduces the operation time of a single request, and thus can also increase the number of requests per second (QPS).
[0063] For details, see Figure 3 , Figure 3 is a scenario schematic diagram of a method for optimizing a voice translation program provided by the embodiments of this applicationFigure 2 , the schematic diagram of this scenario is used to illustrate the optimization process of the voice translation program executed on the computer device side. As Figure 3 shown, the computer device obtains the code statements in the program source code 301, performs binary conversion on the code statements in the program source code, and obtains the code instructions corresponding to the code statements. The number of these code instructions can be denoted as M, and M is a positive integer. Such as Figure 3 the code instruction 1, code instruction 2,... and code instruction M shown in it. Compile the program source code 301 N times, and collect the instruction execution information of each code instruction generated during the operation of the program source code 301, such as the instruction execution information 1 corresponding to the code instruction 1,... and the instruction execution information M corresponding to the code instruction M. Among them, the instruction execution information may include the execution times and execution times of the code instructions in the program source code 301 during N compilations, and the control flow graph data 302 of the program source code 301 constructed based on the execution times and execution times; the computer device performs inlining processing and sequential adjustment on the code instructions in the program source code based on the control flow graph data 302, and generates an optimized program 303; and performs effect detection on the optimized program 303, and determines the optimized program 303 that passes the detection as the target program corresponding to the program source code 301. The target program can improve the execution speed through optimization methods such as branch prediction and inline functions. The computer device can directly call the target program to quickly process the audio information sent by the service device, reduce the running time of the service requests initiated by the service device, and at the same time reduce the costs of service deployment and use.
[0064] Further, please refer to Figure 4 , Figure 4 is the flow schematic of a voice translation program optimization method provided by an embodiment of the present invention Figure 1 , the voice translation program optimization method is executed by a computer device. As Figure 4 shown, the method includes the following steps:
[0065] Step S101, obtain the program source code corresponding to the voice translation service in the game application, compile the program source code with the first voice data, obtain the execution times and execution times of the code instructions in the program source code, and construct the control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code.
[0066] Specifically, the computer device can obtain the program source code corresponding to the voice translation service in the game application, perform binary conversion on the code statements in the program source code to obtain the code instructions corresponding to the code statements, and form an executable program file recognizable by the computer device. Based on the first voice data, the executable program file is run, and the execution times and execution times of the code instructions in the program source code during runtime are collected, that is, the instruction execution information of the code instructions in the program source code during runtime is collected. Alternatively, the computer device can obtain the code statements in the program source code corresponding to the voice translation service in the game application, determine the code statements as code instructions, and can compile the program source code using the first voice data to obtain the instruction execution information of the code instructions included in the program source code. Further, the control flow graph data of the program source code can be constructed based on the execution times and execution times of the code instructions in the program source code. The control flow graph data can be an abstract representation of the program source code, representing all the paths that will be traversed during the execution of the program source code. Among them, the computer device performs binary conversion on the code statements to obtain the code instructions corresponding to the code statements, and forms an executable program file recognizable by the computer device, including four stages: preprocessing, compilation, assembly, and linking. For example, in the preprocessing stage, the computer device can delete all "#define", expand all macro definitions, process all conditional control symbols, delete all comments, etc., to obtain a preprocessing text file with the file extension ".i", which will not be elaborated here one by one. The conditional control symbols can be "if, ifded, elif, else, endif", etc.; in the compilation stage, the computer device performs a series of lexical analysis, syntax analysis, semantic analysis, and optimization on the preprocessing text file, and translates it into a text file with the file extension ".s"; in the assembly stage, the computer device translates the text file with the file extension ".s" into machine instructions, packs these machine instructions into a format called relocatable object program, and saves the result in a binary file with the file extension ".o"; finally, the executable program file is obtained through link merging. The executable program file can be loaded into memory and executed by the system. For example, there are code statement fragments "foo(){if(cond)foo_stmt;}" and "bar(){bar_stmt;foo();}" in the program source code. The code instruction fragments after the computer device performs binary conversion on the above two code statement fragments are shown in Table 1.
[0067] Table 1
[0068]
[0069] Among them, the process of collecting the execution times and execution times of code instructions in the source code of a running program can be to add detection nodes to the code instructions in the source code of the program, generate instrumented code, compile the instrumented code N times using the first voice data, and based on the detection nodes, obtain the execution times and execution times of the code instructions in the source code of the program during N compilations, and perform a structural analysis on the source code of the program to obtain the call logic relationship between the code instructions in the source code of the program; N is a positive integer. Specifically, the computer device can call an analysis tool or library to add detection nodes, such as probes, to each of the M code instructions included in the source code of the program, generating a piece of instrumented code. That is to say, each code instruction in the source code of the program is associated with a detection node, which can be a code segment for information collection, an assignment statement, or a function call for collecting coverage information. The detection node can include a counter for recording the execution times and a timer for recording the execution time, etc. Further, compile the instrumented code N times to obtain the detection compilation data generated by the M detection nodes during N compilations. The detection compilation data includes, but is not limited to, the execution status, single execution time, and single execution result generated by the corresponding detection node in each compilation, etc. M is a positive integer; the N detection compilation data corresponding to each detection node can be statistically analyzed to obtain the instruction execution information corresponding to the detection node. The instruction execution information includes, but is not limited to, the execution time and execution times of the code instruction targeted by the detection node, etc.
[0070] Among them, the execution status includes the executed status and the unexecuted status. The computer device can count the number of compilations in which the execution status of the detection node of the j-th code instruction is the executed status during N compilations to obtain the execution times of the j-th code instruction; the statistical value of the single execution times corresponding to the detection node of the j-th code instruction during N compilations can be determined as the execution time of the j-th code instruction. The statistical value can be the maximum value, median value, or average value of the N single execution times, etc. Among them, j is a positive integer less than or equal to M. Through this process, the instruction execution information corresponding to each of the M code instructions can be obtained.
[0071] Further, based on the instruction execution information of the code instructions in the program source code, the control flow graph data of the program source code can be constructed. Specifically, nodes can be generated based on the code instructions in the program source code, as well as the execution times and execution times of the code instructions in the program source code (i.e., instruction execution information). Directed edges can be generated based on the call logic relationship between the code instructions in the program source code. The nodes and directed edges are combined to form the control flow graph data of the program source code. The computer device analyzes the execution times, execution times of the code instructions in the program source code, and the data flow information of the program execution, and combines the code instructions in the program source code with the execution times and execution times of the code instructions to generate a node. The node represents the basic unit of code execution. Directed edges are generated for the corresponding nodes based on the call logic relationship and conditional branch situation between the code instructions in the program source code, and combined into the control flow graph data of the program source code. For example, when a conditional statement is encountered, different execution paths may be selected according to the result of the condition, and these paths can be represented by directed edges. For a specific example, if there is a code instruction segment "foo(){if(cond)foo_stmt;}" in the program source code, where the code instruction "if_stmt" is executed 50 times and the code instruction "foo_stmt" is executed 10 times, then the code instructions "foo()", "if_stmt", and "foo_stmt" generate 3 nodes respectively. The nodes contain information such as the code instruction and its execution times. The node corresponding to the code instruction "foo()" generates two directed edges pointing to the nodes corresponding to the code instructions "if_stmt" and "foo_stmt" respectively.
[0072] See further Figure 5 , Figure 5 FIGS. and
[0073] are schematic diagrams of two control flow graph data generated by the computer device provided in the embodiments of the present application. Among them, the box node represents that there are branches in the node. "ESL: {}" in the node indicates the specific position of the code instruction corresponding to the node in the function code body. For example, "ESL:{bar:2:0}" indicates that the node corresponds to the second code instruction in the code body of the function "bar()"; "TotalCount:300" indicates that the execution times of the code instruction corresponding to the node is 300 times; "Function:foo" indicates that the code instruction corresponding to the node is a function call instruction; "if_stmt;" indicates the code instruction corresponding to the node. The computer device determines two child nodes of the node corresponding to the code instruction "bar()" based on the first control flow graph data.
[0073] Step S102, according to the call logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data, perform inlining processing and sequential adjustment on the code instructions in the program source code to generate an optimized program.
[0074] Specifically, the control flow graph data stores all the paths that will be traversed during the execution of the code instructions in the program source code, as well as the execution times and execution counts of each code instruction included in each path. The computer device can search for the i-th code instruction in the control flow graph data and find the first child node of the corresponding node in the control flow graph data. If there are at least two first child nodes for the node corresponding to the i-th code instruction, obtain the execution counts included in each of the at least two first child nodes; the parent-child relationship between the nodes in the control flow graph data is used to represent the call logic relationship between the code instructions in the program source code; i is a positive integer; sort the code instructions corresponding to each of the at least two first child nodes based on the execution counts included in each of the at least two first child nodes to obtain a branch instruction sequence; the code instructions corresponding to each of the at least two first child nodes are the branch instructions of the i-th code instruction; the branch instruction sequence includes at least two branch instructions. Further, the branch instruction sequence can be adjusted to obtain the i-th adjusted program. Specifically, the computer device can detect the branch instructions in the branch instruction sequence, determine the instruction types of the branch instructions in the branch instruction sequence, and adjust the branch instruction sequence according to the instruction types of the branch instructions in the branch instruction sequence to obtain the i-th adjusted program. Among them, the instruction types include but are not limited to function call types and conditional detection types, etc.
[0075] Further, if the i-th code instruction indicates that the adjustment of the code instructions in the program source code is completed, determine the i-th adjusted program as the optimized program. If the i-th code instruction indicates that the adjustment of the code instructions in the program source code is not completed, based on the optimization stop flag, search for the (i + 1)-th code instruction in the control flow graph data and find the child node of the corresponding node in the control flow graph data.
[0076] It should be understood that the above process of optimizing the adjustable order and inlined code instructions in the program source code is not directly adjusted in the code statements of the program source code, but is adjusted to the executable program file composed of the code instructions corresponding to the code statements in the program source code during compilation.
[0077] Step S103, run the optimized program with the first voice data, detect the effect of the optimized program based on the running information generated during the running of the optimized program, and determine the optimized program that passes the detection as the target program corresponding to the voice translation service.
[0078] Specifically, after the optimization process ends, the computer device also needs to use the same data (i.e., the first voice data) to verify the optimization program, obtain the first running result generated by compiling the program source code, and determine the first running parameters of the program source code based on the execution times and execution times of the code instructions in the program source code; the first running result refers to the source text data translated from the first voice data through the program source code; the first running parameter is the first relevant running information generated by running the program source code based on the first voice data, and the first relevant running information includes the first execution times and the first execution time of the code instructions; obtain the first voice data used when compiling the program source code, run the optimization program N times with the first voice data, obtain the second running result of the optimization program, and determine the second running parameters of the optimization program based on the execution times and execution times of the code instructions in the optimization program; N is a positive integer; the second running result refers to the optimized text data translated from the first voice data through the optimization program; the second running parameter is the second relevant running information generated by running the optimization program based on the first voice data; the second relevant running information includes the second execution times and the second execution time of the code instructions; if the second running result is the same as the first running result, that is, the source text data is the same as the optimized text data, and the second running parameter is better than the first running parameter, that is, the second execution times and the second execution time are respectively less than the first execution times and the first execution time, then it is determined that the detection of the optimization program passes, and the optimization program is determined as the target program corresponding to the voice translation service. Among them, the running parameter refers to the data generated during the compilation of the corresponding program, which can be used to characterize the compilation performance of the program, and can include, but is not limited to, the execution times and execution time of the code instructions during the running of the program. For example, the first running parameter can be used to characterize the compilation performance of the program source code, and the second running parameter can be used to characterize the compilation performance of the optimization program, etc.
[0079] Step S104, when the second voice data generated by the first object is collected through the game application, call the target program corresponding to the voice translation service, convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application.
[0080] In an embodiment of the present application, after optimizing the program source code of the voice translation service to obtain the target program corresponding to the voice translation service, the target program is applied to a game. When the computer device (i.e., the game running device at this time) collects the second voice data generated by the first object through the game application, the computer device calls the target program, runs the target program based on the second voice data, converts the second voice data into target text data, and displays the obtained target text data on the page (i.e., in the interface of the game application). For example, when the first object inputs an audio message "Hello" by clicking the microphone button on the game interface, the computer device responds to the click operation, collects the audio message "Hello" input by the first object and converts it into audio data corresponding to the audio message "Hello", calls the target program corresponding to the voice translation service, runs the target program to convert the above audio data into target text data "Hello", and displays the text information of the target text data "Hello" in the game interface.
[0081] For example, in the voice interaction service for game applications of the present application, at this time, the first language data may be multiple segments of voice audio. There is a large amount of repetitive and concentrated logic in the program source code corresponding to the voice interaction service, such as code instructions for voice resampling, access to the Remote Dictionary Server (Redis) component, network requests, etc. The program source code can be compiled to obtain the instruction execution information of code instructions such as voice resampling, access to the Redis component, and network requests. Assuming that the execution times of the code instructions corresponding to operations related to Redis (such as access to the Redis component) are relatively large, that is, relatively frequent, the function code of the code instructions corresponding to operations related to Redis can be inlined and expanded, the order of branch instructions corresponding to operations related to Redis can be adjusted, etc. At the same time, the remote dictionary service pipeline technology (Redis pipeline) can be used to package some code instructions related to operations related to Redis to obtain batch processing data until the optimization of the entire program source code is completed to obtain an optimized program. Through the above process, code instructions with similar execution times can be stored in positions with similar binaries, thereby reducing the overhead and latency of network communication, improving the performance and throughput of Redis. Among them, voice resampling is a digital signal processing technology used to convert a voice signal of one sampling rate into a voice signal of another sampling rate. Among them, Redis is an open-source in-memory data storage system, also known as a data structure server. Redis pipeline is a technology that optimizes the communication between the Redis client and the Redis server, which can package multiple Redis commands into a batch request and send it to the Redis server at one time, thereby reducing the overhead and latency of network communication, improving the performance and throughput of Redis, and thus improving the performance and execution efficiency of the program source code and enriching the gaming object experience.
[0082] In an embodiment of the present application, a computer device may obtain the program source code corresponding to the voice translation service in a game application, compile the program source code using first voice data to obtain the execution times and execution times of the code instructions in the program source code, and construct control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code; according to the call logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data, perform inlining processing and sequential adjustment on the code instructions in the program source code to generate an optimized program; run the optimized program using the first voice data, and perform effect detection on the optimized program based on the running information generated when the optimized program runs, and determine the optimized program that passes the detection as the target program corresponding to the voice translation service; when second voice data generated by a first object is collected through the game application, call the target program corresponding to the voice translation service, and convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application. Through the above process, without modifying any line of code in the server (i.e., any code statement in the program source code), the computer device can collect the execution times and execution times of the code instructions in the program source code to assist optimization. When recompiling, for input parameters, optimize in terms of branch prediction, code layout, function inlining, etc., so as to improve the processing performance of word requests of the voice translation service by 20% and reduce the costs of service deployment and use.
[0083] Please also refer to Figure 6 , Figure 6 which is a flowchart showing a method for optimizing a voice translation program provided by an embodiment of the present application Figure 2 , and this data processing method can be executed by a computer device. As Figure 6 shown, the method includes:
[0084] Step S201, find the first child node corresponding to the i-th code instruction in the control flow graph data, and sort the code instructions corresponding to the first child node in the program source code to obtain an intermediate program i including a branch instruction sequence.
[0085] Specifically, the computer device analyzes and processes the information in the control flow graph data to find the sub-node corresponding to the i-th code instruction in the control flow graph data. If there are at least two first sub-nodes corresponding to the i-th code instruction in the program source code, it indicates that the i-th code instruction has at least two branches. Then, obtain the execution times respectively included in the at least two first sub-nodes, that is, the execution times respectively corresponding to each branch instruction corresponding to the i-th code instruction; sort each branch instruction based on the execution times of each branch instruction corresponding to the i-th code instruction to obtain an intermediate program i including a branch instruction sequence. For example, when the i-th code instruction has 5 branches, the execution times of the first branch instruction is 30, the second branch instruction is 10, the third branch instruction is 120, the fourth branch instruction is 100, and the fifth branch instruction is 300, the generated branch sequence is composed of the code instructions respectively corresponding to the fifth branch instruction, the third branch instruction, the fourth branch instruction, the first branch instruction, and the second branch instruction in sequence.
[0086] Step S202, determine the instruction type of the branch instructions in the branch instruction sequence in the intermediate program i.
[0087] In the embodiment of the present application, the instruction type of the first branch instruction in the branch instruction sequence in the intermediate program i can be obtained. The instruction type includes but is not limited to function call type, conditional detection type, and Remote Dictionary Server (Redis) type, etc.
[0088] Step S203, adjust the branch instruction sequence according to the instruction type of the branch instructions in the branch instruction sequence in the intermediate program i.
[0089] In an embodiment of the present application, if the first branch instruction in the branch instruction sequence in the intermediate program i is a function call instruction, that is, the instruction type of the first branch instruction is a function call type, then inlining processing can be performed on the function code corresponding to the function call instruction. After the computer device processes the code instructions in the program source code that can be reordered and inlined, an optimized program can be obtained. Specifically, the function code indicated by the first branch instruction can be searched, and an inlining modifier is added to the function code to obtain the i-th adjusted program corresponding to the program source code; the inlining modifier is used to indicate that the function code is an inline function; the first branch instruction is the first branch instruction in the branch instruction sequence. Among them, the computer device can obtain the code language type of the program source code and add the inlining modifier corresponding to the code language type to the function code. For example, if the code language type of the program source code is "C language", the above inlining modifier can be "inline"; if the code language type of the program source code is "JAVA language", the above inlining modifier can be "final". The inlining modifier is used to define the function code as an inline function. However, if the above function is a complex structural control statement or a recursive function, the function cannot be successfully inlined. The function code defined as an inline function does not need to perform an instruction jump when making a function call and can directly execute the instructions in sequence. For example, at this time, there is a code snippet "A = (foo()? bar(): baz())". After the computer device determines the execution times of the functions "foo()" and "bar()", it can immediately call the execution times of the function "baz()" to determine the branch prediction optimization at the function level. If the execution times of the function "baz()" are greater than the execution times of the function "bar()" at this time, the function "baz()" is used as the predicted branch for the function "foo()" next, that is, the code instructions corresponding to the function "baz()" are adjusted to before the code instructions corresponding to the function bar(), and inlining adjustment is performed on the high-frequency function "baz()".
[0090] If at least two branch instructions in the branch instruction sequence in the intermediate program i are conditional detection instructions, and the first branch instruction does not include an execution condition, that is, the instruction types of at least two branch instructions are conditional detection types, then the first execution condition included in the second branch instruction is obtained, and the second execution condition is determined based on the first execution condition; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i, and the second branch instruction is the remaining branch instructions in the branch instruction sequence in the intermediate program i except the first branch instruction; the second execution condition is added to the first branch instruction, and the condition control symbol in at least two branch instructions is updated to obtain the i-th adjusted program corresponding to the program source code.
[0091] Specifically, if the computer device detects that at least two branch instructions in the branch instruction sequence of the intermediate program i are conditional detection instructions, such as conditional detection statements like "if, else", and the first branch instruction is a branch instruction without an execution condition like an else statement, then obtain the first execution condition included in the second branch instruction, determine the second execution condition based on the first execution condition, add the second execution condition to the first branch instruction, and update the conditional control symbol in at least two branch instructions to obtain the i-th adjusted program corresponding to the program source code. For example, if the above first branch instruction is "else{print("a is greater than 20\n");}", and the second branch instruction is "if(a<20){printf("a is less than 20\n");}", then the adjusted first branch instruction is "if(a>20){print("a is greater than 20\n");", and the second branch instruction is "else{printf("a is less than 20\n");}".
[0092] If at least two branch instructions in the branch instruction sequence are Redis instructions, that is, the instruction types of at least two branch instructions are of the Redis type, then the Redis packaging technology (such as Redis pipeline, etc.) can be used to package at least two branch instructions and the affiliated instructions of each branch instruction into batch processing data to obtain the i-th adjusted program. The affiliated instruction of a branch instruction refers to the code instructions of the nodes other than the node corresponding to the branch instruction in the subtree rooted at the node corresponding to the branch instruction in the control flow graph data.
[0093] Furthermore, the computer device also needs to find the node corresponding to the second branch instruction from the control flow graph data. If there are at least two second child nodes in the node corresponding to the second branch instruction, then add an optimization stop flag at the branch node corresponding to the second branch instruction in the control flow graph data; the optimization stop flag is used to indicate that in the control flow graph data, the code instructions of the nodes included in the subtree rooted at the branch node are not detected; the second branch instruction is the remaining branch instructions in the branch instruction sequence except the first branch instruction ranked first.
[0094] Specifically, the computer device also needs to find the node corresponding to the second branch instruction from the control flow graph data, determine the number of second child nodes existing in the node corresponding to the second branch instruction. If there are at least two second child nodes in the node corresponding to the second branch instruction, an optimization stop flag is added at the branch node corresponding to the second branch instruction in the control flow graph data. During the program execution process, the computer device can recognize this optimization stop flag and does not perform optimization adjustment on the code instructions of the nodes included in the subtree with the node corresponding to this optimization stop flag as the root node. For example, if the second branch instruction is an if statement and there is an if / else conditional detection statement nested in this if statement, an optimization stop flag is added at the corresponding position of this if statement in the control flow graph data. When the computer recognizes this optimization stop flag, it does not perform the above optimization adjustment process on the if / else conditional detection statement in the if statement.
[0095] Step S204, detect the adjustment result of the code instruction in the program source code indicated by the i-th code instruction.
[0096] In the embodiment of the present application, if the i-th code instruction indicates that the adjustment of the code instruction in the program source code is not completed, return to execute step S201. Specifically, if the i-th code instruction indicates that the adjustment of the code instruction in the program source code is not completed, based on the node corresponding to the i-th code instruction, perform a depth-first traversal on the control flow graph data, and determine the code instruction corresponding to the first node that is not associated with the optimization stop flag obtained by the traversal as the i-th code instruction (that is, the (i + 1)-th code instruction in step S102 above), and return to execute step S201, so as to optimize the next code instruction. Optionally, a breadth-first traversal can also be performed on the control flow graph data. The breadth-first traversal means starting from an un-traversed node in the control flow graph data, first traversing the adjacent nodes of this node, and then sequentially traversing the adjacent nodes of each adjacent node. Optionally, when traversing the control flow graph data, if the k-th node is traversed and associated with the optimization stop flag, starting from the k-th node, continue to traverse the nodes in the control flow graph data except for the subtree with the k-th node as the root node until the first node that is not associated with the optimization stop flag is obtained, where k is a positive integer. Figure 5 wherein, if the i-th code instruction indicates that the adjustment of the code instruction in the program source code is completed, execute step S205.
[0097]
[0098] Step S205, determine the optimization program.
[0099] In the embodiment of the present application, if the i-th code instruction indicates that the adjustment of the code instruction in the program source code is completed, determine the i-th adjustment program as the optimization program.
[0100] See Figure 7 , Figure 7 which is a schematic flowchart of a method for optimizing a voice translation program provided by an embodiment of the present application Figure 3 The above computer obtains the code instructions in the program source code, and the process of compiling the program source code corresponds to Figure 7 the process from the resource library to compilation. Among them, the program source code comes from the resource library. The execution times and execution times (execution instruction information) of the code instructions obtained by compiling the program source code and the execution instruction information based on the code instructions flow through the ingestor to the collector, are transmitted to the sample database, and finally, through the configuration file generator, a configuration file is generated and stored in the resource library. The computer device re-compiles and optimizes the program source code based on the configuration file (i.e., information such as the execution times and execution times of the code instructions and control flow graph data) to obtain a binary file (i.e., an optimized program) for archiving. The process of step S103 corresponds to Figure 7 the process in which the computer device calls the system performance analysis tool to perform performance analysis on the binary file of the release version to obtain the binary file of the release version. Among them, the release version refers to a binary file generated after optimizing the speed of the program during compilation without debugging the program source code and improving the code running speed.
[0101] The above details the method of the embodiment of the present invention. The following provides the device of the embodiment of the present invention. Please see Figure 8 , Figure 8 which is a schematic diagram of a voice translation program optimization device provided by an embodiment of the present application. The voice translation program optimization device may be a computer program (including program code, etc.) running in a computer device. For example, the voice translation program optimization device may be an application software; the device may be used to execute the corresponding steps in the method provided by the embodiment of the present application. As Figure 8 shown, the voice translation program optimization device 800 may be used for Figure 4 and Figure 6 the computer devices in the corresponding embodiments. Specifically, the voice translation program optimization device may include: an information acquisition module 11, a code compilation module 12, a compilation optimization module 13, an optimization modification module 14, an optimization verification module 15, and a program call module 16.
[0102] The information acquisition module 11 is used to obtain the program source code corresponding to the voice translation service in the game application. The specific implementation manner of the information acquisition module 11 may refer to Figure 4 the description of step S101 in the corresponding embodiment, which will not be elaborated here.
[0103] The code compilation module 12 is used to compile the program source code with the first voice data to obtain the execution times and execution times of the code instructions in the program source code, and construct the control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code.
[0104] Among them, the code compilation module 12 includes:
[0105] The data acquisition unit 121 is used to add detection nodes to the code instructions in the program source code, generate instrumented code, compile the instrumented code N times with the first voice data, obtain the execution times and execution times of the code instructions in the program source code during N compilations based on the detection nodes, perform a structural analysis on the program source code, and obtain the call logic relationship between the code instructions in the program source code. The specific implementation manner of the data acquisition unit 121 can be referred to Figure 4 the description of step S101 in the corresponding embodiment, which will not be elaborated here.
[0106] The flow graph generation unit 122 is used to generate nodes based on the code instructions in the program source code, as well as the execution times and execution times of the code instructions in the program source code, generate directed edges based on the call logic relationship between the code instructions in the program source code, and form the control flow graph data of the program source code by combining the nodes and the directed edges. The specific implementation manner of the flow graph generation unit 122 can be referred to Figure 4 the description of step S101 in the corresponding embodiment, which will not be elaborated here.
[0107] The compilation optimization module 13 is used to perform inlining processing and sequence adjustment on the code instructions in the program source code according to the call logic relationship and execution times between the code instructions in the control flow graph data, and generate an optimized program.
[0108] Among them, the compilation optimization module 13 includes:
[0109] The information search unit 131 is used to search for the i-th code instruction in the control flow graph data, the child nodes of the node corresponding to the i-th code instruction in the control flow graph data. If there are at least two first child nodes corresponding to the node of the i-th code instruction, obtain the execution times respectively included in the at least two first child nodes; the parent-child relationship between the nodes in the control flow graph data is used to represent the call logic relationship between the code instructions in the program source code; i is a positive integer.
[0110] A data sorting unit 132, configured to sort code instructions corresponding to at least two first child nodes in a program source code based on the number of executions respectively included in the at least two first child nodes, so as to obtain an intermediate program i including a branch instruction sequence; the code instructions corresponding to the at least two first child nodes are branch instructions of the i-th code instruction; the branch instruction sequence includes at least two branch instructions.
[0111] For the specific implementation manners of the information search unit 131 and the data sorting unit 132, reference can be made to Figure 6 the description of step S201 in the corresponding embodiment, which will not be elaborated here.
[0112] A data adjustment unit 133, configured to adjust the branch instruction sequence in the intermediate program i to obtain the i-th adjusted program corresponding to the program source code; wherein, the data adjustment unit 133 is specifically configured to, if the first branch instruction is a function call instruction, search for the function code indicated by the first branch instruction, add an inline modifier to the function code to obtain the i-th adjusted program corresponding to the program source code; the inline modifier is used to indicate that the function code is an inline function; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i. The data adjustment unit 133 is further specifically configured to, if at least two branch instructions in the branch instruction sequence in the intermediate program i are conditional detection instructions and the first branch instruction does not include an execution condition, obtain the first execution condition included in the second branch instruction, and determine a second execution condition based on the first execution condition; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i, and the second branch instruction is the remaining branch instructions in the branch instruction sequence in the intermediate program i except the first branch instruction; add the second execution condition to the first branch instruction, and update the condition control symbol in the at least two branch instructions to obtain the i-th adjusted program. For the specific implementation manner of the data adjustment unit 133, reference can be made to Figure 6 the description of step S203 in the corresponding embodiment, which will not be elaborated here.
[0113] An information determination unit 134, configured to determine the i-th adjusted program as an optimized program if the i-th code instruction indicates that the adjustment of the code instructions in the program source code is completed.
[0114] The optimization and modification module 14 is used to find the node corresponding to the second branch instruction from the control flow graph data. If there are at least two second child nodes corresponding to the node of the second branch instruction, an optimization stop flag is added at the branch node corresponding to the second branch instruction in the control flow graph data. The optimization stop flag is used to indicate that in the control flow graph data, the code instructions of the nodes included in the subtree with the branch node as the root node are not detected. If the i-th code instruction indicates that the code instructions in the program source code have not been adjusted completely, based on the optimization stop flag, the (i + 1)-th code instruction is found from the control flow graph data, and the child node of the node corresponding to it in the control flow graph data. The specific implementation manner of the optimization and modification module 14 can be referred to Figure 6 the description of step S203 in the corresponding embodiment, which will not be elaborated here.
[0115] The optimization verification module 15 is used to run the optimization program with the first voice data, and based on the running information generated during the running of the optimization program, detect the effect of the optimization program, and determine the optimization program that passes the detection as the target program corresponding to the voice translation service.
[0116] Among them, the optimization verification module 15 includes:
[0117] The running information determination unit 151 is used to obtain the first running result generated by compiling the program source code, and determine the first running parameters of the program source code based on the execution times and execution times of the code instructions in the program source code; obtain the first voice parameters used when compiling the program source code, and run the optimization program N times with the first voice parameters to obtain the second running result of the optimization program, and determine the second running parameters of the optimization program based on the execution times and execution times of the code instructions in the optimization program; the first running result refers to the source text data translated from the first voice data through the program source code; the second running result refers to the optimized text data translated from the first voice data through the optimization program; N is a positive integer;
[0118] The data verification unit 152 is used to determine that the optimization program passes the detection and determine the optimization program as the target program corresponding to the voice translation service if the second running result is the same as the first running result and the second running parameters are better than the first running parameters.
[0119] The specific implementation manners of the running information determination unit 151 and the data verification unit 152 can be referred to Figure 4 the specific description of step S103 in the corresponding embodiment, which will not be elaborated here.
[0120] The program call module 16 is configured to call the target program corresponding to the voice translation service when the second voice data generated by the first object is collected through the game application, convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application. For the specific implementation manner of the program call module 16, reference can be made to Figure 4 the description of step S104 in the corresponding embodiment, which will not be elaborated here.
[0121] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit that includes the function of the module or unit.
[0122] Furthermore, please refer to Figure 9 , Figure 9 is a schematic structural diagram of a computer device provided by an embodiment of the present application. As Figure 9 shown, the computer device 900 can be the computer device 101 in the corresponding embodiment of the above Figure 1 . The computer device 900 may include: a processor 901, a network interface 904, and a memory 905. In addition, the computer device 900 may further include: a user interface 903 and at least one communication bus 902. Among them, the communication bus 902 is used to implement connection communication between these components. Among them, the user interface 903 may include a display screen (Display) and a keyboard (Keyboard). Optionally, the user interface 903 may further include a standard wired interface and a wireless interface. The network interface 904 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface or a Bluetooth interface). The memory 905 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. Optionally, the memory 905 may further be at least one storage device located far from the aforementioned processor 901. As Figure 9 shown, the memory 905, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.
[0123] In as Figure 9In the computer device 900 shown, the network interface 904 can provide network communication network elements; the user interface 903 is mainly used to provide an interface for users to input; and the processor 901 can be used to call the device control application program stored in the memory 905 to implement:
[0124] Obtain the program source code corresponding to the voice translation service in the game application, compile the program source code using the first voice data, obtain the execution times and execution times of the code instructions in the program source code, and construct the control flow graph data of the program source code based on the execution times and execution times of the code instructions in the program source code.
[0125] According to the call logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data, perform inlining processing and sequential adjustment on the code instructions in the program source code to generate an optimized program.
[0126] Run the optimized program using the first voice data, perform effect detection on the optimized program based on the running information generated during the running of the optimized program, and determine the optimized program that passes the detection as the target program corresponding to the voice translation service;
[0127] When the second voice data generated by the first object is collected through the game application, call the target program corresponding to the voice translation service, convert the second voice data into target text data through the target program, and display the target text data on the interface of the game application.
[0128] It should be understood that the computer device 900 described in the embodiments of the present application can execute the description of the voice translation program optimization method in any of the foregoing Figure 4 and Figure 6 corresponding embodiments, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated.
[0129] The embodiments of the present application also provide a computer-readable storage medium, which stores a computer program, and the computer program is suitable for being loaded and executed by the processor Figure 4 or Figure 6 The methods provided in each step in, for details, reference can be made to the implementation manners provided in each step in this Figure 4 or Figure 6 which will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application. As an example, the computer program can be deployed to be executed on a computer device, or on multiple computer devices located at one place, or on multiple computer devices distributed at multiple places and interconnected through a communication network.
[0130] The computer-readable storage medium may be the device provided in any of the foregoing embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0131] The embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 4 or Figure 6 the methods provided in various alternative manners in. When the computer device can collect the execution times and execution times of the code instructions in the program source code to assist in optimization and re-compilation, for input parameters, optimization is performed in terms of branch prediction, code layout, function inlining, etc., so that the processing performance of the program for word requests of the speech translation service is improved by 20%, the efficiency of the speech translation service is improved, and the costs of service deployment and use are reduced.
[0132] The terms "first", "second", etc. in the description, claims and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment that includes a series of steps or units is not limited to the listed steps or modules, but may optionally further include steps or modules not listed, or may optionally further include other step units inherent to these processes, methods, devices, products or equipment.
[0133] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to their functions in this description. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0134] The methods and related devices provided by the embodiments of this application are described with reference to the method flowcharts and / or structural schematic diagrams provided by the embodiments of this application. Specifically, each process and / or block of the method flowchart and / or structural schematic diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or structural schematic Figure 1 one block or multiple blocks. These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one process or multiple processes and / or structural schematic Figure 1 one block or multiple blocks. These computer program instructions can also be loaded onto a computer or other programmable device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one process or multiple processes and / or structural schematic one block or multiple blocks.
[0135] The steps in the methods of the embodiments of this application can be adjusted, combined, and deleted according to actual needs.
[0136] The modules in the devices of the embodiments of this application can be combined, divided, and deleted according to actual needs.
[0137] The above-disclosed are only the preferred embodiments of this application. Of course, the scope of the rights of this application cannot be limited thereby. Therefore, equivalent changes made according to the claims of this application still fall within the scope covered by this application.
Claims
1. A method for optimizing a speech translation program, characterized in that: The method comprises: Obtaining a program source code corresponding to a voice translation service in a game application, compiling the program source code using the first voice data, obtaining the number of executions and the execution time of code instructions in the program source code, and constructing control flow graph data of the program source code based on the number of executions and the execution time of code instructions in the program source code; According to the calling logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data, inline processing and sequence adjustment are performed on the code instructions in the program source code to generate an optimized program; Running the optimization program using the first voice data, performing effect detection on the optimization program based on the running information generated when the optimization program is running, and determining the optimization program that passes the detection as the target program corresponding to the voice translation service; When the second voice data generated by the first object is collected through the game application, the target program corresponding to the voice translation service is called, the second voice data is converted into target text data through the target program, and the target text data is displayed in the interface of the game application.
2. The method according to claim 1, characterized in that The method of using the first voice data to compile the program source code to obtain the number of executions and execution time of code instructions in the program source code, and constructing control flow graph data of the program source code based on the number of executions and execution time of code instructions in the program source code, includes: Add a detection node to the code instruction in the program source code, generate an insertion code, compile the insertion code N times using the first voice data, obtain the number of executions and execution time of the code instruction in the program source code in the N compilations based on the detection node, perform structural analysis on the program source code, and obtain the calling logic relationship between the code instructions in the program source code; N is a positive integer; Nodes are generated based on the code instructions in the program source code, and the number of executions and execution time of the code instructions in the program source code; directed edges are generated based on the calling logical relationship between the code instructions in the program source code; and the nodes and the directed edges are combined to form control flow graph data of the program source code.
3. The method according to claim 1, characterized in that The step of inlining and sequentially adjusting the code instructions in the program source code according to the calling logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data to generate an optimized program includes: Searching for the i-th code instruction from the control flow graph data, and for the child nodes of the corresponding node in the control flow graph data, if it is found that the node corresponding to the i-th code instruction has at least two first child nodes, then obtaining the execution times respectively included in the at least two first child nodes; the parent-child relationship between the nodes in the control flow graph data is used to represent the calling logic relationship between the code instructions in the program source code; i is a positive integer; Based on the execution times respectively included in the at least two first sub-nodes, the code instructions respectively corresponding to the at least two first sub-nodes in the program source code are sorted to obtain an intermediate program i including a branch instruction sequence; the code instructions respectively corresponding to the at least two first sub-nodes are branch instructions of the i-th code instruction; the branch instruction sequence includes at least two branch instructions; Adjusting the branch instruction sequence in the intermediate program i to obtain an i-th adjustment program corresponding to the program source code; If the i-th code instruction indicates that the adjustment of the code instructions in the program source code is completed, the i-th adjustment program is determined as an optimization program.
4. The method according to claim 3, characterized in that The step of adjusting the branch instruction sequence in the intermediate program i to obtain the i-th adjustment program corresponding to the program source code includes: If the first branch instruction is a function call instruction, then search for the function code indicated by the first branch instruction, add an inline modifier to the function code, and obtain the i-th adjustment program corresponding to the program source code; the inline modifier is used to indicate that the function code is an inline function; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i.
5. The method according to claim 3, characterized in that: The step of adjusting the branch instruction sequence in the intermediate program i to obtain the i-th adjustment program corresponding to the program source code includes: If at least two branch instructions in the branch instruction sequence in the intermediate program i are conditional detection instructions, and the first branch instruction does not include an execution condition, then the first execution condition included in the second branch instruction is obtained, and the second execution condition is determined based on the first execution condition; the first branch instruction is the first branch instruction in the branch instruction sequence in the intermediate program i, and the second branch instruction is the remaining branch instructions in the branch instruction sequence in the intermediate program i except the first branch instruction; The second execution condition is added to the first branch instruction, and the conditional control symbols in the at least two branch instructions are updated to obtain the i-th adjustment program corresponding to the program source code.
6. The method according to claim 3, characterized in that The method further comprises: A node corresponding to a second branch instruction is searched from the control flow graph data, and if the node corresponding to the second branch instruction has at least two second child nodes, an optimization stop mark is added to the branch node corresponding to the second branch instruction in the control flow graph data; the optimization stop mark is used to indicate that in the control flow graph data, code instructions of nodes included in a subtree with the branch node as a root node are not detected; the second branch instruction is the remaining branch instructions in the branch instruction sequence in the intermediate program i except the first branch instruction ranked first; If the i-th code instruction indicates that the code instruction in the program source code has not been adjusted, then based on the optimization stop flag, the i+1-th code instruction is searched from the control flow graph data for a child node of a node corresponding to the control flow graph data.
7. The method according to claim 1, characterized in that The step of running the optimization program using the first voice data, performing effect detection on the optimization program based on the operation information generated when the optimization program is running, and determining the optimization program that passes the detection as the target program corresponding to the voice translation service includes: Obtaining a first running result generated by compiling the program source code, and determining a first running parameter of the program source code based on the number of executions and execution time of code instructions in the program source code; the first running result refers to source text data translated from the first voice data through the program source code; Acquire the first voice data used when compiling the program source code, use the first voice data to run the optimization program N times, obtain a second running result of the optimization program, and determine a second running parameter of the optimization program based on the number of executions and execution time of code instructions in the optimization program; N is a positive integer; the second running result refers to optimized text data translated from the first voice data by the optimization program; If the second operation result is the same as the first operation result, and the second operation parameter is better than the first operation parameter, it is determined that the optimization program has passed the detection, and the optimization program is determined as the target program corresponding to the speech translation service.
8. A speech translation program optimization device, characterized in that: The device comprises: An information acquisition module, used to obtain the program source code corresponding to the voice translation service in the game application; A code compiling module, used to compile the program source code using the first voice data, obtain the number of executions and execution time of the code instructions in the program source code, and construct control flow graph data of the program source code based on the number of executions and execution time of the code instructions in the program source code; A compiling and optimizing module, configured to perform inline processing and sequence adjustment on the code instructions in the program source code according to the calling logic relationship and execution times between the code instructions in the program source code indicated in the control flow graph data, so as to generate an optimized program; A result verification module, configured to run the optimization program using the first voice data, perform effect detection on the optimization program based on the operation information generated when the optimization program is run, and determine the optimization program that passes the detection as the target program corresponding to the voice translation service; A program calling module is used to call a target program corresponding to the speech translation service when the second speech data generated by the first object is collected through the game application, convert the second speech data into target text data through the target program, and display the target text data in the interface of the game application.
9. A computer device, characterized in that: Includes processor, memory, input and output interfaces; The processor is connected to the memory and the input / output interface respectively, wherein the input / output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.