A distributed compilation method, system, electronic device and storage medium

By cooperating with the client and the scheduler to select the best compiler and adjust the number of parallel compilation modules, the problem of being unable to detect the performance of the compilation machine in the existing technology is solved, and the efficiency and stability of distributed compilation are improved.

CN114296930BActive Publication Date: 2024-08-27BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111641625.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2024-08-27
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

Existing distributed compilation methods cannot perform memory and performance testing on compilation machines, and are prone to memory overflows and machines with poor compilation performance slowing down the overall compilation progress.

Method used

The client and scheduler work together to determine whether distributed compilation is needed, select the best current compiler to allocate compilation tasks, adjust the number of parallel compilation modules through the CPU idle rate, and prefetch the compiler to improve compilation efficiency and prevent memory overflow. and low-performance machines slowing down progress.

Benefits of technology

It improves compilation efficiency, avoids the problems of memory overflow and low-performance machines that slow down compilation progress, and achieves more efficient distributed compilation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114296930B
    Figure CN114296930B
Patent Text Reader

Abstract

The embodiment of the present application provides a distributed compilation method, system, electronic device and storage medium, which relates to the field of computer application technology. The method includes a client, which determines whether the received compilation command is distributed compilation; if so, the compilation information of the task to be compiled is sent to the scheduler, and the compiler is obtained from the scheduler to send the task to be compiled to the compiler for compilation; the compilation result returned by the compiler is received; the scheduler, according to the compilation request initiated by the client, selects the current best compiler from the compiler information and returns it to the client, so that the current best compiler executes the task to be compiled, obtains the best compiler for distributed compilation, and solves the problem that the existing method cannot perform memory and performance detection on the compiler machine, and is prone to memory overflow and the machine with poor compilation performance will seriously slow down the overall compilation progress.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to a distributed compilation method, system, electronic device and storage medium. Background Art

[0002] Distributed compilation means sending the source code to be compiled to different machines through the network for separate compilation. After the compilation is completed, it is linked to the local machine, thereby converting the project into a cluster task for processing, solving the problems of limited single-machine compilation performance and slow compilation speed of large projects, and achieving the purpose of improving development efficiency.

[0003] Existing distributed compilation methods, such as using the open source software distcc to implement it, and using dmucs as the load balancing tool of distcc. During compilation, this solution will read the machine IP from the specified file, obtain the load of each machine through dmucs, and adjust the IP order of the machine according to the machine load. During compilation, the compilation command, the file to be compiled, and its dependent libraries and header files are sent to the machine with the first IP order for compilation. After the compilation is completed, they are linked locally. This method cannot perform memory and performance detection on the compilation machine, and is prone to memory overflow. Machines with poor compilation performance will seriously slow down the overall compilation progress. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a distributed compilation method, system, electronic device and storage medium to obtain the best compiler for distributed compilation, so as to solve the problem that the existing method cannot perform memory and performance detection on the compilation machine, and memory overflow is prone to occur. Machines with poor compilation performance will seriously slow down the overall compilation progress.

[0005] The present application provides a distributed compilation method, the method comprising:

[0006] The client determines whether the received compilation command is a distributed compilation;

[0007] If yes, the compilation information of the task to be compiled is sent to the local daemon process;

[0008] The local daemon process parses the compilation information and obtains a compiler from the scheduler to send the task to be compiled to the compiler for compilation;

[0009] Receiving the compilation result returned by the compiler;

[0010] The scheduler selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client and returns it to the client, so that the currently optimal compiler executes the task to be compiled.

[0011] In the above implementation process, compilation tasks that do not require distributed compilation are completed locally, and those that require distributed compilation are sent to the current best compiler for compilation, thereby improving compilation efficiency. The current best compiler can be selected based on the compiler information, which solves the problem that the existing method cannot perform memory and performance detection on the compilation machine, and is prone to memory overflow. The machine with poor compilation performance will seriously slow down the overall compilation progress.

[0012] Furthermore, before the step of determining whether the received compile command is distributed compiled, the method further includes:

[0013] Record the module name of each compilation task execution module and the library name generated by the compilation task execution module when executing the compilation task;

[0014] Generate a module dependency list based on the module name and the library name;

[0015] The module dependency list is traversed and the CPU idle rate is calculated to obtain the number of parallel compilation modules, so as to execute the compilation task using the number of parallel compilation modules.

[0016] In the above implementation process, the maximum number of parallel compilation modules is adjusted according to the CPU idle rate, which can improve the efficiency of local compilation.

