File compiling method and device, electronic equipment and storage medium

By using thread pools to perform compilation tasks concurrently and avoiding duplicate compilation, the problem of long and slow file compilation time is solved, and an efficient file compilation process is achieved.

CN119271208APending Publication Date: 2025-01-07BEIJING QINGYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411379528.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

In the prior art, file compilation methods have problems such as long compilation time, slow compilation speed and repeated compilation in large-scale software projects, resulting in insufficiency of file compilation.

Method used

By obtaining the compilation control parameters of the file to be compiled, creating and adding the compilation thread to the preset thread pool, and compiling within each compilation thread based on the unique identification information of the file to be compiled, using the thread pool to perform multiple compilation tasks concurrently, avoiding the use of the thread pool to avoid Repeat compilation.

Benefits of technology

It effectively reduces file compilation time, speeds up file compilation speed, ensures that each file to be compiled correctly, avoids duplicate compilation, and improves file compilation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271208A_ABST
    Figure CN119271208A_ABST
Patent Text Reader

Abstract

The invention discloses a file compiling method and device, electronic equipment and a storage medium, and relates to the technical field of data processing. According to the specific implementation scheme, compiling control parameters of a to-be-compiled file are obtained; creating a compiling thread according to the compiling control parameter, and adding the compiling thread to a preset thread pool; and compiling based on the unique identification information of the to-be-compiled file in each compiling thread. According to the embodiment of the invention, the file compiling time is shortened, the file compiling process is accelerated, repeated file compiling is avoided, and the file compiling efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a file compilation method, device, electronic equipment and storage medium. Background Art

[0002] File compilation is an important part of software development, which aims to convert source code written in a programming language into machine code or intermediate code that can be directly executed by a computer. In the field of data processing technology, file compilation ensures efficient execution of code and improves program performance and security. However, with the continuous expansion of the scale of software projects, when the size of the files to be compiled is particularly large, the file compilation methods in the prior art have problems such as long compilation time, slow compilation speed and repeated compilation, which greatly reduces the efficiency of file compilation. Therefore, reducing file compilation time, speeding up file compilation speed and avoiding repeated file compilation have become urgent problems to be solved in the field of data processing technology. Summary of the invention

[0003] The embodiments of the present invention provide a file compilation method, device, electronic device and storage medium, which can reduce the file compilation time and speed up the file compilation speed.

[0004] In one aspect of an embodiment of the present invention, a file compilation method is provided, comprising:

[0005] Get the compilation control parameters of the file to be compiled;

[0006] Create a compile thread according to the compile control parameters, and add the compile thread to the preset thread pool;

[0007] Compilation is performed in each compilation thread based on the unique identification information of the file to be compiled.

[0008] Another aspect of an embodiment of the present invention provides a file compiling device, comprising:

[0009] Compilation parameter module, used to obtain the compilation control parameters of the file to be compiled;

[0010] A thread creation module, used to create a compilation thread according to the compilation control parameters, and add the compilation thread to a preset thread pool;

[0011] The compiling execution module is used to compile in each compiling thread based on the unique identification information of the file to be compiled.

[0012] Another aspect of an embodiment of the present invention provides an electronic device, including:

[0013] at least one processor; and

[0014] a memory communicatively connected to at least one processor; wherein,

[0015] The memory stores a computer program executable by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the file compiling method according to any one of claims 1 to 7.

[0016] Another aspect of the embodiments of the present invention provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the file compilation method of any embodiment of the present invention when executing the computer instructions.

[0017] In an embodiment of the present invention, a compilation control parameter for guiding a file to be compiled to perform a compilation operation is obtained, and a compilation thread for executing a compilation task is created according to the compilation control parameter. After the compilation thread is created, the compilation thread is added to a preset thread pool that has been created in advance. In each compilation thread, the file to be compiled is determined or identified based on the unique identification information of the file to be compiled, and a compilation operation is performed on the file to be compiled. The technical solution of the embodiment of the present invention can use the thread pool to concurrently execute multiple compilation threads by adding the compilation thread to the preset thread pool, saving file compilation time and speeding up file compilation. The file to be compiled is compiled according to the unique identification information, which can ensure that each file to be compiled is compiled correctly and avoid repeated compilation of the file to be compiled.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 is a flowchart of a file compilation method provided according to Embodiment 1 of the present invention;

