Multi-branch concurrent compiling method and device, equipment and storage medium

By establishing a file-level dependency graph and a multi-level caching mechanism in multi-branch parallel development, the problem of inaccurate cache usage in the compilation system is solved, thereby reducing compilation time and improving compilation efficiency, and ensuring efficient collaborative optimization of complex dependent modules.

CN121579020APending Publication Date: 2026-02-27CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511780093.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In multi-branch parallel development, existing compilation systems cannot accurately utilize caches, resulting in large fluctuations in compilation time, significant time consumption during the first compilation, and coarse dependency analysis leading to frequent recompilation of irrelevant files, resulting in low efficiency of remote team collaboration.

Method used

By parsing circular dependencies to form a directed acyclic graph, a file-level dependency graph is established. Independent main cache folders and secondary cache folders are created for each source branch. Incremental compilation is then performed in conjunction with the file-level dependency graph to optimize the compilation caching mechanism.

Benefits of technology

It significantly shortens the first compilation time, improves the compilation hit rate of the second commit, enhances the compilation efficiency and cache accuracy of multi-branch concurrent development, and ensures real-time collaborative optimization of modules with complex dependencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579020A_ABST
    Figure CN121579020A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-branch concurrent compiling method, device and equipment and a storage medium, and relates to the technical field of software development compiling optimizing.The method comprises the steps that source files and header files which the source files directly depend on form compiling units, and a file-level dependency graph between the compiling units is established; creating an independent primary cache folder for the source branch, and creating a corresponding secondary cache folder for a target branch requested to be merged by the source branch; when the source branch triggers compiling for the first time, the compiling cache of the secondary cache folder of the target branch of the source branch is positioned and obtained, and when the source branch triggers compiling again, the compiling cache is directly obtained from the main cache folder of the source branch; and determining a to-be-compiled unit set based on the file-level dependency graph, performing incremental compilation according to the acquired compilation cache, and storing a compilation result to a main cache folder of the source branch. The method can solve the problems that during multi-branch concurrent compiling, cache cannot be accurately used, and time consumption of first-time compiling increment is serious.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software development and compilation optimization, in particular to a multi-branch concurrent compilation method, device, equipment and storage medium. BACKGROUND

[0002] The core algorithm modules (such as perception, positioning, planning, and control) of an intelligent driving system are usually developed using high-performance C++ language, and the code scale is large and the dependency relationship between modules is complex.

[0003] To cope with the needs of rapid iteration, parallel development of functions, urgent bug fixing, etc., as shown in Figure 1 , a multi-branch parallel development mode is generally adopted at present. That is, there is a stable trunk branch, and there are multiple feature branches or repair branches, and developers work independently on different branches. Developers need to frequently switch between different branches for development, testing and verification.

[0004] Incremental compilation is a key technology to improve the development efficiency of large projects, and its core idea is to recompile only the source files and their dependent files that have changed since the last compilation. The mainstream build system (such as Make, CMake) supports incremental compilation. However, when multiple branches are used for parallel development, multiple branches occupy the same compilation cache or only some branches can use the compilation cache, resulting in large fluctuations in compilation time when multiple branches are used for parallel development; as shown in Figure 2 , the existing cache scheme only supports module-level cache, and multiple branches commonly modify a cache file when multiple branches are used for concurrent development, resulting in the acquisition of dirty cache.

[0005] In the mainstream compilation build system, dependency analysis is rough, and even a single file modification may trigger a large number of unrelated file recompilations, which is particularly time-consuming when the project function is large. Lack of fine-grained cache system, unable to share compilation results across branches, and low efficiency of remote team collaboration. SUMMARY

[0006] The present application provides a multi-branch concurrent compilation method, device, equipment and storage medium, which can solve the problem of inaccurate use of cache and serious incremental compilation time when multiple branches are used for concurrent compilation.