[0017] Furthermore, the method further comprises:

[0018] The client redirects the logs generated during the execution of the compilation task.

[0019] In the above implementation process, when multiple compilation tasks are executed in parallel, log redirection can be used for sorting to prevent the logs of each compilation task from being out of order.

[0020] Furthermore, the step of determining whether the received compile command is a distributed compile comprises:

[0021] Determine whether the compilation command contains an option that cannot be compiled in a distributed manner, whether it is a lightweight task, whether it is a fallback task, and whether it can be compiled locally.

[0022] In the above implementation process, whether distributed compilation is required is determined based on whether there is an option that cannot be compiled in a distributed manner, whether it is a lightweight task, whether it is a fallback task, and whether it can be compiled locally.

[0023] Furthermore, before the step of selecting the current best compiler from the compiler information and returning it to the client, the method further includes:

[0024] Receives information about the number of cores, memory, load, and available compilers sent periodically by the remote daemon.

[0025] In the above implementation process, the current best compiler is selected for compilation based on information such as the number of cores, memory, load, and available compilers to prevent memory overflow and the problem that machines with poor compilation performance will seriously slow down the overall compilation progress.

[0026] Furthermore, the method further comprises:

[0027] When the load is low, the scheduler generates a test compilation command according to the compilation machine information sent by the remote daemon process;

[0028] Sending the test compile command to the compiling machine for compiling test;

[0029] The compiling time returned by the compiler is received, and a low-performance machine in the compiler is marked according to the compiling time.

[0030] In the above implementation process, the compiler is tested for compilation, so as to mark low-performance machines to avoid slowing down the compilation efficiency during subsequent use.

[0031] Furthermore, the method further comprises:

[0032] During compilation, the scheduler pre-fetches one or more compiler machines as compilation task quotas according to the compilation task amount;

[0033] When the next compiling task is received, the compiling task quota is allocated to the client.

[0034] In the above implementation process, the compilation efficiency can be improved by pre-fetching the compiler and repeatedly sending compilation information can be avoided.

[0035] The present application also provides a distributed compilation system, the system comprising:

[0036] The client is used to determine whether the received compilation command is a distributed compilation;

[0037] If yes, the compilation information of the task to be compiled is sent to the scheduler, and a compiler is obtained from the scheduler to send the task to be compiled to the compiler for compilation;

[0038] Receiving the compilation result returned by the compiler;

[0039] The scheduler selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client and returns it to the client, so that the currently optimal compiler executes the task to be compiled.

[0040] In the above implementation process, compilation tasks that do not require distributed compilation are completed locally, and those that require distributed compilation are sent to the current best compiler for compilation, thereby improving compilation efficiency. The current best compiler can be selected based on the compiler information, which solves the problem that the existing method cannot perform memory and performance detection on the compilation machine, and is prone to memory overflow. The machine with poor compilation performance will seriously slow down the overall compilation progress.

[0041] An embodiment of the present application further provides an electronic device, the electronic device comprising a memory and a processor, the memory being used to store a computer program, and the processor running the computer program so that the electronic device executes any one of the above-mentioned distributed compilation methods.

[0042] An embodiment of the present application further provides a readable storage medium, wherein the readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, any of the above-mentioned distributed compilation methods is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 A flowchart of a distributed compilation method provided in an embodiment of the present application;

[0045] Figure 2 A distributed compilation execution flow chart provided in an embodiment of the present application;

[0046] Figure 3 A parallel construction flow chart provided for an embodiment of the present application;

[0047] Figure 4 A distributed compilation performance diagnosis flow chart provided in an embodiment of the present application;

[0048] Figure 5 A compilation pre-fetching flow chart provided for an embodiment of the present application;

[0049] Figure 6 A structural block diagram of a distributed compilation system provided in an embodiment of the present application;

[0050] Figure 7 This is a structural block diagram of another distributed compilation system provided in an embodiment of the present application.

[0051] icon:

[0052] 100-client; 101-parallel construction module; 102-log sorting module; 103-distributed compilation judgment module; 200-scheduler; 201-distributed compilation performance diagnosis module; 202-compiler selection module; 203-prefetch module; 300-local daemon; 400-remote daemon; 401-heartbeat module. DETAILED DESCRIPTION

[0053] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0054] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0055] Please see Figure 1 , Figure 1 A flowchart of a distributed compilation method provided in an embodiment of the present application. Distributed compilation is achieved through the coordination of a local compiler and a remote compiler to improve compilation efficiency, specifically including the following steps:

[0056] Step S100: The client 100 determines whether the received compile command is a distributed compile command;

[0057] Step S200: If yes, the compilation information of the task to be compiled is sent to the local daemon process;

[0058] like Figure 2 As shown, it is a distributed compilation execution flow chart. When performing distributed compilation, the client 100 passes the compiler hash value of the task to be compiled and the temporary file name to be compiled to the local daemon process, and the local daemon process communicates with the scheduler 200 / compiler.

[0059] Step S300: the local daemon process parses the compilation information and obtains a compiler from the scheduler 200 to send the task to be compiled to the compiler for compilation, and receives the compilation result returned by the compiler;

[0060] The local daemon receives and parses the compilation information sent by the client 100, communicates with the scheduler 200, obtains an available compiler, and then sends the compilation task to the designated compiler for compilation. The transmission process uses zero-copy technology to reduce file copy overhead.

[0061] The client 100 receives the compilation result sent back by the compiler, obtains the compilation result and decides whether to redistribute the compilation command (the compilation command needs to be redistributed when the compilation fails) or wait for all target files to be sent back before executing the link.

[0062] Step S400: the scheduler 200 selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client 100 and returns it to the client 100, so that the currently optimal compiler executes the task to be compiled.

[0063] like Figure 3 As shown in the flowchart of parallel construction, before step S100, the method further includes:

[0064] Step S111: recording the module name of each compilation task execution module and the library name generated by the compilation task execution module when executing the compilation task;

[0065] Step S112: Generate a module dependency list based on the module name and the library name;

[0066] Step S113: traverse the module dependency list and calculate the CPU idle rate to obtain the number of parallel compilation modules, so as to use the number of parallel compilation modules to execute the compilation task.

[0067] The generation of the module dependency list depends on a non-parallel build, and is supplemented and improved in the parallel build: the module name of each compilation task execution module and the library name of the dynamic / static library generated when each compilation task execution module executes the link are recorded. Other compilation task execution modules that are linked to the dynamic / static library during the compilation phase will also be written into the module dependency list. The module dependency list after the compilation is completed (updated) is stored in the specified svn path so that the module dependency list can be obtained from the path during parallel builds.

[0068] When building a parallel compilation module, you need to calculate the CPU idle rate to obtain the number of modules that can be compiled locally in parallel. At the same time, traverse the module dependency list to find all modules that meet the execution conditions, so as to take as many modules as possible as parallel compilation modules within the module number range.

[0069] In addition, each time the parallel compilation module is built, the CPU idle rate is recalculated, and the maximum number of modules that can be compiled in parallel next time is adjusted based on the CPU idle rate.

[0070] The purpose of building a parallel compilation module is to use multiple parallel compilation modules for compilation to improve compilation efficiency; during the compilation process, the number of parallel compilation modules is adjusted in real time to regulate the load, and the number of local build commands that can be executed simultaneously is increased to improve the overall compilation speed.

[0071] The client 100 redirects the logs generated during the execution of the compilation task to prevent the parallel compilation logs from being confused and causing positioning difficulties. The redirection process runs through the entire execution of the compilation task.

[0072] When make is building, the log is written to the log file. When creating a child make process, the output is redirected to a temporary file. The file name is obtained by hashing the process id and the process start time. Before the child make exits, the temporary file is appended to the log file corresponding to the parent process, thereby preventing the occurrence of disorder to a certain extent. Among them, make is a program used to perform parallel builds. When using make to build multiple targets in parallel, multiple child processes will be created, and each child process executes a target to be built (using multiple makes to perform parallel builds at the same time).

[0073] The judgment of distributed compilation in step S100, specifically, when the compilation command is transmitted to the client 100, it will first be judged whether distributed compilation is performed on the compilation command. The judgment is based on four factors: whether the compilation command contains options that cannot be distributed compiled, whether it is a lightweight task, whether it is a fallback task, and whether the local can withstand the compilation.

[0074] Among them, a lightweight task is a task that occupies less memory and can be compiled by a local compiler. Whether it is lightweight can be determined based on the nature of the task (pre-compilation, etc.) and the compilation record.

[0075] Rollback task. When a remote compiler compiles a compilation task, if the compilation execution time is too long or multiple compilation executions fail, the compilation command and source file hash value corresponding to the compilation task will be sent to the client 100. The task that needs to be compiled again on the client 100 is the rollback task. Whether it is a rollback task can be determined based on the compilation record.