[0021] Figure 2 is a flowchart of another file compilation method provided according to Embodiment 2 of the present invention;

[0022] Figure 3 is a flowchart of another file compilation method provided according to Embodiment 3 of the present invention;

[0023] Figure 4 is a flow chart of another file compilation method provided according to Embodiment 4 of the present invention;

[0024] Figure 5 is a flowchart of a file compilation task provided according to a fourth embodiment of the present invention;

[0025] Figure 6 is a thread pool control flow chart provided according to Embodiment 4 of the present invention;

[0026] Figure 7 It is a schematic diagram of the structure of a file compiling device for implementing an embodiment of the present invention;

[0027] Figure 8 The present invention is a block diagram of an electronic device for implementing the file compilation method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] Figure 1 A flowchart of a file compilation method is provided for the first embodiment of the present invention. This embodiment is applicable to the case of optimizing the file compilation process. The method can be executed by a file compilation device. The file compilation device can be implemented in the form of hardware and / or software. The file compilation device can be configured in an electronic device. Figure 1 As shown, the method includes:

[0032] S110: Obtain compilation control parameters of the file to be compiled.

[0033] In the embodiment of the present invention, the file to be compiled can be understood as a source code file that needs to be compiled, wherein the compilation operation on the file to be compiled is intended to be converted into a computer executable file, and the file to be compiled is written in a programming language, and the programming language may include, for example, C, C++ or Java, etc. The compilation control parameters can be understood as a series of parameters that guide the compilation operation of the file to be compiled, and are used to guide the behavior of the compilation process. For example, the compilation control parameters include at least one of the following: a project folder to be compiled, a cache folder or a concurrent number, etc.

[0034] Specifically, the compilation control parameters for guiding the compilation operation of the file to be compiled are obtained, wherein the compilation control parameters may be obtained by: using command line options of a compilation tool or viewing a project configuration file. Obtaining the compilation control parameters of the file to be compiled can ensure that the file to be compiled can be converted into a computer executable file as expected.

[0035] S120: Create a compile thread according to the compile control parameters, and add the compile thread to a preset thread pool.

[0036] In an embodiment of the present invention, a compile thread can be understood as a thread used to execute a compile task, and the creation of a compile thread is guided by compile control parameters. A thread pool refers to a mechanism for managing the life cycle and resources of compile threads, wherein the size of the thread pool can be set according to the number of concurrencies in the compile control parameters or adjusted according to the number of processor cores of the system. A preset thread pool can be understood as a thread pool that has been created in advance, wherein the considerations for creating a thread pool may include: the hardware resources of the system or the scale of the compile task.

[0037] Specifically, a compile thread for executing the compile task is created according to the compile control parameters. After the compile thread is created, the compile thread is added to a preset thread pool that has been created in advance. After the compile thread is added to the preset thread pool, the preset thread pool allocates an idle thread to execute the compile thread. If all threads in the preset thread pool are working, the compile thread will wait in the thread pool until an idle thread executes the compile thread. The thread pool can reduce the overhead of thread creation and destruction by reusing the created compile threads. The thread pool allows multiple compile threads to execute concurrently, which can reduce the compilation time of the file.

[0038] S130: Compile in each compilation thread based on the unique identification information of the file to be compiled.

[0039] In the embodiment of the present invention, the unique identification information may be understood as an identifier used to uniquely determine or identify the file to be compiled. For example, the identification information may include: a file name or a hash value.

[0040] Specifically, in each compilation thread, the file to be compiled is determined or identified based on the unique identification information of the compilation file, and the compilation operation is performed on the file to be compiled. Compiling the file to be compiled according to the unique identification information can ensure that each compilation thread is for a unique file to be compiled during the compilation operation, thereby ensuring the accuracy of the compilation and avoiding repeated compilation.

[0041] In an embodiment of the present invention, a compilation control parameter for guiding a file to be compiled to perform a compilation operation is obtained, and a compilation thread for executing a compilation task is created according to the compilation control parameter. After the compilation thread is created, the compilation thread is added to a preset thread pool that has been created in advance. In each compilation thread, the file to be compiled is determined or identified based on the unique identification information of the compilation file, and a compilation operation is performed on the file to be compiled. The technical solution of the embodiment of the present invention can use the thread pool to concurrently execute multiple compilation threads by adding the compilation thread to the preset thread pool, saving file compilation time and speeding up file compilation. The file to be compiled is compiled according to the unique identification information, which can ensure that each file to be compiled is compiled correctly and avoid repeated compilation of the file to be compiled.