[0007] In a first aspect, the present application provides a multi-branch concurrent compilation method, which comprises: constructing a compilation unit from a source file and its directly dependent header file, and forming a directed acyclic graph through parsing circular dependency to establish a file-level dependency graph between compilation units; creating an independent primary cache folder for a source branch to store its local merged compilation cache, and creating a corresponding secondary cache folder for a target branch requested to be merged by the source branch to store the compilation cache after the target branch is merged; When the source branch triggers compilation for the first time, locate and acquire the compilation cache of the target branch secondary cache folder, and when the same source branch triggers compilation again, directly acquire the compilation cache from its primary cache folder; Based on the file-level dependency graph, determine the set of units to be compiled, and perform incremental compilation according to the acquired compilation cache, and store the compilation result to the primary cache folder of the source branch.

[0008] In combination with the first aspect, in an implementation, the forming of a directed acyclic graph by resolving the circular dependency to establish the file-level dependency graph between the compilation units comprises: building a global symbol reference relationship matrix to identify a cross-file call chain; topologically sorting the identified strongly connected components, and extracting a common symbol table; generating an intermediate interface file based on the common symbol table to isolate bidirectional dependencies; reconstructing the dependency relationship of the compilation unit to point to the intermediate interface file, forming a directed acyclic graph to establish the file-level dependency graph between the compilation units.

[0009] In combination with the first aspect, in an implementation, the determining of the set of units to be compiled based on the file-level dependency graph, and the performing of incremental compilation according to the acquired compilation cache comprises: When a source file is modified, traverse the file-level dependency graph, and use a depth-first search and a topological sorting algorithm to mark the affected direct and indirect dependency nodes; Only trigger recompilation for the compilation units corresponding to the affected nodes.

[0010] In combination with the first aspect, in an implementation, it further comprises: After the source branch is merged into the target branch, asynchronously trigger a cache reconstruction task for the target branch to generate new compilation cache and update to the corresponding secondary cache folder.

[0011] In combination with the first aspect, in an implementation, the secondary cache folder comprises a state indicating file, and the state comprises idle, occupied and abandoned; When the state of the secondary cache folder is idle, read the cache information therein as the compilation cache, and modify the state thereof from idle to occupied.

[0012] In combination with the first aspect, in an implementation, it further comprises: creating a corresponding merge request ID file in the hit secondary cache folder, deleting the merge request ID file in the hit secondary cache folder when the compilation ends, and marking the secondary cache folder as idle when there is no merge request ID file under the secondary cache folder.

[0013] In combination with the first aspect, in an implementation, the method further includes: If the primary cache folder remains in the occupied state and exceeds a preset threshold time, marking the state of the primary cache folder as abandoned.

[0014] In a second aspect, an embodiment of the present application provides a multi-branch concurrent compilation device, which includes: The compilation control module is configured to form a compilation unit by using a source file and a header file directly dependent on the source file, and to establish a file-level dependency graph between the compilation units by parsing a circular dependency to form a directed acyclic graph. The cache module is configured to create an independent primary cache folder for a source branch to store a local compiled cache after merging, and to create a corresponding secondary cache folder for a target branch requested by the source branch to store a compiled cache after merging of the target branch is completed. The scheduling module is configured to locate and acquire the compiled cache of the secondary cache folder of the target branch of the source branch when the source branch triggers compilation for the first time, and to directly acquire the compiled cache from the primary cache folder of the source branch when the source branch triggers compilation again. The scheduling module is further configured to determine a set of to-be-compiled units based on the file-level dependency graph, to perform incremental compilation based on the acquired compiled cache, and to store a compilation result in the primary cache folder of the source branch.

[0015] In a third aspect, an embodiment of the present application provides a multi-branch concurrent compilation device, which includes a processor, a memory, and a multi-branch concurrent compilation program stored in the memory and executable by the processor, wherein the multi-branch concurrent compilation program, when executed by the processor, implements the steps of the multi-branch concurrent compilation method.