[0076] When compiling locally, it is necessary to detect the number of cores and load of the client 100. If the load of the client 100 does not exceed the given value, it means that the client 100 can withstand the compilation and distributed compilation will not be performed.

[0077] The client 100 first calls the local compiler to preprocess the source file (a lightweight task) and outputs a temporary file (for remote compilation) with a specified file name to avoid directly exposing the preprocessed code to other compilers in the cluster. After the compilation is completed, the temporary file is deleted to improve the security of the compilation. After the preprocessing is completed, the temporary file descriptor is passed to the local daemon process.

[0078] After startup, the remote daemon establishes a connection with the scheduler 200, maintains the connection by means of a timed heartbeat, and sends compiler information such as the number of available cores, memory, load, and availability of the compiler where the remote daemon is located to the scheduler 200.

[0079] After receiving the compilation request initiated by the client 100 , the scheduler 200 selects the currently available best compiler from the compiler information uploaded by the remote daemon process and returns it to the client 100 .

[0080] like Figure 4 As shown, it is a distributed compilation performance diagnosis flow chart, and the method also includes distributed compilation performance diagnosis:

[0081] Step S411: when the load is low, the scheduler 200 generates a test compilation command according to the compilation machine information sent by the remote daemon process;

[0082] Step S412: Send the test compilation command to the compiler to perform compilation test;

[0083] Step S413: receiving the compilation time returned by the compiler, and marking the low-performance machine in the compiler according to the compilation time.

[0084] When a compiler joins a cluster and after each compilation occurs, the scheduler 200 performs a distributed compilation performance diagnosis when the load on each machine is low, generates corresponding compilation commands based on the compiler information reported by the remote daemon, and distributes the compilation test files to the machine containing the specified compiler for compilation testing. The compiler sends the compilation time back to the scheduler 200. The scheduler 200 marks the machine whose compilation time exceeds the minimum value by 30% as a low-performance machine. The low-performance machine only participates in compilation when the resources of other machines are exhausted.

[0085] like Figure 5 As shown, it is a compilation pre-fetching flow chart, and the method also includes compilation pre-fetching:

[0086] Step S421: During compilation, the scheduler 200 pre-fetches one or more compilation machines as compilation task quotas according to the compilation task amount;

[0087] Step S422: when receiving the next compilation task, allocating the compilation task quota to the client 100 .

[0088] When compilation occurs, the scheduler 200 will pre-fetch the quota of one or more compilation tasks locally according to the task volume, and when the next compilation task comes, the quota can be directly allocated to the client 100.

[0089] When the scheduler 200 cannot pre-fetch the compiler machine, it means that the machines that meet the compilation environment in the network segment have been used up. In this case, the next time, pre-fetch will be performed from the machines with different compilation environments in the compilation cluster. After the pre-fetch is completed, the compiler machine information is returned and a flag is set to notify the client 100 to additionally package the local compiler and the dependent libraries and header file information required to execute the compilation when sending the compilation task.

[0090] By pre-compiling, the compilation resources are unitized, resources are pre-fetched for compilation tasks, query delays are reduced, and repeated sending of compilation information is avoided.

[0091] For example, based on the compilation process of this method, the overall packaging speed is improved by distributing the code to be compiled from the packaging server to each compiler for compilation. Specifically:

[0092] Step S11: a virtual machine that executes the scheduling process is used as the scheduler 200, and the daemon process is executed on the other two virtual machines and the packaging server and used as the compiler. The machines used are all equipped with 4-core CPUs and 8G memory, and the compiler is pre-installed with the compilation-related tool chain;

[0093] Step S12: The client 100 / compiler and the scheduler 200 perform heartbeats regularly to maintain the connection and report available compilers, memory, number of cores, and load information;

[0094] Step S13: The packaging server (client 100) copies the code from SVN and executes the packaging process;

[0095] Step S14: the packaging server starts to execute compilation as the client 100, determines the number of parallel modules according to the CPU idle time, determines the actual parallel compilation modules according to the module dependency list, and starts to execute the build;

[0096] Step S15: Before compiling, check whether the compilation task meets the conditions for distributed compilation. If the conditions are not met, perform local compilation. During the compilation process, write the compilation task information and status into the log;

[0097] Step S16: As the compilation proceeds, the module concurrency increases, and the number of CPU resources used locally exceeds the limit, the scheduler 200 is requested to allocate the task to a suitable compiler machine for distributed compilation in a zero-copy manner;