[0042] Embodiment 2

[0043] Figure 2 This is a flowchart of another file compilation method provided by Embodiment 2 of the present invention. Based on the above embodiment, this embodiment of the present invention provides another file compilation method. Figure 2 As shown, the method includes:

[0044] S210: Obtain compilation control parameters of the file to be compiled.

[0045] S220, reading the to-be-compiled project folder, cache folder and concurrency number in the compilation control parameters.

[0046] In an embodiment of the present invention, the to-be-compiled project folder contains all source code files that need to be compiled, and is used to guide the electronic device to determine the to-be-compiled files; the cache folder is used to store cache files generated during the compilation process, wherein the files in the cache folder can be reused in subsequent compilation processes to avoid repeated compilation of the same source code files, thereby reducing compilation time; the concurrency number refers to the number of compilation threads allowed to be executed simultaneously during the compilation process. Multiple compilation threads are executed simultaneously, which speeds up the file compilation process.

[0047] Specifically, the project folder to be compiled, the cache folder and the number of concurrent connections are read from the compilation control parameters. Among them, the source code files to be compiled can be determined by reading the project folder to be compiled, and the cache folder stores the cache files generated by the files to be compiled during the compilation process. Reading the cache folder can avoid repeatedly compiling the same source code files. The number of concurrent connections is read from the compilation control parameters, and a corresponding number of compilation threads can be created according to the read number of concurrent connections. The corresponding number of compilation threads can execute compilation tasks at the same time, reducing compilation time.

[0048] S230: Create a number of compilation threads corresponding to the number of concurrent connections, and initialize the compilation threads according to the to-be-compiled project folders and the cache folders.

[0049] Specifically, the number of concurrency is read from the compilation control parameters, a corresponding number of compilation threads are created according to the number of concurrency, the project folder to be compiled and the cache folder are read from the compilation control parameters, and the compilation threads are initialized according to the project folder to be compiled and the cache folder to ensure that each compilation thread can execute the compilation task.

[0050] For example, initializing the compilation threads according to the to-be-compiled project folder and the cache folder may include: specifying a path of the to-be-compiled project folder for each compilation thread or specifying a path of the cache folder for each compilation thread.

[0051] S240: Add each compile thread to a waiting task list of a preset thread pool, and move the compile thread to an execution task list of the preset thread pool when executing the compile thread.

[0052] In the embodiment of the present invention, the waiting task list can be understood as a list of threads in the thread pool that have not yet started to execute tasks, and the executing task list can be understood as a list of compiling threads in the thread pool that are currently executing tasks. Before a compiling thread is assigned a task, it is in the waiting task list and is in a waiting state. When a compiling thread is selected from the waiting task list and starts to execute a compiling task, it is moved to the executing task list and starts to execute the compiling task.

[0053] Specifically, the preset thread pool includes at least two states of task lists, namely a waiting task list and an execution task list. Compilation threads that do not need to execute compilation tasks are added to the waiting task list of the preset thread pool. Compilation threads in the waiting task list are not assigned compilation tasks and are in a waiting state. When a compilation thread is selected in the waiting task list and needs to start executing compilation tasks, the compilation thread will be moved to the execution task list of the preset thread pool. The compilation threads in the execution task list are assigned compilation tasks and are in a working state. When the waiting task list and the execution task list are both empty, the preset thread pool indicates that there are no tasks.

[0054] S250: For each compilation thread, use the hash value of the file to be compiled as unique identification information.

[0055] In the embodiment of the present invention, the hash value refers to a character string of fixed length obtained by calculating the file to be compiled through a hash function. For example, the hash function may include: MD5 function, SHA-1 function or SHA-256 function, etc.

[0056] Specifically, in the created compilation thread, the to-be-compiled file is calculated by a hash function, the obtained hash value is used as the unique identification information for determining or identifying the to-be-compiled file, and the to-be-compiled file is compiled according to the unique identification information.

[0057] S260: Determine a target compiled file cache for the file to be compiled in the historical compiled file cache according to the unique identification information.