[0016] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a multi-branch concurrent compilation program, wherein the multi-branch concurrent compilation program, when executed by a processor, implements the steps of the multi-branch concurrent compilation method.

[0017] The technical scheme provided by the embodiment of the present application has the following beneficial effects: By constructing a compilation unit with a source file and its directly dependent header files, a directed acyclic graph is formed by parsing the circular dependency to establish a file-level dependency graph between the compilation units; an independent primary cache folder is created for a source branch to store its local merged compilation cache, and a corresponding secondary cache folder is created for a target branch requested by the source branch to store the compilation cache after the merging of the target branch is completed; when the source branch triggers compilation for the first time, the compilation cache of the target branch secondary cache folder is located and obtained, and when the same source branch triggers compilation again, the compilation cache is directly obtained from the primary cache folder of the source branch; based on the file-level dependency graph, a set of units to be compiled is determined, and incremental compilation is performed according to the obtained compilation cache, and the compilation result is stored in the primary cache folder of the source branch.

[0018] Therefore, by decomposing the compilation granularity to the file level and establishing a file-level dependency graph, and combining the multi-level cache mechanism of the primary cache and the secondary cache, the application realizes significant efficiency improvement in the intelligent driving multi-branch concurrent development scene: the first compilation time is greatly shortened, and the secondary submission compilation hit rate is also greatly improved, effectively solving the core problems of low cache precision hit rate and long first compilation time in multi-branch concurrency, and ensuring real-time collaborative optimization of modules with complex dependency relationships. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 A multi-branch concurrent compilation run graph; Figure 2 A multi-branch concurrent compilation cache occupancy graph; Figure 3 A flowchart of an embodiment of the multi-branch concurrent compilation method of the application; Figure 4 A structural block diagram of single source file compilation of the application; Figure 5 A schematic diagram of the directed acyclic graph formed by the application; Figure 6 A multi-level compilation cache usage flowchart of the application; Figure 7 A scheduling flowchart when MR open of the application; Figure 8 A scheduling flowchart when MR merged of the application; Figure 9 A functional module schematic diagram of an embodiment of the multi-branch concurrent compilation device of the application; Figure 10 A hardware structure schematic diagram of the multi-branch concurrent compilation device involved in the embodiment scheme of the application. DETAILED DESCRIPTION

[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0022] In a first aspect, embodiments of this application provide a multi-branch concurrent compilation method.

[0023] In one embodiment, reference is made to Figure 3 , Figure 3 This is a flowchart illustrating the first embodiment of the multi-branch concurrent compilation method of this application. Figure 3 As shown, multi-branch concurrent compilation methods include: S1. The source files and their directly dependent header files are formed into compilation units. A directed acyclic graph is formed by resolving circular dependencies to establish a file-level dependency graph between compilation units. It's worth noting that traditional compilation systems use dynamic or static libraries as the smallest compilation unit, while this embodiment decomposes the compilation granularity to the file level. Each source file (e.g., .cc / .cpp) and its directly dependent header files constitute an atomic compilation unit, and a file-level dependency graph is established through static code analysis. See also... Figure 4 As shown, the compilation of a single source file includes a single compiled source file, a single compiled header file, and the dependency files that support the compilation of that source file.

[0024] To establish a file-level dependency graph, the key lies in the circular dependency resolution algorithm: when file A depends on file B and B inversely depends on A, the system automatically extracts common dependencies to generate an interface layer, transforming the circular dependency into a tree structure. This process is achieved through the following steps: Step 1: Construct a global symbol reference matrix to identify cross-file call chains; Step 2: Perform topological sorting on the strongly connected components (SCCs) and extract the common symbol table; Step 3: Generate intermediate interface files (.ii format) to isolate bidirectional dependencies; Step 4: Refactor the compiler unit dependencies to point to the interface file.