[0098] Step S17: During the compilation process, lightweight tasks and compiled rollback tasks are written into the compilation record file, and the module dependency list is improved;

[0099] Step S18: After the compiler completes the compilation, the target file and the compilation record file are transmitted back to the packaging server;

[0100] Step S19: The packaging server executes the link locally to generate a library file or an executable file.

[0101] This method detects the memory of the compiler machine and reduces the occurrence of memory overflow caused by starting tasks when the memory is insufficient. It implements build-level load regulation by adjusting the number of modules compiled in parallel in real time, increases the number of local build commands that can be executed simultaneously, and improves the overall compilation speed. It fully utilizes the machine resources in the compilation cluster by packaging the compilation environment. It increases the security of compilation by creating preprocessing temporary files. It alleviates the problem of difficulty in locating errors when distributed parallel compilation occurs by log sorting.

[0102] The present application also provides a distributed compilation system. Figure 6 FIG. 1 is a block diagram of a distributed compilation system, wherein the system includes:

[0103] The client 100 is used to determine whether the received compile command is a distributed compile;

[0104] If yes, the compilation information of the task to be compiled is sent to the local daemon process;

[0105] The local daemon process 300 is used to parse the compilation information and obtain a compiler from the scheduler 200 to send the task to be compiled to the compiler for compilation;

[0106] Receiving the compilation result returned by the compiler;

[0107] The scheduler 200 selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client 100 and returns it to the client 100, so that the currently optimal compiler executes the task to be compiled.

[0108] Compilation tasks that do not require distributed compilation are completed locally. For those that require distributed compilation, they are sent to the current best compiler for compilation, thereby improving compilation efficiency. The current best compiler can be selected based on the compiler information, which solves the problem that existing methods cannot perform memory and performance detection on the compiler machine, and memory overflow is prone to occur. Machines with poor compilation performance will seriously slow down the overall compilation progress.

[0109] like Figure 7 , which is a structural block diagram of another distributed compilation system, the client 100 further includes a parallel construction module 101 , a log sorting module 102 , and a distributed compilation judgment module 103 .

[0110] A parallel construction module 101 is used to record the module name of each compilation task execution module and the library name generated by the compilation task execution module when executing the compilation task;

[0111] Generate a module dependency list based on the module name and the library name;

[0112] The module dependency list is traversed and the CPU idle rate is calculated to obtain the number of parallel compilation modules, so as to execute the compilation task using the number of parallel compilation modules.

[0113] The log sorting module 102 is used to redirect the logs generated during the execution of the compilation task.

[0114] The distributed compilation judgment module 103 is used to judge whether the compilation command contains an option that cannot be compiled in a distributed manner, whether it is a lightweight task, whether it is a fallback task, and whether it can be compiled locally.

[0115] The remote daemon process 400 includes a heartbeat module 401 for maintaining a connection based on a timed heartbeat and sending the number of available cores, memory, load, and available compilers of the machine where the remote daemon process 400 is located to the scheduler 200 .

[0116] The scheduler 200 includes a distributed compilation performance diagnosis module 201 , a compiler selection module 202 , and a pre-fetch module 203 .

[0117] The distributed compilation performance diagnosis module 201 is used for generating a test compilation command according to the compilation machine information sent by the remote daemon process when the load is low.

[0118] Sending the test compile command to the compiling machine for compiling test;

[0119] The compiling time returned by the compiler is received, and a low-performance machine in the compiler is marked according to the compiling time.

[0120] A pre-fetching module 203, used for, during compilation, the scheduler 200 pre-fetches one or more compilers as a compilation task quota according to the compilation task amount;

[0121] When the next compiling task is received, the compiling task quota is allocated to the client 100 .

[0122] The compiler selection module 202 is used to select the currently available best compiler from the compiler information uploaded by the remote daemon process and return it to the client 100 after receiving the compilation request initiated by the client 100 .

[0123] The system includes a machine that initiates compilation (client 100), multiple machines that execute compilation tasks (compilation machines), and a machine that distributes compilation tasks (scheduler 200).

[0124] The client 100 is responsible for building each compilation module in parallel and redirecting the logs output during the construction process; querying the scheduler 200 according to the compilation command in the module, distributing the compilation task to the compiler returned by the scheduler 200, receiving the target file returned by the compiler, and executing the link locally to generate a library file or an executable file.

[0125] The compiler is responsible for executing the compilation task issued by the client 100 and transmitting the compilation result back to the client 100 through the network.