[0058] In an embodiment of the present invention, the compiled file cache can be understood as files and file compilation results generated during the compilation process, the historical compiled file cache can be understood as a collection of file caches for storing previously compiled files and file compilation results, the target compiled file cache can be understood as a file cache that matches the unique identification information of the current file to be compiled, the target compiled file cache is obtained by matching the unique identification information in the historical compiled file cache, and the target compiled file cache can be directly used in subsequent compilation processes.

[0059] Specifically, the file matching the unique identification information of the file to be compiled is searched in the historical compiled cache files according to the unique identification information, and the file matching the unique identification information found in the historical compiled cache files is used as the target compiled cache file.

[0060] S270: Copy the target compiled file cache as the compiled file cache of the file to be compiled.

[0061] Specifically, if the target compilation file cache is searched in the historical compiled cache files, then during the compilation process, the target compilation file cache is directly copied as the compilation file cache of the file to be compiled. There is no need to compile the file to be compiled again. Copying the target compilation file cache as the compilation file cache of the file to be compiled can avoid repeated compilation and reduce compilation time.

[0062] In an embodiment of the present invention, a compilation control parameter of a file to be compiled is obtained, a project folder to be compiled, a cache folder and a concurrency number are read from the compilation control parameter, a corresponding number of compilation threads are created according to the read concurrency number, the compilation thread is initialized according to the project folder to be compiled and the cache folder, the initialized compilation thread is added to a waiting task list of a thread pool, when the compilation thread is selected in the waiting task list and needs to execute a compilation task, the compilation thread is moved to an execution task list of a preset thread pool, a hash value of the file to be compiled is calculated according to a hash function, the hash value is used as unique identification information of the file to be compiled, the file to be compiled is compiled based on the unique identification information, during the compilation process, a cache file matching the unique identification information of the file to be compiled is searched in a historical compiled cache file according to the unique identification information, the cache file matching the unique identification information is used as a target compilation cache file, and the target compilation cache file is directly copied as a compilation file cache of the file to be compiled, without compiling the file to be compiled. The technical solution of the embodiment of the present invention reads the concurrency number from the compilation control parameter, creates a corresponding number of compilation threads according to the read concurrency number, and the corresponding number of compilation threads can execute compilation tasks in parallel, so that the file compilation time is reduced and the compilation process is accelerated. Based on the hash value, the target compilation file cache of the file to be compiled is determined in the historical compiled file cache, and the target compilation file cache that matches the file to be compiled is copied as the compilation file cache of the file to be compiled, avoiding repeated compilation of files, reducing file compilation time, and thereby improving the compilation efficiency of files.

[0063] Embodiment 3

[0064] Figure 3 This is a flowchart of another file compilation method provided by Embodiment 3 of the present invention. Based on the above embodiment, this embodiment of the present invention provides another file compilation method. Figure 3 As shown, the method includes:

[0065] S310: Obtain compilation control parameters of the file to be compiled.

[0066] S320, reading the to-be-compiled project folder, cache folder and concurrency number in the compilation control parameters.

[0067] S330: Create a number of compilation threads corresponding to the number of concurrent connections, and initialize the compilation threads according to the to-be-compiled project folders and cache folders.

[0068] S340: Add each compile thread to a waiting task list of a preset thread pool, and move the compile thread to an execution task list of the preset thread pool when executing the compile thread.

[0069] S350: For each compilation thread, use the hash value of the file to be compiled as unique identification information.

[0070] S360: Generate a compiled file cache path according to the unique identification information.

[0071] In the embodiment of the present invention, the compiled file cache path refers to the storage location of the compiled file cache.

[0072] Specifically, the to-be-compiled file is compiled according to the unique identification information, and a compiled file cache is generated during the compilation process. The storage location of the compiled file cache is generated according to the unique identification information, and the storage location is used as the compiled file cache path.

[0073] S370: Use the historical compiled file cache stored in the compiled file cache path as the target compiled file cache.

[0074] Specifically, a compilation file cache path is obtained, a historical compiled file cache is found under the compilation file cache path, and the found historical compiled file cache is used as a target compilation file cache for the file to be compiled.

[0075] S380: Copy the target compiled file cache as the compiled file cache of the file to be compiled.