[0025] The following is an example of a perception module and decision module in intelligent driving: Step 1, find all "rings" (construct symbol reference relationship matrix) Scan all files to establish a global symbol relationship table, such as: (perception module) camera_detector.cc calls (decision module) path_planner.cc, and path_planner.cc calls camera_detector.cc.

[0026] Step 2, break the ring into a tree (SCC topological sorting + common symbol table) Identify all files in the ring (strongly connected component SCC: camera_detector.cc + path_planner.cc).

[0027] Extract common symbols: extract common interfaces (such as get_bbox(), update_params()) in the ring.

[0028] Topological sorting: turn the ring into a tree (such as: perception module → interface file → decision module).

[0029] Step 3, generate intermediate interface files (.ii format) Create an.ii file (such as camera_detector.ii), which only writes the declaration of the common symbol, isolating the bidirectional dependency.

[0030] As a result, the perception module now only depends on camera_detector.ii (no longer directly depends on path_planner.cc). The decision module now only depends on camera_detector.ii (no longer directly depends on camera_detector.cc).

[0031] Step 4: Reconstruct the dependency chain (point to the interface file) Modify the dependency relationship of all files to point to the interface file (.ii) instead of the original file.

[0032] As a result, the original ring dependency chain: camera_detector.cc → path_planner.cc → camera_detector.cc; becomes a tree-shaped dependency chain: camera_detector.cc → camera_detector.ii; path_planner.cc -> camera_detector.ii.

[0033] After this process, see Figure 5 As shown in the figure, all compilation units form a strict Directed Acyclic Graph (DAG), and the nodes represent file-level compilation units, and the edges represent dependency relationships. This structure significantly improves the efficiency of incremental compilation: when file X is modified, the dependency graph traversal algorithm (based on DFS (Depth-First Search) and topological sorting) accurately marks the affected node set, and only triggers the recompilation of directly / indirectly dependent units. Tests show that in a million-line code-level project, file-level granularity significantly reduces the amount of invalid compilation compared to module-level compilation, and the compilation time is also greatly reduced.

[0034] S2, create an independent master cache folder for the source branch to store its local merged compilation cache, and create a corresponding secondary cache folder for the target branch requested by the source branch to store the compilation cache after the merging of the target branch is completed; S3, when the source branch triggers compilation for the first time, locate and obtain the compilation cache of its target branch secondary cache folder, and when the same source branch triggers compilation again, directly obtain the compilation cache from its master cache folder; S4, determine the set of units to be compiled based on the file-level dependency graph, and perform incremental compilation according to the obtained compilation cache, and store the compilation result to the master cache folder of the source branch.

[0035] Specifically, during the Jenkins running process, when the source branch is compiled for the first time, the base version is loaded from the master branch cache through differential binary analysis technology, and only the newly added / modified files are compiled, improving the efficiency of the first compilation of the branch. The cache information of this compilation is stored in the Jenkins server mounting directory according to the branch, and when the code of the branch is submitted again, the cache in the mounting directory can be quickly hit, greatly improving the compilation time. When the master branch is merged, cache reconstruction is performed asynchronously to keep the cache baseline synchronized; in the Jenkins environment, this scheme shortens the first compilation time of the branch by 78% when multiple branches are parallel, and the second submission compilation hit rate reaches 93%. The specific process is shown in Figure 6 .

[0036] During the running of Jenkins, after the source branch undergoes local merging, a master cache folder is created according to the source branch of the merging request, and it is simultaneously found whether there is a secondary cache folder, if the secondary cache folder exists, the cache information of the secondary cache folder is read for compilation, and after the compilation, the cache information is written into the master cache folder. The master cache folder stores the compilation cache after the local merging of the source branch, and the secondary cache folder stores the compilation cache information (i.e. the latest target branch cache information) after the actual merging of the source branch into the target branch (master branch).

