Distributed compilation method, device, computer program product, equipment and medium
By storing and retrieving compilation results in the shared directory of the shared server, the problem of repeated compilation between compilation devices is solved and compilation efficiency is improved.
Patent Information
- Application Number
- CN202410853485.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-06-28
Smart Images

Figure CN118409757B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software technology, and more specifically, to a distributed compilation method, device, computer program product, electronic device and computer-readable storage medium. Background Art
[0002] In the process of compiling software, multiple compiling devices can be used to compile the software. For example, the compiling task can be distributed to multiple computers for parallel execution to speed up the overall compiling process. However, multiple compiling devices may process repeated compiling tasks, resulting in reduced compiling efficiency.
[0003] In summary, how to improve compilation efficiency is a problem that currently needs to be solved urgently by those skilled in the art. Summary of the invention
[0004] The purpose of the present invention is to provide a distributed compilation method, which can solve the technical problem of how to improve compilation efficiency to a certain extent. The present invention also provides a distributed compilation device, a computer program product, an electronic device and a computer readable storage medium.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, a distributed compilation method is provided, which is applied to a compilation device, comprising:
[0007] Get the compilation task;
[0008] Generate description information of the compilation task;
[0009] Determine that a shared server is mounted on a shared directory of the compilation device;
[0010] Detecting whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information;
[0011] If it is detected based on the description information that the compilation result exists in the shared directory, reading the compilation result from the shared directory for processing;
[0012] Among them, a target number of the compilation devices all mount the shared directory, and the target number is greater than or equal to 2.
[0013] On the other hand, after detecting whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information, the method further includes:
[0014] If it is detected based on the description information that the compilation result does not exist in the shared directory, executing the compilation task to obtain the compilation result;
[0015] The description information and the compilation result are stored in the shared directory.
[0016] On the other hand, storing the description information and the compilation result in the shared directory includes:
[0017] Locking the shared directory;
[0018] Storing the description information and the compilation result in the shared directory;
[0019] Unlock the shared directory.
[0020] On the other hand, locking the shared directory includes:
[0021] Generate a first locking node based on the current moment;
[0022] Sending the first locking node to the shared server, so that the shared server determines whether to respond to the first locking node based on the lock request pool;
[0023] If the shared server sends a response message in response to the first locking node, the shared directory is locked;
[0024] The lock request pool is used to store the lock nodes generated by each of the compilation devices and corresponding to the shared directory.
[0025] On the other hand, determining that the shared server is mounted on the shared directory of the compilation device includes:
[0026] Determining a compiler cache of the compiling device;
[0027] The shared directory mounted by the shared server is determined in the compiler cache.
[0028] On the other hand, before getting the compilation task, it also includes:
[0029] The cache directory of the compiler cache is set to the local directory where the shared directory is mounted.
[0030] On the other hand, get the compilation tasks, including:
[0031] Detecting whether the compiling device is a central scheduler;
[0032] If the compilation device is the central scheduler, obtaining a total task, distributing the total task, and obtaining the compilation task;
[0033] If the compiling device is not the central scheduler, receiving the compiling task distributed by the central scheduler;
[0034] The central scheduler includes a device selected from the target number of compiling devices by the distributed compiler.
[0035] On the other hand, generating description information of the compilation task includes:
[0036] Obtaining source file information of the compilation task;
[0037] Obtaining compilation parameters of the compilation task;
[0038] Generate a cache key for the compilation task based on the source file information and the compilation parameters;
[0039] The cache key is used as the description information.
[0040] On the other hand, generating a cache key of the compilation task based on the source file information and the compilation parameters includes:
[0041] Generate a hash value of the source file information;
[0042] A cache key for the compilation task is generated based on the hash value and the compilation parameter.
[0043] In a second aspect, a distributed compilation apparatus is provided, comprising a shared server, and a target number of compilation devices connected to the shared server, the target number being greater than or equal to 2, and the target number of compilation devices all mounting a shared directory of the shared server;
[0044] The compilation device is used to obtain a compilation task; generate description information of the compilation task; detect whether there is a compilation result corresponding to the compilation task in a shared directory based on the description information; if the compilation result is detected to exist in the shared directory based on the description information, read the compilation result from the shared directory for processing.
[0045] On the other hand, the compiling device is configured with a distributed compiler and a compiler cache.
[0046] On the other hand, the shared server is used for:
[0047] Identify shared files;
[0048] Obtaining compiler cache information of the compiling device;
[0049] Adding the compiler cache information to the shared file;
[0050] The read and write permission information of the compiling device is added to the shared file, wherein the read and write permission information includes the read and write permission of the compiling device to the shared directory.
[0051] According to a third aspect, a computer program product is provided, comprising a computer program / instruction, which, when executed by a processor, implements the steps of any of the above-described distributed compilation methods.
[0052] In a fourth aspect, an electronic device is provided, including:
[0053] Memory for storing computer programs;
[0054] A processor is used to implement the steps of any of the above-mentioned distributed compilation methods when executing the computer program.
[0055] According to a fifth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of any of the above-described distributed compilation methods are implemented.
[0056] A distributed compilation method provided by the present invention is applied to a compilation device, obtains a compilation task; generates description information of the compilation task; determines that a shared server is mounted on a shared directory of the compilation device; detects whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if the compilation result is detected in the shared directory based on the description information, the compilation result is read from the shared directory for processing; wherein a target number of compilation devices are mounted with a shared directory, and the target number is greater than or equal to 2. The beneficial effect of the present invention is that each compilation device mounts a shared directory of a shared server, and when processing a compilation task, each compilation device searches the shared directory according to the description information of the compilation task, and if there is a compilation result corresponding to the compilation task in the shared directory, the compilation result is read from the shared directory for processing, so that as long as there is a compilation result in the shared directory, each compilation device can directly obtain the compilation result for processing without having to compile the compilation task to obtain the compilation result, thereby reducing the repeated compilation process of the compilation task and improving the compilation efficiency. A compilation device, a computer program product, an electronic device and a computer-readable storage medium provided by the present invention also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0058] Figure 1 A flowchart of a distributed compilation method provided by an embodiment of the present invention;
[0059] Figure 2A schematic diagram of the structure of a distributed compilation device provided by an embodiment of the present invention;
[0060] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0061] Figure 4 Another structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] See also Figure 1 , Figure 1 A flowchart of a distributed compilation method provided by an embodiment of the present invention.
[0064] A distributed compilation method provided by an embodiment of the present invention is applied to a compilation device and may include the following steps:
[0065] Step S101: Obtain a compilation task.
[0066] In actual applications, the compiling device may first obtain a compiling task, which may be a task for compiling a target function of the software, such as a task for compiling a function for scanning a server, or a task for compiling a function for repairing a server failure, etc. In addition, the type of the compiling device may be flexibly determined according to the application scenario, such as a client, etc.
[0067] Step S102: Generate description information of the compilation task.
[0068] Step S103: Determine that a shared server is mounted on a shared directory of a compilation device; a target number of compilation devices are mounted on the shared directory, and the target number is greater than or equal to 2.
[0069] Step S104: Detecting whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information.
[0070] Step S105: If it is detected based on the description information that there is a compilation result in the shared directory, the compilation result is read from the shared directory for processing.
[0071] In actual applications, the compilation device of the present invention is mounted on a shared directory of a shared server, and the shared directory is used to store compilation results, and all compilation devices in distributed compilation mount this shared directory. In this way, as long as the compilation result corresponding to the compilation task is stored in the shared directory, the compilation device can read the corresponding compilation result from the shared directory for processing, without repeatedly executing the process of compiling according to the compilation task to obtain the compilation result. In this process, in order to accurately detect whether there is a compilation result required by the compilation device in the shared directory, the compilation device can generate description information of the compilation task to reflect the characteristics of the compilation task with the help of the description information, and the type can be determined according to the application scenario. Then, it is determined that the shared server is mounted on the shared directory of the compilation device, and finally, based on the description information, it is detected whether there is a compilation result corresponding to the compilation task in the shared directory. If it is detected that there is a compilation result in the shared directory based on the description information, the compilation result is read from the shared directory for processing.
[0072] It should be noted that the number and type of compilation results recorded in the shared directory can be determined according to actual needs, and the number of shared directories can also be determined according to actual needs. For example, a single software can correspond to a single shared directory.
[0073] In actual applications, after the compilation device detects whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information, if it is detected based on the description information that there is no compilation result in the shared directory, the compilation task is executed to obtain the compilation result; the description information and the compilation result are stored in the shared directory, for example, the description information and the compilation result are stored in the shared directory in the form of a key-value pair.
[0074] From this process, it can be seen that after the compilation device detects that there is no compilation result in the shared directory based on the description information, it will execute the compilation task to obtain the compilation result, and store the description information and the compilation result in the shared directory. In this way, when other compilation devices process the compilation task, they can directly read the compilation result from the shared directory for application, saving the operation of other compilation devices executing the compilation task to obtain the compilation result, which can further ensure the compilation efficiency.
[0075] In a specific application scenario, when the compiler device stores the description information and compilation results in a shared directory, multiple compiler devices can operate on the shared directory. In this way, multiple compiler devices may operate on the shared directory at the same time, resulting in data errors in the shared directory. To avoid this situation, the compiler device can lock the shared directory, store the description information and compilation results in the shared directory, and then unlock the shared directory. The locking and unlocking mechanism can ensure that only a single compiler device can operate on the shared directory at the same time, ensuring the data stability of the shared directory.
[0076] In a specific application scenario, during the process of locking a shared directory, the compilation device can generate a first locking node based on the current moment; send the first locking node to the shared server so that the shared server determines whether to respond to the first locking node based on the lock request pool; if the shared server sends a response message in response to the first locking node, the shared directory is locked; wherein the lock request pool is used to store the locking nodes corresponding to the shared directory generated by each compilation device. In this way, the locking nodes of each shared directory are stored in the lock request pool corresponding to the shared directory, and each locking node is generated based on the current moment, so that each locking node will carry time information, and the shared server can know the locking requirement moment of each compilation device according to the time information written by the locking node, and then decide whether to respond to the locking node according to the locking requirement moment to decide whether to grant locking authority to the compilation device. It should be noted that in this process, if the compilation device does not need to lock after sending the locking node, it can request the shared server to delete the locking node to exit the locking allocation process.
[0077] In actual applications, when determining that a shared server is mounted on a shared directory of the compiling device, the compiling device can first determine the compiler cache of the compiling device; and determine the shared directory mounted on the shared server in the compiler cache. In other words, a compiler cache (ccache) is deployed in the compiling device, and the shared directory of the shared server is mounted in this compiler cache. In this way, the compiling device can quickly interact with the shared directory through the compiler cache, which can improve the compilation efficiency from the perspective of improving the efficiency of data interaction.
[0078] In a specific application scenario, in order to facilitate mounting a shared directory, the compilation device may also set the cache directory of the compiler cache to a local directory that mounts the shared directory before obtaining the compilation task.
[0079] In a specific application scenario, when the compiler device sets the cache directory of the compiler cache as the local directory for mounting the shared directory, the compiler device can parse the operating system type of the compiler device. If the operating system of the compiler device is a Linux system, the tmpfs directory can be used as the cache directory of the compiler cache. In this way, when the compiler device is a Linux system device, the tmpfs directory can be used as the cache directory of the compiler cache. Since the cache directory is used to mount the shared directory, the compiler device is equivalent to using the tmpfs directory to mount the shared directory. In this way, the compiler device can quickly access the shared directory and can automatically allocate and release memory, thereby improving the data access efficiency and memory management capabilities of the compiler device.
[0080] In a specific application scenario, during the distributed compilation process, the compilation device can be configured with a distributed compiler (distcc) to globally schedule the compilation tasks in the distributed compilation process with the help of the distributed compiler. Therefore, in the process of obtaining the compilation task, the compilation device can detect whether the compilation device is a central scheduler. If the compilation device is a central scheduler, the total task is obtained, which is also the total compilation task. The total task is distributed to obtain the compilation task. If the compilation device is not a central scheduler, the compilation task distributed by the central scheduler is received. Among them, the central scheduler includes the device selected from the target number of compilation devices according to the distributed compiler.
[0081] From this process, it can be seen that the compilation device of the present invention is configured with a distributed compiler, and according to the distributed compiler, a central scheduler will be selected in the compilation device to schedule the compilation tasks. In this way, when the compilation device is a central scheduler, the total task can be distributed so that each compilation device obtains the compilation task to be processed. When the compilation device is not a central scheduler, it can directly receive the compilation task distributed by the central scheduler to obtain the compilation task to be processed by itself, so that the compilation tasks can be systematically distributed to multiple compilation devices for parallel execution, thereby accelerating the overall compilation process.
[0082] It should be noted that, according to the principle of the distributed compiler, the compiled and unmodified files can be cached after being compiled and can be reused in the entire compilation process of the project. Based on the idea of caching, the distributed compiler will maintain a local cache for each compilation device during the distributed compilation process. When a certain compilation device completes the compilation of a certain source file for the first time, the distributed compiler can calculate the hash value of the source file and store the compilation result and the hash value in the local cache. In the subsequent construction process, if it is found that the same source file needs to be compiled on the same compilation device, the distributed compiler will first check the local cache. If there is a cache with a hash value match, the compilation result in the cache is directly used without actual compilation. That is, the distributed compiler can ensure that a single compilation device will not repeat the same compilation task, and the distributed compilation method of the present invention can ensure that multiple compilation devices will not repeat the same compilation task. After the combination of the two, it can be ensured that a single compilation device will not repeat the same compilation task, and it can be ensured that multiple compilation devices will not repeat the same compilation task, and the compilation effect is better.
[0083] In actual applications, in the process of generating the description information of the compilation task, the source file information of the compilation task can be obtained; the compilation parameters of the compilation task can be obtained; a cache key of the compilation task can be generated based on the source file information and the compilation parameters; and the cache key can be used as the description information. Specifically, in the process of generating the cache key of the compilation task based on the source file information and the compilation parameters, a hash value of the source file information can be generated; and a cache key of the compilation task can be generated based on the hash value and the compilation parameters.
[0084] From this process, it can be seen that when the compilation device generates the description information of the compilation task, it will obtain the source file information of the compilation task and generate a hash value of the source file information. It uses the hash value to express the source file information and avoid leakage of the source file information. After that, it obtains the compilation parameters of the compilation task and generates a cache key for the compilation task based on the hash value and the compilation parameters, so that the cache key carries the source file information and compilation parameters. Finally, if the cache key is used as the description information, it is equivalent to using the source file information and compilation parameters of the compilation task as the description information, which can ensure the validity and accuracy of the description information.
[0085] A distributed compilation method provided by the present invention is applied to a compilation device, and is used to obtain a compilation task; generate description information of the compilation task; determine that a shared server is mounted on a shared directory of the compilation device; detect whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if it is detected that there is a compilation result in the shared directory based on the description information, then read the compilation result from the shared directory for processing; wherein a target number of compilation devices are mounted with a shared directory, and the target number is greater than or equal to 2. The beneficial effect of the present invention is that each compilation device is mounted with a shared directory of a shared server, and when processing a compilation task, each compilation device searches the shared directory according to the description information of the compilation task, and if there is a compilation result corresponding to the compilation task in the shared directory, then read the compilation result from the shared directory for processing, so that as long as there is a compilation result in the shared directory, each compilation device can directly obtain the compilation result for processing without having to compile the compilation task to obtain the compilation result, thereby reducing the repeated compilation process of the compilation task and improving the compilation efficiency.
[0086] See also Figure 2 , Figure 2 A schematic diagram of the structure of a distributed compilation device provided by an embodiment of the present invention.
[0087] A distributed compiling device provided by an embodiment of the present invention includes a shared server, a target number of compiling devices connected to the shared server, the target number is greater than or equal to 2, and the target number of compiling devices all mount a shared directory of the shared server;
[0088] The compilation device is used to obtain a compilation task; generate description information of the compilation task; detect whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if the compilation result is detected to exist in the shared directory based on the description information, read the compilation result from the shared directory for processing.
[0089] The present invention provides a distributed compilation device, comprising a shared server, a target number of compilation devices connected to the shared server, the target number being greater than or equal to 2, and the target number of compilation devices all mounting a shared directory of the shared server; the compilation device is used to obtain a compilation task; generate description information of the compilation task; detect whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if the compilation result is detected to exist in the shared directory based on the description information, then read the compilation result from the shared directory for processing. The beneficial effect of the present invention is that each compilation device mounts the shared directory of the shared server, and when processing a compilation task, each compilation device searches the shared directory according to the description information of the compilation task, and if there is a compilation result corresponding to the compilation task in the shared directory, then read the compilation result from the shared directory for processing, so that as long as there is a compilation result in the shared directory, each compilation device can directly obtain the compilation result for processing without having to compile the compilation task to obtain the compilation result, thereby reducing the repeated compilation process of the compilation task and improving the compilation efficiency.
[0090] In practical applications, the compilation device can be configured with a distributed compiler and a compiler cache.
[0091] In actual applications, the shared server can be used to: determine shared files; obtain compiler cache information of the compilation device; add compiler cache information to the shared file; add read and write permission information of the compilation device to the shared file, and the read and write permission information includes the read and write permissions of the compilation device to the shared directory, so that all compilation devices can access the shared directory and can read and write data in the shared directory.
[0092] It should be noted that the type of the shared server may be determined according to the application scenario. For example, the shared server may be a Network File System (NFS) server.
[0093] A computer program product provided by an embodiment of the present invention includes a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented:
[0094] Get the compilation task;
[0095] Generate description information of the compilation task;
[0096] Make sure that the shared server is mounted on the shared directory of the compilation device; the target number of compilation devices are all mounted on the shared directory, and the target number is greater than or equal to 2;
[0097] Based on the description information, detect whether there is a compilation result corresponding to the compilation task in the shared directory;
[0098] If it is detected based on the description information that there is a compilation result in the shared directory, the compilation result is read from the shared directory for processing.
[0099] A computer program product provided by the present invention includes a computer program / instruction, which, when executed by a processor, obtains a compilation task; generates description information of the compilation task; determines that a shared server is mounted on a shared directory of a compilation device; detects whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if it is detected that there is a compilation result in the shared directory based on the description information, reads the compilation result from the shared directory for processing; wherein a target number of compilation devices all mount the shared directory, and the target number is greater than or equal to 2. The beneficial effect of the present invention is that each compilation device mounts the shared directory of the shared server, and when processing a compilation task, each compilation device searches the shared directory according to the description information of the compilation task, and if there is a compilation result corresponding to the compilation task in the shared directory, reads the compilation result from the shared directory for processing, so that as long as there is a compilation result in the shared directory, each compilation device can directly obtain the compilation result for processing without having to compile the compilation task to obtain the compilation result, thereby reducing the repeated compilation process of the compilation task and improving the compilation efficiency.
[0100] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: after detecting whether there is a compilation result corresponding to a compilation task in a shared directory based on description information, if it is detected based on the description information that there is no compilation result in the shared directory, executing the compilation task to obtain the compilation result; and storing the description information and the compilation result in the shared directory.
[0101] A computer program product provided by an embodiment of the present invention includes a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented: locking a shared directory; storing description information and compilation results in the shared directory; and unlocking the shared directory.
[0102] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: generating a first locking node based on the current moment; sending the first locking node to a shared server, so that the shared server determines whether to respond to the first locking node based on a lock request pool; if the shared server sends a response message in response to the first locking node, locking the shared directory; wherein the lock request pool is used to store the locking nodes generated by each compilation device and corresponding to the shared directory.
[0103] A computer program product provided by an embodiment of the present invention includes a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented: determining a compiler cache of a compiling device; and determining a shared directory mounted by a shared server in the compiler cache.
[0104] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: before obtaining a compilation task, setting a cache directory of a compiler cache to a local directory on which a shared directory is mounted.
[0105] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: detecting whether a compilation device is a central scheduler, and if the compilation device is a central scheduler, obtaining a total task, distributing the total task, and obtaining a compilation task; if the compilation device is not a central scheduler, receiving the compilation task distributed by the central scheduler; wherein the central scheduler includes a device selected from a target number of compilation devices according to a distributed compiler.
[0106] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: obtaining source file information of a compilation task; obtaining compilation parameters of the compilation task; generating a cache key for the compilation task based on the source file information and the compilation parameters; and using the cache key as description information.
[0107] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: generating a hash value of source file information; and generating a cache key of a compilation task based on the hash value and compilation parameters.
[0108] A distributed compilation system provided by an embodiment of the present invention is applied to a compilation device and may include:
[0109] Get module, used to get compilation tasks;
[0110] The generation module is used to generate the description information of the compilation task;
[0111] A determination module is used to determine that a shared server is mounted on a shared directory of a compilation device; a target number of compilation devices are all mounted with a shared directory, and the target number is greater than or equal to 2;
[0112] The detection module is used to detect whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; if the compilation result is detected to exist in the shared directory based on the description information, the compilation result is read from the shared directory for processing.
[0113] The present invention also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of the distributed compilation method provided in the embodiment of the present invention. Figure 3 , Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0114] An electronic device provided by an embodiment of the present invention includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the following steps are implemented:
[0115] Get the compilation task;
[0116] Generate description information of the compilation task;
[0117] Make sure that the shared server is mounted on the shared directory of the compilation device; the target number of compilation devices are all mounted on the shared directory, and the target number is greater than or equal to 2;
[0118] Based on the description information, detect whether there is a compilation result corresponding to the compilation task in the shared directory;
[0119] If it is detected based on the description information that there is a compilation result in the shared directory, the compilation result is read from the shared directory for processing.
[0120] See also Figure 4Another electronic device provided in an embodiment of the present invention may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize communication between the electronic device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication method adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (Mobile High-Definition Link, MHL), Universal Serial Bus (Universal Serial Bus, USB), High-Definition Multimedia Interface (High-Definition Multimedia Interface, HDMI), wireless connection: wireless fidelity technology (WIreless Fidelity, WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.
[0121] An embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0122] Get the compilation task;
[0123] Generate description information of the compilation task;
[0124] Make sure that the shared server is mounted on the shared directory of the compilation device; the target number of compilation devices are all mounted on the shared directory, and the target number is greater than or equal to 2;
[0125] Based on the description information, detect whether there is a compilation result corresponding to the compilation task in the shared directory;
[0126] If it is detected based on the description information that there is a compilation result in the shared directory, the compilation result is read from the shared directory for processing.
[0127] The computer-readable storage medium involved in the present invention includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.
[0128] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0129] For the description of the relevant parts of a distributed compilation device, a computer program product, an electronic device, and a computer-readable storage medium provided by the embodiments of the present invention, please refer to the detailed description of the corresponding parts in a distributed compilation method provided by the embodiments of the present invention, which will not be repeated here. In addition, the parts of the above technical solutions provided by the embodiments of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0130] It should also 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 presence of other identical elements in the process, method, article or device including the elements.
[0131] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A distributed compilation method, characterized in that: Applicable to compilation equipment, including: Get the compilation task; Generate description information of the compilation task; Determine that a shared server is mounted on a shared directory of the compilation device, wherein the shared directory is used to store compilation results; Detecting whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information; If it is detected based on the description information that the compilation result exists in the shared directory, reading the compilation result from the shared directory for processing; The target number of compiling devices all mount the shared directory, and the target number is greater than or equal to 2; Wherein, after detecting whether there is a compilation result corresponding to the compilation task in the shared directory based on the description information, the method further includes: If it is detected based on the description information that the compilation result does not exist in the shared directory, executing the compilation task to obtain the compilation result; Storing the description information and the compilation result in the shared directory; The step of storing the description information and the compilation result in the shared directory includes: Locking the shared directory; Storing the description information and the compilation result in the shared directory; Unlock the shared directory.
2. The distributed compilation method according to claim 1, characterized in that: Locking the shared directory includes: Generate a first locking node based on the current moment; Sending the first locking node to the shared server, so that the shared server determines whether to respond to the first locking node based on the lock request pool; If the shared server sends a response message in response to the first locking node, the shared directory is locked; The lock request pool is used to store the lock nodes generated by each of the compilation devices and corresponding to the shared directory.
3. The distributed compilation method according to claim 1, characterized in that: Make sure the shared server is mounted on the shared directory of the compilation device, including: Determining a compiler cache of the compiling device; The shared directory mounted by the shared server is determined in the compiler cache.
4. The distributed compilation method according to claim 3, characterized in that: Before getting the compilation task, it also includes: The cache directory of the compiler cache is set to the local directory where the shared directory is mounted.
5. The distributed compilation method according to claim 1, characterized in that: Get compilation tasks, including: Detecting whether the compiling device is a central scheduler; If the compilation device is the central scheduler, obtaining a total task, distributing the total task, and obtaining the compilation task; If the compiling device is not the central scheduler, receiving the compiling task distributed by the central scheduler; The central scheduler includes a device selected from the target number of compiling devices by the distributed compiler.
6. The distributed compilation method according to claim 1, characterized in that: Generate description information of the compilation task, including: Obtaining source file information of the compilation task; Obtaining compilation parameters of the compilation task; Generate a cache key for the compilation task based on the source file information and the compilation parameters; The cache key is used as the description information.
7. The distributed compilation method according to claim 6, characterized in that: Generating a cache key of the compilation task based on the source file information and the compilation parameters includes: Generate a hash value of the source file information; A cache key for the compilation task is generated based on the hash value and the compilation parameter.
8. A distributed compilation device, characterized in that: It includes a shared server and a target number of compilation devices connected to the shared server, the target number is greater than or equal to 2, and the target number of compilation devices are all mounted with a shared directory of the shared server, and the shared directory is used to store compilation results; The compiling device is used to obtain a compiling task; generate description information of the compiling task; detect whether there is a compiling result corresponding to the compiling task in a shared directory based on the description information; if the compiling result is detected to exist in the shared directory based on the description information, read the compiling result from the shared directory for processing; If it is detected based on the description information that the compilation result does not exist in the shared directory, the compilation task is executed to obtain the compilation result, the shared directory is locked, the description information and the compilation result are stored in the shared directory, and the shared directory is unlocked.
9. The distributed compilation device according to claim 8, characterized in that: The compiling device is configured with a distributed compiler and a compiler cache.
10. The distributed compilation device according to claim 9, characterized in that: The shared server is used for: Identify shared files; Obtaining compiler cache information of the compiling device; Adding the compiler cache information to the shared file; The read and write permission information of the compiling device is added to the shared file, wherein the read and write permission information includes the read and write permission of the compiling device to the shared directory.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the distributed compilation method according to any one of claims 1 to 7 are implemented.
12. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the distributed compilation method according to any one of claims 1 to 7 when executing the computer program.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the distributed compilation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Compiling system, electronic device and readable medium
CN112445489A
Distributed compiling method and device, equipment and readable storage medium
CN113986239A
Compiling method, device and equipment
CN115421722A
Distributed compiling method and system, node and computer readable storage medium
CN117111948A
Object compiling method and device, computer equipment, storage medium and program product
CN117687616A