[0076] Based on the above embodiment, in the embodiment of the present invention, the compiled file cache path is generated according to the unique identification information, including:

[0077] At least part of the characters of the unique identification information is extracted as a folder name; a cache subfolder is created in the cache folder of the to-be-compiled file according to the folder name, and the folder path of the cache subfolder is used as the compiled file cache path.

[0078] Specifically, the unique identification information of the file to be compiled is obtained, some characters are extracted from the unique identification information of the file to be compiled, and the extracted some characters are used as the folder name, a cache subfolder is created according to the folder name in the cache folder of the file to be compiled, and the creation path of the cache subfolder is defined as the compiled file cache path.

[0079] By way of example, an implementation method for obtaining a compiled file cache path based on unique identification information may include: obtaining a hash value of a file to be compiled based on a hash function, using the hash value of the file to be compiled as unique identification information of the file to be compiled, constructing a compiled file cache path through the hash value, taking the hash value b0534ef0924275fa1f28e85a989c960e as an example, the first-level folder is agreed to be the first 2 characters of the hash value, i.e., b0, and b0 is used as the folder name of the first-level folder, the second-level folder is agreed to be the last 3 characters of the first 5 characters of the hash value, i.e., 534, and 534 is used as the folder name of the second-level folder, and obtaining a cache folder in the compilation control parameters. Taking / pitrix / pycache as an example of the obtained cache folder, the compiled file cache path is / pitrix / pycache / b0 / 534 / b0534ef0924275fa1f28e85a989c960e.

[0080] Based on the above embodiment, the embodiment of the present invention further includes: when there is no target compiled file cache, a compile operation is performed on the file to be compiled to obtain a compiled file cache.

[0081] Specifically, when the target compilation file cache is not matched in the historical compiled file cache based on the unique identification information, it indicates that the target compilation file cache does not exist. When the target compilation file cache does not exist, the target compilation file cache cannot be directly copied as the compilation file cache, and a compilation operation must be performed on the file to be compiled to obtain the compilation file cache of the file to be compiled.

[0082] Based on the above embodiment, the embodiment of the present invention further includes: when the time difference between the last access time and the current access time of the historical compiled file cache is greater than a threshold, deleting the historical compiled file cache.

[0083] In the implementation of the present invention, the last access time refers to the time point when the historical compiled file cache was last accessed, wherein the last access time is updated each time the historical compiled file cache is accessed to reflect the latest access time. The current access time refers to the real time of accessing the historical compiled file cache, wherein the current time is obtained for comparison with the last access time. The threshold value can be understood as a preset time length, which is used to define the maximum time interval between the last access time and the current access time.

[0084] Specifically, when the difference between the time when the historical compiled file cache was last accessed and the current real-time access time is greater than a threshold, the historical compiled file cache will be deleted to release storage space.

[0085] Embodiment 4

[0086] Based on the above-mentioned embodiments, the embodiments of the present invention provide another file compilation method flow, a file compilation task flow and a thread pool control flow.

[0087] like Figure 4 As shown, a process of a file compilation method is described in detail, the compilation control parameters are read, wherein the compilation control parameters at least include: a project folder to be compiled, a cache folder and a concurrency number, and a compilation thread and a thread pool are created according to the read compilation control parameters. After the thread pool is started, all the files to be compiled are traversed, and then the files to be compiled that need to be compiled are added to the thread pool. When all the files to be compiled are compiled, the traversal ends. Since the compilation tasks are executed concurrently, it is necessary to wait until the thread pool completes all tasks before the file compilation method process ends. In addition, in the process of traversing the files to be compiled, the traversal can be directly terminated. The methods for terminating the traversal may include: the compilation task fails, the process is terminated, or an external abort instruction is sent to terminate the traversal.