[0037] Referring to Figure 7 As shown in FIG. 6, it is a scheduling process when MR open (Merge Request open, the merging request is created but not merged). When multiple branches are triggered at the same time, multiple master cache folders are created according to the branch names, and when multiple source branches are triggered for compilation at the same time, the system processes each source branch independently, and checks the secondary cache folder of the target branch corresponding to the source branch. Each secondary cache folder has a file indicating the state: idle, occupied, and abandoned. When a file that is not abandoned is traversed, the cache information in this cache folder is directly read for construction, at this time, the state of the hit secondary cache folder is rewritten to occupied (if the initial state is idle), and a merging request ID file corresponding to the hit folder is created, and when the compilation ends, the merging request ID file in the hit folder is deleted. When there is no merging request ID file under the secondary cache directory, the secondary cache directory is marked as idle, and when the secondary cache directory is continuously used for more than 4 hours, the state is set to abandoned. The abandoned folder will be cleaned up when the Jenkins is triggered next time.

[0038] Referring to Figure 8 As shown in FIG. 7, it is a scheduling process when MR merged (Merge Request merged, the merging request has been successfully merged). When the source branch information is merged into the target branch, it is judged whether the master cache directory (master cache folder) corresponding to the source branch exists, if not, it is directly ended, if yes, the secondary cache directory is updated with the master cache directory, and after the update, the master cache directory is deleted. That is, after the source branch is merged into the target branch, the cache of the source branch is updated into the cache of the target branch, to ensure that the cache of the target branch contains the latest optimization (such as the perception optimization result), and the master cache directory of the source branch is cleaned up to avoid redundancy.

[0039] To sum up, the application forms a compilation unit by taking a source file and a header file directly dependent thereon, forms a directed acyclic graph by analyzing circular dependency to establish a file-level dependency graph between compilation units, creates an independent main cache folder for a source branch to store a local merged compilation cache, and creates a corresponding secondary cache folder for a target branch requested by the source branch to store a compilation cache after merging of the target branch is completed, locates and acquires the compilation cache of the target branch secondary cache folder when the source branch triggers compilation for the first time, directly acquires the compilation cache from the main cache folder of the source branch when the source branch triggers compilation again, determines a set of units to be compiled based on the file-level dependency graph, and performs incremental compilation according to the acquired compilation cache and stores the compilation result to the main cache folder of the source branch.

[0040] Therefore, by decomposing the compilation granularity to the file level and establishing a file-level dependency graph, and in combination with the multi-level cache mechanism of the main cache and the secondary cache, the application achieves significant efficiency improvement in the intelligent driving multi-branch concurrent development scenario: the first compilation time is greatly shortened, the second submission compilation hit rate is also greatly improved, the core problems of low cache precision hit rate and long first compilation time in multi-branch concurrency are effectively solved, and real-time collaborative optimization of modules with complex dependency relationships is ensured.

[0041] In a second aspect, an embodiment of the application further provides a multi-branch concurrent compilation device.

[0042] In an embodiment, referring to Figure 9 , Figure 9 FIG. 1 is a schematic diagram of functional modules of an embodiment of the multi-branch concurrent compilation device of the application. As shown in FIG. 1, the multi-branch concurrent compilation device comprises: Figure 9 a compilation control module configured to form a compilation unit by taking a source file and a header file directly dependent thereon, and form a directed acyclic graph by analyzing circular dependency to establish a file-level dependency graph between compilation units; a cache module configured to create an independent main cache folder for a source branch to store a local merged compilation cache, and create a corresponding secondary cache folder for a target branch requested by the source branch to store a compilation cache after merging of the target branch is completed; a scheduling module configured to locate and acquire the compilation cache of the target branch secondary cache folder when the source branch triggers compilation for the first time, and directly acquire the compilation cache from the main cache folder of the source branch when the source branch triggers compilation again; The scheduling module is further configured to determine a set of units to be compiled based on the file-level dependency graph, perform incremental compilation according to the acquired compilation cache, and store the compilation result to the main cache folder of the source branch.