[0126] The scheduler 200 is responsible for querying the compilation environment and available resources of each machine, including but not limited to the compiler existing on the machine, the number of cores of the machine, the remaining memory, and the load status, and returns the currently available machine with the most remaining resources to the client 100.

[0127] In this method, the client 100 and the compiler need to run daemon processes, which include a local daemon process and a remote daemon process, which are started at the same time and occupy different ports.

[0128] The local daemon process is mainly responsible for receiving the compilation information transmitted by the client 100, initiating a compilation request to the scheduler 200, distributing compilation tasks to the compiler, and receiving the compilation results returned by the compiler.

[0129] The remote daemon process is mainly responsible for initiating a timed heartbeat to the scheduler 200, uploading machine-related status information, receiving compilation tasks distributed by the client 100 daemon process, and returning compilation results to the compiler.

[0130] An embodiment of the present application further provides an electronic device, the electronic device comprising a memory and a processor, the memory being used to store a computer program, and the processor running the computer program so that the electronic device executes any one of the above-mentioned distributed compilation methods.

[0131] An embodiment of the present application further provides a readable storage medium, wherein the readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, any of the above-mentioned distributed compilation methods is executed.

[0132] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0133] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0134] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0135] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0136] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0137] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A distributed compilation method, characterized in that: The method comprises: The client determines whether the received compilation command is a distributed compilation; If yes, the compilation information of the task to be compiled is sent to the scheduler, and a compiler is obtained from the scheduler to send the task to be compiled to the compiler for compilation; Receiving the compilation result returned by the compiler; The scheduler selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client and returns it to the client, so that the currently optimal compiler executes the task to be compiled; The method further comprises: When a compiler joins the cluster and after each compilation occurs, when the load is low, the scheduler generates a test compilation command based on the compiler information sent by the remote daemon process; Sending the test compilation command to a designated compiler machine for compilation testing; The compilation time returned by the designated compiler is received, and a low-performance machine in the designated compiler is marked according to the compilation time; the low-performance machine participates in the compilation only when resources of other machines are exhausted.

2. The distributed compilation method according to claim 1, characterized in that: Before the step of determining whether the received compile command is distributed compiled, the method further includes: Record the module name of each compilation task execution module and the library name generated by the compilation task execution module when executing the compilation task; Generate a module dependency list based on the module name and the library name; The module dependency list is traversed and the CPU idle rate is calculated to obtain the number of parallel compilation modules, so as to execute the compilation task using the number of parallel compilation modules.

3. The distributed compilation method according to claim 1, characterized in that: The method further comprises: The client redirects the logs generated during the execution of the compilation task.

4. The distributed compilation method according to claim 1, characterized in that: The step of determining whether the received compile command is a distributed compile comprises: Determine whether the compilation command contains an option that cannot be compiled in a distributed manner, whether it is a lightweight task, whether it is a fallback task, and whether it can be compiled locally.

5. The distributed compilation method according to claim 1, characterized in that: Before the step of selecting the current best compiler from the compiler information and returning it to the client, the method further includes: The scheduler receives information about the number of cores, memory, load, and available compilers sent periodically by the remote daemon.

6. The distributed compilation method according to claim 1, characterized in that: The method further comprises: During compilation, the scheduler pre-fetches one or more compiler machines as compilation task quotas according to the compilation task amount; When the next compiling task is received, the compiling task quota is allocated to the client.

7. A distributed compilation system, characterized in that: The system comprises: The client is used to determine whether the received compilation command is a distributed compilation; If yes, the compilation information of the task to be compiled is sent to the scheduler, and a compiler is obtained from the scheduler to send the task to be compiled to the compiler for compilation; Receiving the compilation result returned by the compiler; The scheduler selects a currently optimal compiler from the compiler information according to the received compilation request initiated by the client and returns it to the client, so that the currently optimal compiler executes the task to be compiled; The scheduler includes a distributed compilation performance diagnosis module; The distributed compilation performance diagnosis module is used to generate a test compilation command according to the compilation machine information sent by the remote daemon process when the compilation machine joins the cluster and after each compilation occurs when the load is low; Sending the test compilation command to a designated compiler machine for compilation testing; The compilation time returned by the designated compiler is received, and a low-performance machine in the designated compiler is marked according to the compilation time; the low-performance machine participates in the compilation only when resources of other machines are exhausted.

8. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the distributed compilation method according to any one of claims 1 to 6.

9. A readable storage medium, characterized in that: The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the distributed compilation method according to any one of claims 1 to 6 is executed.