[0088] like Figure 5 As shown, a file compilation task process is described in detail. The hash value of the file to be compiled is calculated according to the hash function. The hash value will be used as the unique identification information of the file to be compiled, which is used to determine or identify the file to be compiled in the subsequent steps. The cache path of the file to be compiled is obtained by using the calculated hash value. Under the determined cache path, it is determined whether there is a cache file to be compiled corresponding to the file to be compiled based on the unique identification information. If it exists, it indicates that other compilation threads have successfully compiled the file to be compiled, indicating that there is no need to compile the file to be compiled again. At this time, the cache file to be compiled will be directly copied to the target location, and the access time of the cache file to be compiled will be updated to reflect the time when the cache file to be compiled was last accessed. In addition, if the cache file to be compiled corresponding to the file to be compiled cannot be found, it means that the current file to be compiled has not been compiled, and the file to be compiled will be compiled. If the compilation process is successfully completed, the compiled file will be copied to the previously determined cache path for subsequent direct reuse. If an error is encountered during the compilation process and the compilation fails, the compilation task will be marked as failed. In this case, the current process will be terminated, and the compilation failure information will be reported to the user or developer, and the entire compilation task process ends.

[0089] like Figure 6As shown, a thread pool control process is described in detail, which obtains compilation control parameters, initializes the compilation control parameters, creates compilation threads and thread pools according to the compilation control parameters, and starts the thread pool to prepare to receive and execute compilation tasks. Subsequently, the thread pool control process enters a loop body, first detecting whether the compilation task is terminated. If it is detected that the compilation task is terminated, the thread pool control process will end immediately. If the compilation task is still in the execution state, the thread pool control process will obtain new compilation task information. After successfully obtaining the compilation task information, it will further evaluate whether there are pending compilation tasks. If there are pending compilation tasks, it will continue to determine whether the current number of compilation tasks has reached or exceeded the preset concurrency limit. If the current number of compilation tasks does not exceed the concurrency limit, it means that the thread pool is still capable of processing more tasks in parallel, and will continue to execute the current compilation task asynchronously, reset the compilation task information, and detect whether the compilation task is terminated again until all pending compilation tasks are successfully executed and the thread pool control process ends.

[0090] Embodiment 5

[0091] Figure 7 This is a schematic diagram of the structure of a file compilation method device provided by Embodiment 5 of the present invention. Figure 7 As shown, the device comprises:

[0092] A compilation parameter module 510 is used to obtain compilation control parameters of the file to be compiled;

[0093] The thread creation module 520 is used to create a compile thread according to the compile control parameters and add the compile thread to a preset thread pool;

[0094] The compiling execution module 530 is used to compile in each compiling thread based on the unique identification information of the file to be compiled.

[0095] In the embodiment of the present invention, a compilation control parameter for guiding the compilation operation of the file to be compiled is obtained through a compilation parameter module, and a thread creation module creates a compilation thread for executing the compilation task according to the compilation control parameter. After the compilation thread is created, the compilation thread is added to a preset thread pool that has been created in advance. In each compilation thread, a compilation execution module determines or identifies the file to be compiled based on the unique identification information of the compilation file, and performs a compilation operation on the file to be compiled. The technical solution of the embodiment of the present invention can use the thread pool to concurrently execute multiple compilation threads by adding the compilation thread to the preset thread pool, saving file compilation time and speeding up the file compilation. The file to be compiled is compiled according to the unique identification information, which can ensure that each file to be compiled is correctly compiled and avoid duplicate compilation of files.

[0096] Furthermore, the compilation execution module 530 also includes: an identification information determination submodule, which is used to use the hash value of the file to be compiled as the unique identification information for each compilation thread; a file cache determination submodule, which is used to determine the target compilation file cache of the file to be compiled in the historical compiled file cache according to the unique identification information; and a file cache copy submodule, which is used to copy the target compilation file cache as the compilation file cache of the file to be compiled.

[0097] Based on the above embodiment, the embodiment of the present invention further includes: when there is no target compiled file cache, a compile operation is performed on the file to be compiled to obtain a compiled file cache.

[0098] Based on the above embodiment, the embodiment of the present invention further includes: when the time difference between the last access time of the historical compiled file cache and the current time is greater than a threshold, deleting the historical compiled file cache.

[0099] Furthermore, the file cache determination submodule also includes: a cache path generation unit, which is used to generate a compiled file cache path according to the unique identification information; and a target compiled file cache determination unit, which is used to use the historical compiled file cache stored in the compiled file cache path as the target compiled file cache.

[0100] Optionally, the thread creation module 520 is specifically used for:

[0101] Read the project folder to be compiled, cache folder and concurrent number in the compilation control parameters;

[0102] Create a number of compilation threads corresponding to the number of concurrent connections, and initialize the compilation threads according to the project folders to be compiled and the cache folders;