[0043] ​Furthermore, in one embodiment, the compilation control module establishes a file-level dependency graph between compilation units by resolving circular dependencies to form a directed acyclic graph, including: Construct a global symbol reference matrix to identify cross-file call chains; The identified strongly connected components are topologically sorted, and a common symbol table is extracted. An intermediate interface file is generated based on the public symbol table to isolate bidirectional dependencies; The dependencies of the compilation units are restructured so that they point to the intermediate interface file, forming a directed acyclic graph to establish a file-level dependency graph between compilation units.

[0044] Further, in one embodiment, the scheduling module determines the set of units to be compiled based on the file-level dependency graph, and performs incremental compilation according to the obtained compilation cache, including: When a modification to the source file is detected, the file-level dependency graph is traversed, and the affected direct and indirect dependent nodes are marked using a depth-first search and topology sorting algorithm. Recompilation is triggered only for the compilation units corresponding to the affected nodes.

[0045] Furthermore, in one embodiment, the caching module is also used for: When the source branch is merged into the target branch, an asynchronous cache rebuild task is triggered for that target branch to generate a new build cache and update it to the corresponding sub-cache folder.

[0046] Furthermore, in one embodiment, the secondary cache folder includes a file representing a state, the state including free, occupied, and abandoned; When the cache folder is idle, read the cache information in it as the compilation cache and change its status from idle to occupied.

[0047] Furthermore, in one embodiment, the scheduling module is also used for: Create a corresponding merge request ID file in the hit secondary cache folder. Delete the merge request ID file in the hit secondary cache folder when compilation ends. If there is no merge request ID file in the secondary cache folder, mark the secondary cache folder as idle.

[0048] Furthermore, in one embodiment, the scheduling module is also used for: If a cache folder remains occupied for an extended period of time beyond a preset threshold, its status will be marked as obsolete.

[0049] The functions of each module in the multi-branch concurrent compilation device correspond to the steps in the multi-branch concurrent compilation method embodiment, and their functions and implementation processes will not be described in detail here.

[0050] Thirdly, embodiments of this application provide a multi-branch concurrent compilation device, which can be a personal computer (PC), laptop computer, server, or other device with data processing capabilities.

[0051] Reference Figure 10 , Figure 10 This is a schematic diagram of the hardware structure of the multi-branch concurrent compilation device involved in the embodiments of this application. In the embodiments of this application, the multi-branch concurrent compilation device may include a processor, a memory, a communication interface, and a communication bus.

[0052] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.

[0053] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting devices within a multi-branch concurrent compilation device, as well as interfaces used for interconnecting the multi-branch concurrent compilation device with other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.

[0054] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.

[0055] The processor can be a general-purpose processor, which can call a multi-branch concurrent compiler stored in memory and execute the multi-branch concurrent compilation method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the multi-branch concurrent compiler is called can be referred to in the various embodiments of the multi-branch concurrent compilation method of this application, and will not be repeated here.

[0056] Those skilled in the art will understand that Figure 10 The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0057] Fourthly, embodiments of this application also provide a computer-readable storage medium.

[0058] This application stores a multi-branch concurrent compiler on a computer-readable storage medium, wherein when the multi-branch concurrent compiler is executed by a processor, it implements the steps of the multi-branch concurrent compilation method as described above.

[0059] The method implemented when the multi-branch concurrent compiler is executed can be referred to in the various embodiments of the multi-branch concurrent compilation method of this application, and will not be repeated here.

[0060] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0061] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.

[0062] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.

[0063] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.

[0064] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0065] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.

[0066] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method of poly-branch concurrent compilation, the method comprising: The multi-branch concurrent compilation method comprises: forming a compilation unit by taking a source file and a header file directly dependent thereon, forming a directed acyclic graph by analyzing circular dependency to establish a file-level dependency graph between compilation units; creating an independent main cache folder for a source branch to store its local merged compilation cache, and creating a corresponding secondary cache folder for a target branch requested to be merged by the source branch to store the compilation cache after the target branch is merged; locating and obtaining the compilation cache of the target branch secondary cache folder when the source branch triggers compilation for the first time, and directly obtaining the compilation cache from the main cache folder of the source branch when the source branch triggers compilation again; determining a set of compilation units to be compiled based on the file-level dependency graph, and performing incremental compilation according to the obtained compilation cache, and storing the compilation result to the main cache folder of the source branch.

2. The polybranch concurrent compilation method of claim 1, wherein, The forming a directed acyclic graph by analyzing circular dependency to establish a file-level dependency graph between compilation units comprises: building a global symbol reference relationship matrix to identify a cross-file call chain; topologically sorting the identified strongly connected components, and extracting a common symbol table; generating an intermediate interface file based on the common symbol table to isolate bidirectional dependency; reconstructing the dependency relationship of the compilation unit to point to the intermediate interface file, forming a directed acyclic graph to establish a file-level dependency graph between compilation units.

3. The polybranch concurrent compilation method of claim 1, wherein, The determining a set of compilation units to be compiled based on the file-level dependency graph, and performing incremental compilation according to the obtained compilation cache comprises: when a source file is modified, traversing the file-level dependency graph, and using a depth-first search and a topological sorting algorithm to mark affected direct and indirect dependency nodes; only triggering recompilation for the compilation units corresponding to the affected nodes.

4. The multi -branch concurrent compilation method of claim 1, wherein, Further comprising: after the source branch is merged into the target branch, asynchronously triggering a cache reconstruction task for the target branch to generate new compilation cache and update to the corresponding secondary cache folder.

5. The multi-branch concurrent compilation method of claim 1, wherein: the secondary cache folder comprises a file indicating a state, and the state comprises idle, occupied, and abandoned; when the state of the secondary cache folder is idle, reading the cache information therein as compilation cache, and modifying the state thereof from idle to occupied.

6. The polybranch concurrent compilation method of claim 5, wherein, Further comprising: creating a merge request ID file corresponding to the hit secondary cache folder, deleting the merge request ID file in the hit secondary cache folder when the compilation ends, and marking the secondary cache folder as idle when there is no merge request ID file under the secondary cache folder.

7. The polybranch concurrent compilation method of claim 5, wherein, Further comprising: if the primary cache folder remains in the occupied state and exceeds a preset threshold time, marking the state thereof as abandoned.

8. A multi-branch concurrent compilation apparatus, characterized by, The multi-branch concurrent compilation device comprises: a compilation control module configured to form a compilation unit by taking a source file and a header file directly dependent thereon, form a directed acyclic graph by analyzing circular dependency to establish a file-level dependency graph between compilation units; a cache module configured to create an independent primary cache folder for a source branch to store its local merged compilation cache, and create a corresponding secondary cache folder for a target branch requested to be merged by the source branch to store the compilation cache after the target branch is merged; a scheduling module configured to locate and acquire the compilation cache of the target branch secondary cache folder when the source branch triggers compilation for the first time, and directly acquire the compilation cache from the primary cache folder of the source branch when the source branch triggers compilation again; the scheduling module is further configured to determine a set of units to be compiled based on the file-level dependency graph, perform incremental compilation according to the acquired compilation cache, and store the compilation result to the primary cache folder of the source branch.

9. A multi-branch concurrent compilation device, characterized by, The multi-branch concurrent compilation device comprises a processor, a memory, and a multi-branch concurrent compilation program stored on the memory and executable by the processor, wherein the multi-branch concurrent compilation program, when executed by the processor, implements the steps of the multi-branch concurrent compilation 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 a multi-branch concurrent compilation program, wherein the multi-branch concurrent compilation program, when executed by the processor, implements the steps of the multi-branch concurrent compilation method according to any one of claims 1 to 7.