[0103] Each compilation thread is added to a waiting task list of a preset thread pool, and when the compilation thread is executed, the compilation thread is moved to an execution task list of the preset thread pool.

[0104] Optionally, the cache path generation unit is specifically used for:

[0105] Extracting at least part of the characters of the unique identification information as a folder name;

[0106] Create a cache subfolder according to the folder name in the cache folder of the file to be compiled, and use the folder path of the cache subfolder as the compiled file cache path.

[0107] Embodiment 6

[0108] The embodiments of the present invention provide an electronic device for a file compilation method, a computer-readable storage medium and a computer program product.

[0109] Figure 8A schematic diagram of an electronic device that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown in the embodiments of the present invention, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present invention described and / or required herein.

[0110] like Figure 8 As shown, the electronic device includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the ROM 12 or the computer program loaded from the storage unit 18 to the RAM 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0111] A number of components in the electronic device are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0112] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit, a graphics processing unit, various special artificial intelligence computing chips, various processors running machine learning model algorithms, digital signal processors, and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, for example, a file compilation method.

[0113] In some embodiments, the file compilation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the file compilation method may be performed. Alternatively, in other embodiments, the processor 11 may be configured as the file compilation method in any other appropriate manner (e.g., by means of firmware).

[0114] Various implementations of the systems and techniques described above in the embodiments of the present invention may be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays, application specific integrated circuits, application specific standard products, systems on a chip, load programmable logic devices, computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general programmable processor, which may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0115] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0116] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0117] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a cathode ray tube or a liquid crystal display monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including: acoustic input, voice input, or tactile input).

[0118] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local area networks, wide area networks, blockchain networks, and the Internet.

[0119] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private server services.

[0120] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0121] The above specific implementations do not constitute a limitation on the protection scope of the embodiments of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A file compilation method, characterized in that: The method comprises: Get the compilation control parameters of the file to be compiled; Creating a compile thread according to the compile control parameters, and adding the compile thread to a preset thread pool; Compilation is performed in each of the compilation threads based on the unique identification information of the file to be compiled.

2. The method according to claim 1, characterized in that: The compiling in each of the compiling threads based on the unique identification information of the file to be compiled includes: For each of the compiling threads, using the hash value of the file to be compiled as the unique identification information; Determine the target compiled file cache of the file to be compiled in the historical compiled file cache according to the unique identification information; The target compiled file cache is copied as the compiled file cache of the file to be compiled.

3. The method according to claim 2, characterized in that: The step of determining the target compiled file cache of the file to be compiled in the historical compiled file cache according to the unique identification information includes: Generate a compiled file cache path according to the unique identification information; The historical compiled file cache stored in the compiled file cache path is used as the target compiled file cache.

4. The method according to claim 2, characterized in that: Also includes: When the target compiled file cache does not exist, a compiling operation is performed on the file to be compiled to obtain the compiled file cache.

5. The method according to claim 2, characterized in that: Also includes: When the time difference between the last access time and the current access time of the historical compiled file cache is greater than a threshold, the historical compiled file cache is deleted.

6. The method according to claim 1, characterized in that: The creating a compile thread according to the compile control parameter and adding the compile thread to a preset thread pool includes: Read the to-be-compiled project folder, cache folder and concurrent number in the compilation control parameters; Creating a number of compiling threads corresponding to the number of concurrent connections, and initializing the compiling threads according to the to-be-compiled project folders and the cache folders; Each of the compiling threads is added to a waiting task list of the preset thread pool, and when the compiling thread is executed, the compiling thread is moved to an execution task list of the preset thread pool.

7. The method according to claim 3, characterized in that: The generating the compiled file cache path according to the unique identification information includes: Extracting at least part of the characters of the unique identification information as a folder name; A cache subfolder is created in the cache folder of the to-be-compiled file according to the folder name, and the folder path of the cache subfolder is used as the compiled file cache path.

8. A file compilation device, characterized in that: The device comprises: Compilation parameter module, used to obtain the compilation control parameters of the file to be compiled; A thread creation module, used to create a compile thread according to the compile control parameters, and add the compile thread to a preset thread pool; The compiling execution module is used to compile in each compiling thread based on the unique identification information of the file to be compiled.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the file compiling method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the file compilation method according to any one of claims 1 to 7 when executed.