Configuration method of compilation environment, compilation method, device, equipment and storage medium
By pre-configuring frequently used code branches or allocating storage space to configure the code environment in the compilation machine, the problem of long code environment preparation time in traditional compilation is solved, thus improving compilation efficiency.
Patent Information
- Application Number
- CN202110295050.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-19
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2041-03-19
AI Technical Summary
In traditional compilation processes, code branches need to be switched frequently before each compilation task, resulting in excessively long code environment preparation time before compilation begins and low compilation efficiency.
By obtaining statistical data on the code branches corresponding to the compilation task within the first time period, the popularity of each code branch is determined, and the code branches with higher popularity are pre-configured in the code environment of the compilation machine, or the storage space is divided into several sub-storage spaces and the code environment of a code branch is pre-configured in each sub-storage space.
It reduces the code environment preparation time before compilation begins, improves compilation efficiency, especially when the number of compilation machines is less than the number of code branches, avoids frequent code branch switching, and improves the processing speed of compilation tasks.
Smart Images

Figure CN115113853B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a configuration method of a compiling environment, a compiling method, a device, an equipment and a storage medium. BACKGROUND
[0002] Compiling refers to converting an object file in a certain language into a target program in binary language, so that the target program can be recognized and executed by a machine, such as compiling of an application installation file. A compiling task is generally executed on a compiling machine. Due to the complexity of the compiling code and the difference of the version functions, the compiling task can correspond to different code branches, and therefore, each time of compiling needs to switch to a corresponding code branch first, and then the compiling task can be executed. The traditional method is that before each time of starting a compiling task, the compiling machine executes the logic of switching the code branch, and after the switching of the code branch is completed, the compiling is started. However, the switching of the code branch needs to spend a certain time, especially when the compiling task and the code branch are more, each time of compiling needs to frequently switch the compiling machine to the desired code branch (i.e. the target code branch) to start the compiling, which causes that the code environment preparation time before the compiling is started is too long, and the compiling efficiency is low. SUMMARY
[0003] The embodiment of the present application provides a configuration method of a compiling environment, a compiling method, a device, an equipment and a storage medium, so as to reduce the code environment preparation time before the compiling is started, and improve the compiling efficiency.
[0004] The embodiment of the present application provides a configuration method of a compiling environment, a compiling method, a device, an equipment and a storage medium, so as to reduce the code environment preparation time before the compiling is started, and improve the compiling efficiency.
[0005] Obtaining statistical data of all code branches corresponding to a compiling task in a first time period;
[0006] Determining the heat of each code branch according to the statistical data;
[0007] Obtaining a target configuration code branch from each code branch according to the heat, and pre-configuring the target configuration code branch into a code environment of a compiling machine, wherein the target configuration code branch is the code branch which is ranked before a first threshold according to the heat from large to small; or the target configuration code branch is the code branch which is ranked after a second threshold according to the heat from small to large.
[0008] Storing the corresponding relationship between the target configuration code branch and the compiling task into the compiling machine.
[0009] The embodiment of the present application provides a configuration method of a compiling environment, a compiling method, a device, an equipment and a storage medium, so as to reduce the code environment preparation time before the compiling is started, and improve the compiling efficiency.
[0010] dividing the storage space of each compiling machine into a plurality of sub-storage spaces;
[0011] pre-configuring a code environment of a code branch in each of the sub-storage spaces.
[0012] Another aspect of the embodiment of the present application provides a compiling method, comprising the following steps:
[0013] in response to a compiling instruction, obtaining a code environment of a target compiling branch from a code environment of a compiling machine, the code environment of the compiling machine being obtained by the pre-configuration method mentioned above, the target compiling branch being a code branch corresponding to a target compiling task in the compiling instruction;
[0014] executing the target compiling task by using the code environment of the target compiling branch.
[0015] Another aspect of the embodiment of the present application provides a configuration device of a compiling environment, comprising:
[0016] an obtaining module, configured to obtain statistical data of all code branches corresponding to a compiling task within a first time period;
[0017] a hotness determining module, configured to determine the hotness of each of the code branches according to the statistical data;
[0018] a determining and pre-configuring module, configured to obtain a target configuration code branch from each of the code branches according to the hotness, and pre-configure the target configuration code branch into a code environment of a compiling machine, wherein the target configuration code branch is the code branch ranked before a first threshold according to the hotness from large to small; or the target configuration code branch is the code branch ranked after a second threshold according to the hotness from small to large;
[0019] a storage module, configured to store a corresponding relationship between the target configuration code branch and the compiling task into the compiling machine.
[0020] Optionally, the code environment comprises a first branch code environment group and a standby branch code environment, the first branch code environment group comprises the first threshold number or the second threshold number of the target configuration code branches,
[0021] The configuration device further comprises a target compiling branch determining module, which is configured to perform one of the following:
[0022] selecting a code branch corresponding to the current compiling task from the first branch code environment group as a target compiling branch;
[0023] Or, when the first branch code environment group does not exist the code branch corresponding to the current compilation task, obtaining the code branch corresponding to the current compilation task from the prepared branch code environment as a target compilation branch.
[0024] Optionally, the first time period is determined by one of the following steps:
[0025] An initial value of the first time period is obtained, and the first time period is determined according to the initial value and an update parameter, the update parameter including at least one of an update time or an update frequency;
[0026] Or, an idle time period of the compiling machine is obtained, and the idle time period is determined as the first time period, wherein the compiling machine does not execute the compilation task in the idle time period.
[0027] Optionally, the statistical data includes a compilation frequency of the code branch, and the obtaining module is specifically configured to:
[0028] The compilation frequency of all code branches corresponding to the compilation task in the first time period is obtained.
[0029] Optionally, the compilation frequency is represented by any one of a compilation number of the code branch or a user number of the code branch, and the obtaining of the compilation frequency of all code branches corresponding to the compilation task in the first time period includes:
[0030] A compilation number of all code branches corresponding to the compilation task in the first time period is obtained, and the compilation frequency is obtained according to the compilation number;
[0031] Or, a user number of all code branches corresponding to the compilation task in the first time period is obtained, and the compilation frequency is obtained according to the user number.
[0032] Optionally, the heat determination module is specifically configured to:
[0033] All the statistical data are sorted, and the heat of each code branch is obtained according to a sorting result;
[0034] Or, the heat of each code branch is obtained from a first corresponding relationship table according to the statistical data, the first corresponding relationship table being a pre-set corresponding relationship table between statistical data and heat;
[0035] Or, the statistical data is substituted into a pre-set or established function expression between statistical data and heat, and the heat of each code branch is calculated;
[0036] Or, according to the statistical data, a fitting curve between the statistical data and the hotness obtained by pre-fitting is used to fit the hotness of each code branch.
[0037] Or, according to the statistical data, the compilation frequency of each code branch is obtained, and then the hotness of each code branch is determined according to the compilation frequency.
[0038] Optionally, the compiling machines are multiple, and the determining and pre-configuration module specifically comprises:
[0039] A compiling code parameter acquisition unit is configured to acquire corresponding compiling code parameters from the compiling task, wherein the compiling code parameters comprise software code parameters and code branch parameters corresponding to the target configuration code branch.
[0040] A software code acquisition unit is configured to acquire corresponding software code from a code repository according to the software code parameters.
[0041] A target configuration code branch unit is configured to acquire the target configuration code branch from the software code according to the code branch parameters.
[0042] A storage unit is configured to store the target configuration code branch into a code environment of a compiling machine.
[0043] Another aspect of the embodiment of the present application provides a configuration device of a compiling environment, comprising:
[0044] A division module is configured to divide the storage space of each compiling machine into a plurality of sub-storage spaces.
[0045] A pre-configuration module is configured to pre-configure a code environment of a code branch in each sub-storage space.
[0046] Another aspect of the embodiment of the present application provides an electronic device, comprising a processor and a memory.
[0047] The memory stores a program.
[0048] The processor implements the configuration method or the compiling method as described above when executing the program.
[0049] Another aspect of the embodiment of the present application provides a storage medium, which stores a program, and the program is executed by a processor to implement the configuration method or the compiling method as described above.
[0050] When the number of compiling machines is less than the number of code branches, the statistical data of all code branches corresponding to each compiling task in a first time period is obtained, and then the heat of each code branch is determined according to the statistical data; and then the code branches with high heat are selected as target configuration code branches according to the heat ranking result of each code branch, and the target configuration code branches are pre-configured into the code environment of the compiling machine. According to the statistical data of the code branches, the heat of each code branch is obtained, and then the code branches with high heat are pre-configured into the code environment of the compiling machine based on the heat, so that the code branches with high heat can be directly compiled without switching the code branches, the code environment preparation time before the compilation is effectively reduced, and the compiling efficiency is improved.
[0051] In the embodiment of the present application, the storage space of each compiling machine is divided into a plurality of sub-storage spaces, and then the code environment of a code branch is pre-configured in each sub-storage space. By pre-configuring the code environment of the code branch in the sub-storage space, a plurality of code environments of each compiling machine are prepared in advance, so that the code branch required by the compiling task can hit one of the plurality of code environments prepared in advance on the compiling machine, without switching the code branch, the code environment preparation time before the compilation is effectively reduced, and the compiling efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0053] Figure 1 Correspondence diagram of compiling machines and code branches when the number of compiling machines is greater than the number of code branches;
[0054] Figure 2 Correspondence diagram of compiling machines and code branches when the number of compiling machines is less than the number of code branches;
[0055] Figure 3 An implementation environment diagram of the configuration scheme of the compiling environment in the embodiment of the present application;
[0056] Figure 4 Another implementation environment diagram of the configuration scheme of the compiling environment in the embodiment of the present application;
[0057] Figure 5 A flowchart of the configuration method of the compiling environment provided by the embodiment of the present application;
[0058] Figure 6 A specific flow chart of the step of determining the hotness of each code branch according to statistical data in the embodiment of the present application Figure 5
[0059] Figure 7 A page schematic diagram for obtaining software code and target configuration code branch in the embodiment of the present application
[0060] Figure 8 A specific application example flow chart of the configuration method of the compiling environment in the embodiment of the present application Figure 5
[0061] Figure 9 Another implementation flow chart of the configuration method of the compiling environment provided by the embodiment of the present application
[0062] Figure 10 A specific flow chart of the step of pre-configuring a code environment of a code branch in each sub-storage space in the embodiment of the present application Figure 9
[0063] Figure 11 A flow chart of a compiling method provided by the embodiment of the present application
[0064] Figure 12 A structure schematic diagram of the configuration device of the compiling environment provided by the embodiment of the present application
[0065] Figure 13 Another structure schematic diagram of the configuration device of the compiling environment provided by the embodiment of the present application
[0066] Figure 14 A structure schematic diagram of an electronic device provided by the embodiment of the present application DETAILED DESCRIPTION
[0067] In order to make the personnel in the technical field better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the personnel in the field without making creative efforts should belong to the protection scope of the present application.
[0068] The terms "first", "second", "third", and "fourth" and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily described in a particular order. Furthermore, the terms "comprising", "having", "including" or "containing" and any variations thereof are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that comprises, has, includes or contains an item or list of items does not require that every single item in the item or list is included, but rather that at least the specified item or at least a substantial number of the listed items are included.
[0069] Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of the application. The appearances of the phrase "in an embodiment" in various places in the specification are not necessarily referring to the same embodiment, nor are they necessarily mutually exclusive of one another. It is expressly understood that any of the embodiments described herein can be combined with any of the other embodiments.
[0070] Firstly, the related terms involved in the embodiments of the present application are introduced and explained:
[0071] Code: is the source file written by programmers with the language supported by development tools, which is a set of explicit rules represented by characters, symbols or signal code elements in discrete form. The principles of code design include unique certainty, standardization and universality, expandability and stability, easy identification and memory, shortness and format uniformity, and easy modification. Source code is a kind of code. In a certain sense, source code is equivalent to code. In modern programming languages, source code can appear in the form of books or tapes, but the most commonly used format is text file. The purpose of this typical format is to compile computer programs. The ultimate goal of computer source code is to translate human-readable text into computer-executable binary instructions. This process is called compilation, which is completed through a compiler. Code is the core asset of software development. Because the software development process is long and requires the cooperation of multiple people, the development team of software development usually chooses a reliable code processing tool to manage and control the version of code. For example, the reliable code processing tool can use Git (a kind of open source distributed version control system).
[0072] For a software development project, a development team can create a code processing project for code management, and members of the development team can create code branches through Git in the code processing project of the development team to which the members belong, develop codes, release versions, repair defects, etc. on different code branches to realize code isolation. For example, the code branches can be Git branches, and the code branches include feature branches, release branches, and defect repair branches, etc. Among them, the feature branches are used for code development, the release branches are used for version release and online, and the defect repair branches are used for defect repair. After the members of the development team complete code development on the feature branches or defect repair on the defect repair branches, the members can merge the codes on the feature branches or the defect repair branches to the release branches to ensure that the codes for release and online are stable, clean and reliable.
[0073] Generally, the code of each application or two-party library includes master, develop, release, hotfix, feature, etc. code branches, wherein the naming rules of the release and hotfix branches are release-* and hotfix-*, respectively; the naming of the feature branch can use any name except master, develop, release-*, hotfix-*, etc.; and the use methods of the branches are as follows:
[0074] Master branch:
[0075] The master and develop branches are master branches, and the master branches are core branches of all development activities. The outputs generated by all development activities will eventually be reflected in the codes of the master branches. The master branch stores codes that can be deployed in a production environment at any time (Production Ready state). When the development activities are completed, a new deployable code is generated, and the code on the master branch is updated. At the same time, each update has a corresponding version number tag (TAG).
[0076] Develop branch:
[0077] The develop branch is the branch where the current development is saved. Usually the code on this branch is also the code that can be built nightly. So this branch can also be called the "integration branch". When the code on the develop branch has implemented all the features in the software requirements specification, passed all the tests, and the code is stable enough, all the development can be merged back to the master branch. It is recommended that a new version number tag (TAG) is applied to the new commit on the master branch for the subsequent code.
[0078] The release branch:
[0079] The release branch is designed for releasing a new product version. The code on this branch allows small bug fixes and preparation of the release version (version number, release date, compile date, etc.). By doing this on the release branch, the develop branch is free to accept code from new feature branches and start a new software development iteration. The release branch can be derived from the develop branch and must be merged back to the develop and master branches.
[0080] The hotfix branch:
[0081] The hotfix branch is very similar to the release branch except that it is created unplanned: it can produce a new software version that can be deployed in production. When an exception occurs in the production environment or a serious bug is found that must be fixed immediately, a hotfix branch is derived from the specified TAG version on the master branch to organize the emergency fix. The hotfix branch can be derived from the master branch and must be merged back to the master and develop branches.
[0082] The feature branch:
[0083] The feature branch (sometimes also called "topic branch") is usually used when a new software feature is developed. The code changes on this branch are eventually merged back to the develop branch or discarded (e.g. experimental and not effective code changes). Generally, the feature branch code can be saved in the developer's own repository without being forced to commit to the main repository. The feature branch can be derived from the develop branch and must be merged back to the develop branch.
[0084] Code environment of the code branch: the environment in which the code branch is located, corresponding to the type of task to be executed by the code branch or the function to be implemented. For example, if the type of task to be executed by the code branch is a compilation task, then the code environment of the code branch is a corresponding compilation code environment. At this time, the code environment of the code branch refers to each storage space in the compilation machine that can be used to store different code branches. For another example, if the type of task to be executed by the code branch is a release task, then the code environment of the code branch is a corresponding release code environment.
[0085] In the related art, due to the complexity of the compilation code and the difference in the version function, different code branches may correspond to different compilation tasks. Before each compilation, the compilation machine needs to be switched to the corresponding code branch to start the compilation, which requires a certain amount of time to switch the code branch before the compilation, resulting in a long code environment preparation time before the compilation and low compilation efficiency. Figure 1 As shown in FIG. 1, if the number of compilation machines is greater than the number of code branches, then as long as each compilation machine is pre-configured with a type of code branch, all code branches of the compilation task can be covered. In this way, when each compilation task is executed, the corresponding code branch can be directly selected (i.e., the corresponding compilation machine is selected), and there is no need for code environment preparation time before the compilation starts, so that the compilation can be directly performed.
[0086] However, in actual work, due to the complexity of the compilation code and the difference in the version function, the number of code branches corresponding to the compilation task is often large, and the number of compilation machines that can be provided for daily compilation tasks is generally small, far less than the number of code branches, so that a type of code branch cannot be pre-configured on each compilation machine, and the code environment preparation time of the compilation machine is still long. Figure 2 As shown in FIG. 2, when the number of compilation machines is less than the number of code branches, the compilation machine needs to be switched to the corresponding code branch before each compilation to start the compilation, and the compilation efficiency is low. In order to better illustrate this point, it is assumed that there are 10 compilation machines that can be used for the compilation task, and the performance and concurrency of each compilation machine when performing the compilation task have reached the optimum. At this time, each compilation machine can only compile one compilation task at the same time at most. That is, 10 compilation machines can handle 10 compilation tasks at the same time at most. At this time, the related art will adopt the code environment configuration mode shown in Table 1:
[0087] Table 1 Code environment configuration mode of the related art
[0088]
[0089] In Table 1, compilation machines 1-10 are the names of these 10 compilation machines, with Master being the main code branch. As shown in Table 1, the code compiled by each compilation machine is in the code environment of the main code branch (Master) by default. However, the actual compilation task corresponds to a variety of sub-branches, up to 20 or more. It can be understood that the main code branch and sub-branches can be distinguished by version numbers, numerical identifiers, etc. Therefore, each time a compilation machine receives a compilation task, it needs to switch its code branch (i.e., code environment) from Master to the corresponding branch before it can begin actual compilation. Each branch switch takes time, so the problem of long code environment preparation time for the compilation machines persists.
[0090] Based on this, embodiments of this application provide a method for configuring a compilation environment, a compilation method, an apparatus, a device, and a storage medium. By pre-configuring the code environment in the compilation machine, the code environment required for most compilation tasks is extracted and prepared. This allows the compilation machine to directly target one of the pre-configured code environments as the target compilation environment when executing most compilation tasks, based on the code branch corresponding to the compilation task. This effectively reduces the waiting time of switching the compilation machine to the corresponding code branch before compilation and improves compilation efficiency. Specifically, the method of pre-configuring the code environment in the compilation machine in this application can include two types: a code environment configuration method based on popularity and a code environment configuration method based on storage space subdivision.
[0091] The basic implementation process of the popularity-based code environment configuration method is as follows: when the number of compilation machines is less than the number of code branches (e.g., Figure 2 In the scenario shown, firstly, statistical data for all code branches corresponding to each compilation task within the first time period is obtained. Then, the popularity of each code branch is determined based on this statistical data. Next, several code branches with higher popularity are identified as target configuration code branches, and these target configuration code branches are pre-configured in the compilation machine's code environment. This method utilizes statistical data of the code branches that may correspond to a compilation task to obtain the popularity of the code branches. Based on this popularity, several code branches with higher popularity are selected and pre-configured in the compilation machine's code environment. This ensures that the code environment of frequently used code branches with high popularity can be directly hit or selected during compilation without requiring code branch switching, effectively reducing the waiting time for the compilation machine to switch to the corresponding code branch, thereby improving compilation efficiency.
[0092] The code environment configuration method based on storage space subdivision is based on the idea of reasonably and maximally utilizing the storage space of the compiling machine. The basic implementation process is as follows: the storage space of each compiling machine is divided into a plurality of sub-storage spaces, and then a code environment of a code branch is pre-configured in each sub-storage space. In this way, a plurality of code environments can be pre-configured in the storage space of each compiling machine. Similarly, the corresponding code branch can be selected or hit during compilation to directly perform compilation, without the need to switch the code branch, effectively reducing the waiting time of the compiling machine switching to the corresponding code branch, thereby improving the compilation efficiency. The method can be applied to the case where the number of compiling machines is less than the number of code branches. It can be understood that, in addition to being applicable to the case where the number of compiling machines is less than the number of code branches, the method can also be applicable to the case where the number of compiling machines is greater than or equal to the number of code branches. That is, the method has no special requirements for the size relationship between the number of compiling machines and the number of code branches.
[0093] It should be noted that the scheme of pre-configuring a compiling environment in a compiling machine proposed in the embodiments of the present application can be applied to the compilation environment preparation of any application scenario code. For example, the compiling environment configuration scheme can be applied to the front-end compilation environment preparation of an application program or code development of a certain project. By applying the compiling environment configuration scheme, most of the code environments of the code branches that may be required by a compiling task can be prepared before compilation, which facilitates the selection or hitting of the code environment corresponding to the current compiling task from the prepared code environments for direct compilation according to the compiling task during subsequent compilation of the front end, reduces the preparation time of the code environment, and improves the compilation efficiency. For another example, the compiling environment configuration scheme can be applied to the back-end compilation environment preparation of an application program or code development of a certain project. By applying the compiling environment configuration scheme, most of the code environments of the code branches that may be required by a compiling task can be prepared before compilation, which facilitates the selection or hitting of the code environment corresponding to the current compiling task from the prepared code environments for direct compilation according to the compiling task during subsequent compilation of the back end, reduces the preparation time of the code environment, and improves the compilation efficiency.
[0094] The embodiment of the present application provides a configuration method of a compiling environment. The method can be applied in a terminal, or can be applied in a server, or can be applied in an implementation environment composed of the terminal and the server. In addition, the method can also be a software running in the terminal or the server, such as an application program with a compiling environment configuration function. The terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like, but is not limited thereto. The server can be a physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and basic cloud computing services such as big data and artificial intelligence platforms.
[0095] Figure 3 and Figure 4 are two implementation environment schematic diagrams of the configuration method of the compiling environment provided by the embodiment of the present application. The devices included in the two implementation environments are different, the functions of each device can also be different, and the steps performed by each device in the configuration method can also be different. The embodiment of the present application does not limit the specific implementation environment.
[0096] In a possible implementation manner, referring to Figure 3 , the implementation environment can include a computer device 101. The computer device 101 can have a direct compiling function and a function of receiving a compiling task and performing compiling. The computer device 101 can directly perform compiling (that is, the compiling task comes from the computer device 101 itself), or receive a compiling task and perform compiling according to the compiling task by selecting or hitting a corresponding code branch of the code environment from the code environment configured in advance by the embodiment of the present application (that is, the compiling task comes from outside the computer device 101). Figure 3 In the embodiment, a smart phone 1011, a tablet computer 1012, and a desktop computer 1013 are exemplary embodiments of the terminal, and 1014 is a server.
[0097] In another possible implementation manner, referring to Figure 4The implementation environment can include the computer device 101 and the compilation task sending device 102, which can have a compilation task sending function, and the computer device 101 can have a function of receiving a compilation task and performing compilation. The compilation task sending device 102 can obtain or trigger a compilation task through human-computer interaction such as key input, touch input, sound input, and send the compilation task to the computer device 101, so that the computer device 101 receives the compilation task and selects or hits the corresponding code branch code environment from the code environment configured in advance by the embodiment of the application. The compilation task sending device 102 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart bracelet, and the like, but is not limited thereto. Figure 4 Among them, the smart phone 1011, the tablet computer 1012, and the desktop computer 1013 are exemplary embodiments of terminals, and 1014 is a server; and the smart bracelet 1021 and the smart phone 1022 are exemplary embodiments of the compilation task sending device 102.
[0098] Those skilled in the art can understand that the computer device 101 can be a terminal or a server as long as it can perform compilation, and the embodiment of the application does not limit it.
[0099] Based on Figures 1-4 The structure and implementation environment shown, propose various embodiments of the configuration method of the compilation environment of the application.
[0100] Based on Figure 2 The number of compilation machines shown is less than the number of code branches, and the code environment configuration method based on the heat described above, the embodiment of the application proposes a configuration method of the compilation environment, which can reduce the code environment preparation time before compilation and improve the compilation efficiency. The method can be applied to Figure 3 Or Figure 4 The computer device 101 shown. As Figure 5 The configuration method can include the following steps S501-S504:
[0101] S501. Obtain statistical data of all code branches corresponding to the compilation task in the first time period.
[0102] In the embodiments of the present application, different code branches can correspond to different compilation tasks based on the complexity and version functions of the compiled code. In order to facilitate subsequent determination of the heat of each code branch to adapt to different compilation task requirements, the statistical data of the code branches, that is, the statistical data of all code branches corresponding to the compilation task in the first time period, can be obtained first. In step S501, the compilation task can be one or more. Considering the actual working situation and the accuracy and comprehensiveness of the compilation, the compilation task can be multiple compilation tasks, and each compilation task can correspond to at least one code branch.
[0103] In step S501, the statistical data can include the compilation frequency of the code branch, and the compilation frequency of the code branch can be obtained in combination with the usage of the code branch. Alternatively, the statistical data can be obtained by obtaining the names of all code branches corresponding to the compilation task and the usage of all code branches. Specifically, the usage includes the number of times each code branch appears (such as the number of times submitted by the compilation task) or the number of people using each code branch, for example, the number of times code branch A appears is 800 times, and the number of times code branch B appears is 700 times in the first time period; or the number of people using code branch A is 20, and the number of people using code branch B is 10. The first time period can be selected according to specific needs, which can be a week (i.e. seven days), half a month (15 days), a month (i.e. 30 days), 1 quarter (i.e. 90 days) or longer, or one day, 12 hours, 8 hours or shorter, which can be a continuous time period or a non-continuous time period. For example, the time period from Monday to Friday can be selected as the first time period, and then the usage data of the code branches in this time period is extracted, including the names of all code branches and the usage of all code branches, and then the extracted usage data of the code branches is counted.
[0104] It can be understood that, in order to make the heat determined subsequently more accurate and more in line with the actual code branch usage, the first time period can be updated continuously according to the actual usage of the code branch, so that the heat is dynamically updated through the dynamic updating of the first time, and then the target configuration code branch in the code environment of the compilation machine is also dynamically updated, so as to achieve the purpose of intelligently and dynamically allocating the code environment.
[0105] Alternatively, the first time period can be determined by any one of the following steps 1) or step 2):
[0106] 1) obtaining an update parameter and an initial value of the first time period, and determining the first time period according to the initial value and the update parameter, wherein the update parameter includes at least one of an update time or an update frequency.
[0107] Specifically, the initial value of the first time period can be pre-defined or selected by default as the time of the last update of the statistical data. The update time or update frequency can be pre-defined or set by the user. After obtaining the initial value of the first time period, the initial value of the first time period can be used as the starting point of the timing, and the update time or update frequency and the initial value of the first time period are combined to dynamically determine the first time period. For example, assuming that the update time or update frequency is to update the data every 2 days, and the initial value of the first time period is the time of the last update of the data, i.e., Monday, then the first time period can be determined as Monday to Wednesday.
[0108] 2) Obtain the idle time period of the compiling machine, and determine the idle time period as the first time period, wherein the compiling machine does not perform a compiling task in the idle time period.
[0109] In order not to affect the execution of the compiling task, the first time period can be updated in a time period that does not require compiling, i.e., an idle time period when the compiling machine does not perform a compiling task, such as 0:00 to 8:00 every day, or any other idle time period. Similarly, the first time period can be a continuous time period or a non-continuous time period; that is, the code branch data of 0:00 to 8:00 every day can be extracted and then counted, or the code branch data of multiple time periods such as 12:00 to 14:00, 17:00 to 19:00, and 22:00 to 24:00 every day can be extracted and then counted.
[0110] In the embodiment of the present application, the compiling machine can be implemented by using a computer device of Figure 3 or Figure 4 The data such as the usage of the code branch or the number of users can be stored in each compiling machine. In this way, when obtaining the statistical data of all code branches corresponding to the compiling task in the first time period, the data of the corresponding code branch can be first called by the compiling machine, and then the corresponding statistical data can be obtained by counting, so that more comprehensive and accurate statistical data can be conveniently obtained, thereby laying a foundation for accurately determining the heat of each code branch.
[0111] In the embodiment of the present application, when the statistical data includes the compiling frequency of the code branch, step 501 can be further divided into step S5011:
[0112] S5011. Obtain the compiling frequency of all code branches corresponding to the compiling task in the first time period.
[0113] Specifically, the higher the compiling frequency of the code branch, the higher the probability of using the code branch in the daily compiling task, and the higher the heat of the code branch.
[0114] It can be understood that the compiling frequency of the code branch can be obtained in various ways. For example, the compiling frequency of the code branch can be obtained by obtaining the number of times that all code branches appear in the compiling machine, the number of times that the code branches are used, or the number of times that the code branches are compiled in the first time period; or the compiling frequency of the code branch can be obtained by other ways, such as obtaining the number of people using the code branch. Therefore, step S5011 can obtain the compiling frequency of the code branch by the following step (1) or step (2):
[0115] (1) Obtain the compiling times of all code branches corresponding to the compiling task in the first time period, and obtain the corresponding compiling frequency according to the compiling times.
[0116] In the embodiment of the present application, the frequency is the number of times that an event repeats in a unit of time, and therefore the compiling frequency of the code branch refers to the number of times that the code branch is repeatedly compiled in a unit of time. The calculation method can be as follows: assuming that the first time period is T, and the total number of times that the code branch A appears in the compiling machine is N, then the compiling frequency of the code branch A is f : Similarly, the compiling frequencies of other code branches can also be obtained by the same calculation method, and the compiling frequencies of all code branches can be obtained in this way. It can be understood that when the first time period is fixed, that is, the time period T for obtaining the compiling times of all code branches is a fixed value, the compiling times of the code branch are positively correlated with the compiling frequency, and the compiling times of the code branch can directly reflect the compiling frequency.
[0117] (2) Obtain the number of people using all code branches corresponding to the compiling task in the first time period, and obtain the corresponding compiling frequency according to the number of people using the code branches.
[0118] In the embodiment of the present application, it is assumed that the default code branch is used once by one person each time it is compiled, and therefore the compiling frequency of the code branch can also be represented by the number of people using the code branch. At this time, when the first time period is fixed, that is, the time period for obtaining the number of people using all code branches is a fixed value, similarly to the compiling times, the more people using the code branch A, the higher the compiling frequency of the code branch A, and the compiling frequencies of other code branches can also be determined by obtaining the number of people using the code branches.
[0119] S502. Determine the hotness of each code branch according to the statistical data.
[0120] As described in the foregoing step S501, the statistical data can include all code branch names corresponding to the compilation task and all code branches are used, according to the statistical data, the heat of each code branch can be determined. Alternatively, the heat of each code branch can be reflected by the compilation frequency of the code branch, the higher the compilation frequency of the code branch, the greater the heat, and vice versa; and the compilation frequency of the code branch can be represented by the number of times or the number of people used by the code branch. For example, taking the number of times of the code branch as the compilation frequency of the code branch, the first time period is February 18, 2021, and the number of code branches corresponding to the compilation task is 17, for example, the use of each code branch is shown in Table 2.
[0121] Table 2 Use of code branches on February 18, 2021
[0122]
[0123] As can be seen from Table 2, the number of times each code branch is used and the relative heat, wherein the code branch v_3_1_2_branch is used 423 times, and the heat is the largest; and the code branch qy_web_group, the code branch yx_mail_filter, the code branch v_wxread_hospital_branch and the code branch app_grou are all used once, and the heat is the smallest.
[0124] It can be understood that the first time period selected here is February 18, 2021, when the first time period selected is other time periods, the statistical data can be displayed intuitively in a table similar to Table 2, or in the form of a graph such as a line graph, a histogram, etc. It can also be directly displayed in the form of text (for example: display the text "Code branch v_3_1_2_branch is used 423 times" and the like), which is not limited in the present application.
[0125] In the embodiments of the present application, after obtaining the statistical data of each code branch, the corresponding statistical data can be displayed intuitively in the form of a chart, and then the heat of each code branch can be determined.
[0126] In a possible implementation, after obtaining the statistical data of each code branch in step S502, step S502 can use step (1) or step (2) in step S5011 to determine the compilation frequency of each code branch, and then determine the corresponding hotness according to the compilation frequency. It can be understood that, when determining the corresponding hotness according to the compilation frequency, the compilation frequency can be directly used as the corresponding hotness value, or the compilation frequency can be substituted into a preset expression of the relationship between the compilation frequency and the hotness (for example, hotness = compilation frequency x 0.5) to calculate the corresponding hotness value, which is not limited in the present application.
[0127] In another possible implementation, after obtaining the statistical data of each code branch in step S502, a table lookup method, an expression substitution method or a fitting curve method can be used to obtain the corresponding hotness. In the table lookup method, the corresponding hotness can be obtained from a first corresponding relationship table between the statistical data and the hotness, which is set or established in advance, according to the statistical data of each code branch. In the expression substitution method, the statistical data of each code branch can be substituted into a function expression between the statistical data and the hotness, which is set or established in advance, to calculate the corresponding hotness. In the fitting curve method, the corresponding hotness can be obtained by fitting a fitting curve between the statistical data and the hotness, which is fitted in advance, according to the statistical data of each code branch.
[0128] In another possible implementation, after obtaining the statistical data of each code branch in step S502, the statistical data of each code branch can also be sorted, for example, as shown in Table 2, and step S502 can further include the following steps S5021-S5022: Figure 6
[0129] S5021. Sort the statistical data of all code branches.
[0130] It can be understood that, when sorting in step S5021, the sorting can be performed in ascending order or in descending order, which is not limited in the present application. For example, as shown in Table 2, the sorting can be performed in descending order of the number of uses (i.e. the number of compilations) of each code branch in the first time period.
[0131] S5022. Obtain the hotness of each code branch according to the sorting result.
[0132] After obtaining the statistical data sorting result of each code branch through step S5021, the embodiment of the present application can assign the heat of each code branch in turn according to the sorting result, so as to obtain the heat of each code branch. In a possible implementation manner, the statistical data with the maximum or minimum value can be obtained as a reference value according to the sorting result, and then the corresponding heat value (such as 1, 10, 100, 1000, etc.) of the reference value is assigned as a heat reference value, and the rest of the code branches can be calculated according to the relative size of the statistical data of the code branch and the reference value and the heat reference value.
[0133] It can be understood that, in addition to using the statistical data with the maximum or minimum value as the reference value to calculate the heat of the code branch, other sorting methods can also be used to determine the heat value of the code branch, for example, using a piecewise function, that is, when the statistical data of the code branch is in a certain first value interval (such as the first 3 statistical data in descending order), the first value (such as 100, 200, 10, etc.) can be assigned to the code branch, when the statistical data of the code branch is in a certain second value interval (such as the 4th to 6th statistical data in descending order), the second value (such as 50, 100, 5, etc.) can be assigned to the code branch, and so on, that is, the corresponding heat of each code branch can be obtained according to the sorting result.
[0134] S503. Obtain a target configuration code branch from each code branch according to the heat of each code branch, and pre-configure the target configuration code branch into the code environment of the compiling machine, wherein the target configuration code branch is all code branches ranked before a first threshold in descending order of heat, or the target configuration code branch is all code branches ranked after a second threshold in ascending order of heat.
[0135] In step S503, the compiling machine can use a computer device of Figure 3 or Figure 4 , and the code environment of the compiling machine can be a compiling environment of the code branch corresponding to the compiling task (that is, each storage space in the compiling machine that can be used to store different code branches).
[0136] It can be understood that the code branch with high heat is a commonly used code branch, and the possibility of being hit or selected by the compiling task is greater, and the number of compiling machines is limited, so the embodiment of the present application pre-configures the compiling machine to the commonly used code branch with high heat, so as to improve the probability of the pre-configured code environment being hit or selected by the compiling task, reduce the time of switching the code branch, and improve the compiling efficiency.
[0137] In step S503, the first threshold value or the second threshold value can be determined according to the code environment configurable by each compiling machine, and the first threshold value and the second threshold value can be equal or not equal in size, which is not limited in the present application. For example, the first threshold value can be 9 when the hot degrees are sorted in descending order, that is, the code branches with hot degrees ranked in the top 9 are selected as the target configuration code branches. If the statistical data is the statistical data in Table 2 at this time, the code branches v_3_1_2_branch, yx_dev_group, dsd2_group, qy_back_group, arch2_group, ira_bugfix, frankie_apply, app_member_auth and gll_bugfix with hot degrees ranked in the top 9 in Table 2 can be selected as the target configuration code branches, and the 9 code branches are pre-configured into the code environment of each compiling machine. The configuration can refer to Table 2. In Table 2, there are 10 compiling machines capable of providing compilation, and each compiling machine has 10 configurable code environments. The 9 code branches are configured for each compiling machine, occupying 9 code environments. The remaining one is a reserved branch code environment, which is used to obtain the code branch corresponding to the current compilation task as the target compilation branch from the reserved branch code environment when the other 9 code environments do not have the code branch corresponding to the current compilation task. The compiling machine can be used for compilation when the pre-configured code environment does not have the code branch corresponding to the current compilation task, avoiding that the compilation task cannot be executed, and being more reliable.
[0138] Table 3 Configuration table of code branches
[0139]
[0140] From Table 2 and Table 3, after the code branches with the top 9 hotness rankings in Table 2 are pre-configured to each compiling machine, when the code branch corresponding to the compiling task belongs to any one of the 9 code branches, the corresponding code branch can be selected for direct compiling. When the code branch corresponding to the compiling task does not belong to any one of the 9 code branches, the corresponding code branch needs to be switched using the standby branch code environment in the compiling machine for compiling, that is, the compiling after switching can be similar to switching from the main code branch to the slave code branch. From Table 2, it can be counted that the total number of times of being used or compiled is 878, and in Table 3, the code branches with the top 9 hotness rankings in Table 2 are selected as target configuration code branches, and the total number of times of being used or compiled of the 9 code branches is 859. Therefore, only 19 times of compiling tasks cannot find the extracted code environment in the 9 code branches, and need to switch the code branch through the standby branch, and the other 859 times of compiling tasks can be directly compiled without switching the code, and the proportion of not needing to switch is as high as 97.8%.
[0141] It can be understood that the configuration case shown in Table 3 is only one implementation manner, and the specific configuration case can be determined according to actual conditions. For example, the hotness of each code branch determined according to the statistical data and the change of the code environment that can be configured by the compiling machine can be changed accordingly, such as selecting the code branches with the top 7, top 10 or top 12 hotness rankings to be configured to each compiling machine. The top 7, top 10 or top 12 code branches will change or update according to the statistical data of different time periods.
[0142] In the embodiment of the application, the code branches with the top first threshold or the bottom second threshold (i.e., the multiple code branches with relatively large hotness values) are determined as target configuration code branches, and the target configuration code branches are pre-configured to the code environment of the compiling machine, so that most (more than 90% or even higher) of the code environment can be hit in the compiling process, and the corresponding code branch no longer needs to be switched, but the corresponding code branch can be directly selected for compiling, which can reduce the waiting time for switching the corresponding code branch and improve the compiling rate.
[0143] Optionally, as shown in Table 3, the code environment can be divided into two parts, that is, the code environment includes a first branch code environment group and a standby branch code environment, and the first branch code environment group includes a first threshold number or a second threshold number of target configuration code branches. If the hot degree is sorted in descending order, the first branch code environment group includes the first threshold number of target configuration code branches; if the hot degree is sorted in ascending order, the first branch code environment group includes the second threshold number of target configuration code branches. For example, as shown in Table 2 and Table 3, the target configuration code branches can be obtained according to the statistical data in Table 2, such as extracting the first 9 code branches in Table 2 as the target configuration code branches, and then sequentially configuring them into the first branch code environment group (as shown in Table 3), which includes the first 9 code branches extracted from Table 2 in descending order. The standby branch code environment is used to obtain the corresponding code branch when the current compilation task corresponding code branch does not exist in the first branch code environment group. The standby branch code environment needs to be switched to the code branch corresponding to the current compilation task for compilation, that is, the compilation after switching in a similar manner to the related art from the master code branch to the slave code branch, such as the code branch switching through the git checkout command in git.
[0144] In the embodiments of the present application, the pre-configuration of the target configuration code branch into the code environment of the compilation machine in step S503 can be further refined as steps S5031-S5034:
[0145] S5031. Obtain the compilation code parameters corresponding to the compilation task, wherein the compilation code parameters include software code parameters and code branch parameters corresponding to the target configuration code branch;
[0146] In the embodiments of the present application, the software code parameters (GIT_USERNAME, GIT_PASSWORD) and the code branch parameters (BACKEND_BRANCH) are used to indicate the code to be compiled, and the software code represents all the codes corresponding to a compilation task, including codes of various versions, and the software code parameters can represent the index of the software code. The code branch belongs to a part of the software code, and similarly, the code branch parameters can represent the index of the code branch.
[0147] After determining the target code configuration branch through step S502, the name and other code branch identifiers of the target code configuration branch can be obtained, but the corresponding target code configuration branch also needs to be obtained according to the name and other code branch identifiers of the target code configuration branch, so as to pre-configure the target code configuration branch into the code environment of the compilation machine.
[0148] S5032. Obtain the corresponding software code from the code repository according to the software code parameters;
[0149] Referring to Figure 7 , the software code parameter includes a GIT_USERNAME and GIT_PASSWORD field parameter, through which the software code can be queried from the code repository.
[0150] Exemplarily, in git, the software code that needs to be compiled on the compiling machine is pulled (i.e., cloned) from the code repository (such as git.code.tencent.com) of git.
[0151] S5033. Obtain the target configuration code branch from the software code according to the code branch parameter.
[0152] As shown in Figure 7 , the code branch parameter is a BACKEND_BRANCH field parameter, through which the target configuration code branch can be queried from the software code.
[0153] S5034. Store the target configuration code branch into the code environment of the compiling machine.
[0154] In the embodiment of the present application, after obtaining the target configuration code branch, the target configuration code branch is stored into the code environment of the compiling machine, specifically, each target configuration code branch is stored into a code environment. For example, the obtained target configuration code branches include code branch A, code branch B and code branch C, code branch A can be stored into the storage space corresponding to code environment 1, code branch B can be stored into the storage space corresponding to code environment 2, and code branch C can be stored into the storage space corresponding to code environment 3.
[0155] S504. Store the corresponding relationship between the target configuration code branch and the compiling task into the compiling machine.
[0156] In the embodiment of the present application, there can be multiple compiling machines, but the number of compiling machines is smaller than the number of code branches, at this time, multiple target configuration code branches can be pre-configured into the code environment of each compiling machine. In addition, the compiling machine can also store the corresponding relationship between the target configuration code branch and the compiling task through key-value pairs, second corresponding relationship tables and the like, in this way, when compiling, each compiling machine can directly select the corresponding code branch according to the assigned compiling task, and can directly compile without switching the code branch, which can reduce the preparation time of switching the code branch and improve the compiling rate.
[0157] Figure 8A specific application example flowchart of a configuration method of a compilation environment provided by the embodiment of the present application is represented by different version numbers to represent different code branches, i.e., the code branches are specifically version code branches; the statistical data of the code branches is the number of occurrences of the code branches; each code branch is sorted according to the number of occurrences to form a sorting list, and the target configuration code branch is selected or determined according to the sorting list. As shown in Figure 8 The application example specifically includes the following steps S801-S805:
[0158] S801. Obtain each version code branch corresponding to the compilation task in the first time period.
[0159] In the application embodiment, each code branch corresponding to the compilation task in the first time period needs to be obtained first, specifically, the name of each version code branch can be obtained. In order to facilitate the subsequent acquisition of the statistical data of the code branches, the first time period also needs to be determined, which can be determined or updated according to the specific situation, specifically, the way of step S501 can be used, which will not be repeated here.
[0160] S802. Statistically obtain the number of occurrences of each version code branch in the first time period.
[0161] In the application embodiment, after obtaining each version code branch corresponding to the compilation task in the first time period, the number of occurrences of each code branch in the first time period needs to be further obtained and counted. After the first time period is determined by the way of step S501, the name of all version code branches corresponding to the compilation task in the first time period can be obtained, and the number of occurrences of each version code branch can be counted. For example, it is determined that the first time period is from February 10, 2021 to February 15, 2021, all version code branches in the first time period are obtained, including code branch A, code branch B, code branch C, code branch D, …, code branch Z, the number of occurrences of code branch A in the period from February 10, 2021 to February 15, 2021 is 76 times, the number of occurrences of code branch B is 987 times, and the number of occurrences of code branch C is 345 times. In this way, the number of occurrences of each version code branch in the first time period can be counted.
[0162] S803. Sort each version code branch according to the number of occurrences of each version code branch to obtain a sorting list.
[0163] In the application embodiment, the number of occurrences of each version code branch in the first time period is obtained through step S802, and then each code branch can be sorted according to the number of occurrences of each version code branch. For example, the sorting list can be sorted in descending order of the number of occurrences, or the sorting list can be sorted in ascending order of the number of occurrences.
[0164] Optionally, in the application embodiment, after obtaining the sorting list, the operations of steps S8031-S8033 are further performed:
[0165] S8031. Update the sorting list to obtain an updated sorting list.
[0166] Specifically, for different compilation tasks, the corresponding code branches are also different, and the names of the code branches obtained and counted in different time periods and their usage are also different, so the sorting list can be dynamically updated. For example, the update time or update frequency can be set, such as data update every 4 hours or every 2 days; that is, the data of each code branch is reacquired every 4 hours or every 2 days, and the acquired data is counted to obtain the sorting list. At this time, it should be noted that the update time is set, which actually changes the first time period or re-determines the first time period, and the corresponding code branch statistical data in the first time period will also change accordingly. Of course, the sorting list can also be dynamically and real-time updated, for example, a program corresponding to the sorting list can be prepared in advance, the program acquires data from the compilation machine in real time, or the data of the code branch in the compilation machine is transmitted to the program as soon as it changes, and the program can display the updated code branch data in real time according to the pre-set algorithm, and then the sorting list corresponding to the code branch data can also be updated.
[0167] It can be understood that the sorting list is updated by setting the update time, the update frequency, or the program corresponding to the sorting list prepared in advance, which is only a few optional implementation manners, and the sorting list can also be updated by other ways as long as the purpose of updating the sorting list can be achieved.
[0168] S8032. Extract a second version code branch group from the updated sorting list, wherein the second version code branch group is the first threshold number of code branches in the front or the second threshold number of code branches in the back of the updated sorting list.
[0169] In the application embodiment, after the sorting list is updated, the version code branch to be extracted is also changed accordingly, and the code branch with more occurrences in the updated sorting list needs to be extracted. Alternatively, if the updated sorting list is sorted in descending order of the occurrence of the code branch, the first threshold number of code branches in the front of the sorting list are extracted, and if the updated sorting list is sorted in ascending order of the occurrence of the code branch, the second threshold number of code branches in the back of the sorting list are extracted. For example, if the first threshold is determined to be 9, and the code branches in the sorting list are sorted in descending order of the occurrence of the code branch, the first 9 code branches in the sorting list are extracted, and if the second threshold is determined to be 9, and the code branches in the sorting list are sorted in ascending order of the occurrence of the code branch, the last 9 code branches in the sorting list are extracted.
[0170] In the application embodiment, since the sorting list is dynamically updated, the extracted code branch is also changed accordingly, so that the code branch configured in the compiling machine is also changed, and thus the pre-configured code branch in the compiling machine can be hit to the greatest extent during the compiling process, the time for switching the code branch is not needed, and the compiling rate and efficiency are improved.
[0171] S8033. The second version code branch group is configured in each compiling machine.
[0172] Specifically, when the extracted version code branch is changed, if the first threshold number of code branches in the front of the updated sorting list or the second threshold number of code branches in the back of the updated sorting list are extracted as described in step S7032, the code branch pre-configured in each compiling machine is also changed accordingly. Similarly, the changed code branch is configured in the compiling machine, so that the pre-configured code branch in the compiling machine can be hit to a greater extent when the compiling personnel performs the compiling task by using the compiling machine, the preparation time for switching the code branch is reduced, and the compiling rate and efficiency are improved.
[0173] S804. The first version code branch group is extracted from the sorting list, wherein the first version code branch group is the first threshold number of version code branches in the front of the sorting list or the second threshold number of version code branches in the back of the sorting list.
[0174] In the application embodiment, the purpose of step S704 is to obtain a number of version code branches with more occurrences in the sorted list. If the sorted list is sorted in descending order of occurrence, the first threshold number of version code branches in the sorted list are extracted. If the sorted list is sorted in ascending order of occurrence, the second threshold number of version code branches in the sorted list are extracted. Here, the first threshold value can be determined according to specific conditions. For example, the first 10 code branches in the sorted list can be extracted as the first version code branch group, or the first 5 code branches in the sorted list can be extracted as the first version code branch group, so that the version code branches with high occurrence are extracted as the target configuration code branch. The second threshold value is determined in a similar manner to the first threshold value, which will not be described again.
[0175] S805. The first version code branch group is configured to each compiling machine.
[0176] In the application embodiment, after the first version code branch group is extracted, the first version code branch group can be configured to each compiling machine, so that the compiler can directly select the code branch corresponding to the compiling task for compiling when performing the compiling task by using the compiling machine, which reduces the preparation time for switching the code branch and improves the compiling rate and compiling efficiency.
[0177] In the application embodiment, after the first version code branch group is configured to each compiling machine, a preliminary compiling environment can also be configured in each compiling machine, which is used to call the version code branch corresponding to the current compiling task when the version code branch corresponding to the current compiling task is not in the first version code branch group. This method can ensure that the compiling can be successfully performed even if the code branch in the pre-configured code environment is not hit during the compiling process, and avoids that the compiling task cannot be performed, which is more reliable.
[0178] In summary, the compiling environment configuration method provided in the application embodiment first obtains the statistical data of all code branches corresponding to each compiling task in a first time period, and then determines the heat of each code branch according to the statistical data when the number of compiling machines is less than the number of code branches. Then, the first threshold number of code branches with greater heat or the second threshold number of code branches with greater heat are determined as target configuration code branches, and the target configuration code branches are pre-configured to the code environment of the compiling machine. In the application embodiment, the heat of each code branch is obtained according to the statistical data of each code branch, and then the first threshold number of code branches with greater heat or the second threshold number of code branches with greater heat are selected and pre-configured to the code environment of the compiling machine, so that the code branch with greater heat can be directly selected for compiling during the compiling process, without switching the code branch, which can effectively reduce the code environment preparation time before the compiling starts, thereby improving the compiling efficiency.
[0179] Figure 9 Another embodiment flow chart of the configuration method of the compiling environment provided by the present application is provided. The method uses the code environment configuration method based on the subdivision of the storage space described above, is more adaptable, and can be applied to the case where the number of compiling machines is greater than or equal to the number of code branches, or the case where the number of compiling machines is less than the number of code branches. The method can also reduce the code environment preparation time before the start of the compilation and improve the compilation efficiency. The method can also be applied to the computer device 101 shown in Figure 3 or Figure 4 . As shown in Figure 9 , the configuration method can include the following steps S901-S902:
[0180] S901. Subdivide the storage space of each compiling machine into a plurality of sub-storage spaces;
[0181] S902. Pre-configure a code environment of one code branch in each sub-storage space.
[0182] In the embodiment of the present application, the storage space (such as the space of the disk, the memory, etc.) of each code branch occupied by the compiling machine is certain, that is, the storage space used to store one code branch can be a part of the total storage space of the compiling machine, and will not occupy all the disk space. Therefore, in order to reasonably and maximally utilize the storage space of the compiling machine, the storage space of each compiling machine can be subdivided into a plurality of sub-storage spaces, and then a code environment of one code branch is pre-configured in each sub-storage space. The subdivision method of the storage in step S901 of the embodiment of the present application can be determined according to the actual storage space size of each compiling machine and the storage space size occupied by one code branch. Exemplarily, assuming that the storage space of each compiling machine is 300G, and the storage space occupied by one code branch is 30G, then the storage space of each compiling machine can be subdivided into 10 sub-storage spaces, and each sub-storage space can be used to store one code branch. Therefore, 10 sub-storage spaces can store the code environments of 10 code branches. For another example, if the storage space of the compiling machine is larger than 300G, such as 400G, and the storage space occupied by one code branch is 20G, then the storage space of the compiling machine can be subdivided into 20 sub-storage spaces, and the 20 sub-storage spaces can store 20 code branches.
[0183] It can be understood that the subdivision of the storage space of the compiling machine into 10 or 20 sub-storage spaces in step S901 is only two optional embodiments, and the corresponding subdivision can be performed according to the specific situation in actual work.
[0184] As shown in Table 1, the related technologies do not pre-configure code branches. By default, the compilation machine's storage space only stores the master code. This means that during compilation, the master code needs to be switched to the code branch corresponding to the compilation task before compilation can proceed. This results in waiting for code branch switching for each compilation, leading to low compilation speed. In contrast, this application's embodiment divides the storage space of each compilation machine into several sub-storage spaces and pre-configures the code environment of a code branch in each sub-storage space. This allows each compilation machine to pre-configure multiple code branch environments simultaneously. During compilation, the code branch corresponding to the current compilation task can be directly selected without switching code branches, reducing preparation time and improving compilation efficiency. For example, as shown in Table 4, the compilation machine's storage space can be divided into 10 sub-storage spaces, each pre-configured with a code branch. Thus, during compilation, if the code branch corresponding to the compilation task happens to be any one of these 10 code branches, the corresponding code branch can be directly selected for compilation without switching code branches, reducing the time spent switching code branches and improving compilation efficiency. Generally, the configuration method in Table 1 requires several minutes to more than ten minutes for a compilation machine to switch code branches once. However, by adopting the configuration method of this application embodiment, the time consumed by switching code branches can be reduced to zero.
[0185] Table 4 Code Branch Configuration Table
[0186]
[0187] It is understandable that the configuration shown in Table 4 is only one implementation method, and the specific configuration can be determined according to the actual situation. For example, if the compilation machine has 400G of storage space and a code branch requires 30G of storage space, the compilation machine's storage space can be divided into 13 sub-storage spaces; if the compilation machine has 400G of storage space and a code branch only requires 20G of storage space, the compilation machine's storage space can be divided into 20 sub-storage spaces.
[0188] Figure 10 A flowchart illustrating a code environment with a pre-configured code branch in each sub-storage space, as provided in embodiments of this application. In some embodiments, such as... Figure 10 As shown, step S902 may specifically include the following steps S9021-S9022:
[0189] S9021. Obtain the first sub-storage space from each sub-storage space, and pre-configure the code environment of the main code branch in the first sub-storage space.
[0190] In the embodiment of the present application, the code branches include a master code branch and a plurality of sub-code branches, for example, master in Table 4 is the master code branch, and Branch1, Branch2, Branch3, Branch4, Branch5, Branch6, Branch7, Branch8, Branch9 in Table 4 are all sub-code branches; therefore, one of the plurality of sub-storage spaces needs to be selected as the first sub-storage space to configure the code environment of the master code branch. For example, as shown in Table 4, one of the sub-storage spaces can be selected to configure the code environment of the master code branch. Since the storage modes of the sub-storage spaces are not different, the selection of one of the plurality of sub-storage spaces as the first sub-storage space can be random selection or arbitrary selection, and there is no specific selection mode, as long as it can be used to configure the code environment of the master code branch.
[0191] S9022. Obtain a second sub-storage space from each sub-storage space, and the second sub-storage space is pre-configured with the code environment of the sub-code branch, wherein the second sub-storage space is any one of the sub-storage spaces except the first sub-storage space.
[0192] In the embodiment of the present application, after the storage space of the compiling machine is divided into 10 sub-storage spaces as shown in Table 4, one of the sub-storage spaces is selected as the first sub-storage space, the first sub-storage space is configured with the code environment of the master code branch, and the remaining 9 sub-storage spaces are all second sub-storage spaces to configure the code environment of the 9 sub-code branches; by configuring the remaining 9 sub-storage spaces with the code environment of the 9 sub-code branches respectively, when the code branch corresponding to the compiling task is any one of the 9 sub-code branches in the compiling process, the corresponding code branch can be directly selected without switching the code branch, thereby improving the compiling rate.
[0193] It can be understood that, by selecting one of the sub-storage spaces as the first sub-storage space and configuring the code environment of the master code branch, when the code branch corresponding to the compiling task is the master code branch, the master code branch can be directly selected for compiling without switching the code branch, and when the code branch corresponding to the compiling task does not belong to the 10 code branches (1 master code branch and 9 sub-code branches), the master code branch can be switched to the code branch corresponding to the current compiling task to continue the compiling, so that the compiling process will not be interrupted and is more reliable.
[0194] In summary, the compilation environment configuration method provided in this application divides the storage space of each compilation machine into several sub-storage spaces, and then pre-configures the code environment of a code branch in each sub-storage space. By pre-configuring the code environment of the code branch in the sub-storage space, when the code branch corresponding to the compilation task hits one of the multiple pre-prepared code environments on the encoding machine during the compilation process, there is no need to switch code branches, and compilation can be performed directly, which effectively reduces the code environment preparation time before the compilation starts, thereby improving compilation efficiency.
[0195] Figure 11 A flowchart of a compilation method provided in this application embodiment, the method being implemented through, for example... Figure 5 or Figure 9 The compilation environment configuration method shown includes the following steps S1101-S1102: After pre-configuring the code environment, compilation can be performed:
[0196] S1101. In response to compilation instructions, obtain the code environment of the target compilation branch from the code environment of the compilation machine, wherein the code environment of the compilation machine is obtained through... Figure 5 or Figure 9 The method described above pre-configures the target compilation branch as the code branch corresponding to the target compilation task in the compilation instructions;
[0197] S1102. Execute the target compilation task using the code environment of the target compilation branch.
[0198] In step S1101 of this application embodiment, the compilation instructions can come from... Figure 3 Computer equipment 101 or Figure 4 The compilation task sending device 102, i.e., the compilation instructions are obtained in the following ways: the computer device 101 obtains or triggers the compilation task through human-computer interaction methods such as key input, touch input, and sound input; or the compilation task sending device 102 obtains or triggers the compilation task through human-computer interaction methods such as key input, touch input, and sound input.
[0199] This application embodiment is passed through Figure 5 or Figure 9 The configuration method shown pre-configures the code environment of the code branch in the compilation machine. Therefore, when compiling using the compilation machine, it can obtain the code environment of the target compilation branch from the code environment of the compilation machine in response to the compilation instructions, and then execute the target compilation task through the code environment of the target compilation branch. This means that when the code branch corresponding to the compilation task hits one of the multiple code environments prepared in advance on the encoding machine during the compilation process, there is no need to switch code branches and compilation can be carried out directly, which effectively reduces the code environment preparation time before the compilation starts, thereby improving compilation efficiency.
[0200] likeFigure 12 As shown in the embodiment of the present application, the configuration device of the compiling environment comprises:
[0201] The acquisition module 1201 is configured to acquire statistical data of all code branches corresponding to a compiling task within a first time period.
[0202] The heat determination module 1202 is configured to determine the heat of each code branch according to the statistical data.
[0203] The determination and pre-configuration module 1203 is configured to obtain a target configuration code branch from each code branch according to the heat, and pre-configure the target configuration code branch into a code environment of a compiling machine, wherein the target configuration code branch is all code branches ranked before a first threshold in a descending order of the heat, or the target configuration code branch is all code branches ranked after a second threshold in an ascending order of the heat.
[0204] The storage module 1204 is configured to store a corresponding relationship between the target configuration code branch and the compiling task into the compiling machine.
[0205] Figure 5 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown. Figure 5 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown. Figure 5 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown.
[0206] As shown in the embodiment of the present application, the configuration device of the compiling environment comprises: Figure 13
[0207] The division module 1301 is configured to divide the storage space of each compiling machine into a plurality of sub-storage spaces.
[0208] The pre-configuration module 1302 is configured to pre-configure a code environment of a code branch in each sub-storage space.
[0209] Figure 9 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown. Figure 9 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown. Figure 9 The contents in the configuration method embodiment shown are applicable to the device embodiment, the device embodiment specifically realizes the functions same as the configuration method embodiment shown, and achieves the beneficial effects same as the configuration method embodiment shown.
[0210] As shown in the embodiment of the present application, the electronic device comprises a processor 1401 and a memory 1402. Figure 14
[0211] The memory 1402 stores a program.
[0212] The processor 1401 implements the configuration method shown in Figure 5 or Figure 9 The compiling method shown in the configuration method or Figure 11 The compiling method shown in the configuration method or
[0213] Figure 5 or Figure 9 The configuration method of the compiling environment shown in the configuration method or Figure 11 The configuration method of the compiling environment shown in the configuration method or Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or
[0214] The computer readable storage medium stores a program executable by a processor, and the program executable by the processor is used to implement the configuration method shown in Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or
[0215] Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or Figure 5 or Figure 9 The configuration method or Figure 11 The configuration method or
[0216] The computer program product or computer program includes computer instructions stored in a computer readable storage medium. The processor of the computer device can read the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the configuration method of the compiling environment shown in Figure 5 or Figure 9 The configuration method of the compiling environment shown in the configuration method or Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 Figure 9 Figure 11 Figure 5 FigureThe illustrated compilation method.
[0217] It can be appreciated that all or some of the steps of the methods disclosed above can be implemented as software, firmware, hardware, or suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on computer readable media, which can comprise computer storage media (or non-transitory media) and communication media (or transitory media). As is known to those skilled in the art, computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Further, as is known to those skilled in the art, communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and includes any information delivery media.
[0218] The above embodiments of the present application have been described in detail, but the present application is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the spirit of the present application.
Claims
1. A configuration method of a compiling environment, characterized by, The method comprises the following steps: acquiring statistical data of all code branches corresponding to a compilation task within a first time period; determining the heat of each code branch according to the statistical data; obtaining a target configuration code branch from each code branch according to the heat, and pre-configuring the target configuration code branch into a code environment of a compilation machine, wherein the target configuration code branch is the code branch ranked before a first threshold in descending order of the heat, or the target configuration code branch is the code branch ranked after a second threshold in ascending order of the heat; storing the correspondence between the target configuration code branch and the compilation task into the compilation machine.
2. The method of claim 1, wherein, The code environment comprises a first branch code environment group and a standby branch code environment, the first branch code environment group comprises the first threshold number or the second threshold number of target configuration code branches, The configuration method further comprises one of the following: selecting a code branch corresponding to the current compilation task from the first branch code environment group as a target compilation branch; or, when the first branch code environment group does not have a code branch corresponding to the current compilation task, obtaining a code branch corresponding to the current compilation task from the standby branch code environment as a target compilation branch.
3. The method of claim 1, wherein, The first time period is determined by one of the following steps: acquiring an update parameter and an initial value of the first time period, and determining the first time period according to the initial value and the update parameter, wherein the update parameter comprises at least one of an update time or an update frequency; or, acquiring an idle time period of the compilation machine, and determining the idle time period as the first time period, wherein the compilation machine does not execute the compilation task during the idle time period.
4. The method of claim 1, wherein, The statistical data comprises the compilation frequency of the code branch, and the acquisition of the statistical data of all code branches corresponding to the compilation task within the first time period comprises: acquiring the compilation frequency of all code branches corresponding to the compilation task within the first time period.
5. The method of claim 4, wherein, The compilation frequency is represented by any one of the number of compilations of the code branch or the number of users of the code branch, and the acquisition of the compilation frequency of all code branches corresponding to the compilation task within the first time period comprises: acquiring the number of compilations of all code branches corresponding to the compilation task within the first time period, and obtaining the compilation frequency according to the number of compilations; or, acquiring the number of users of all code branches corresponding to the compilation task within the first time period, and obtaining the compilation frequency according to the number of users.
6. The method of claim 1, wherein, The determination of the heat of each code branch according to the statistical data comprises one of the following: sorting all the statistical data, and obtaining the heat of each code branch according to the sorting result; or, obtaining the heat of each code branch from a first correspondence table according to the statistical data, wherein the first correspondence table is a pre-set correspondence table between statistical data and heat. Or, the statistical data is substituted into a function expression between statistical data and hotness which is preset or established, and the hotness of each code branch is calculated; Or, according to the statistical data, a fitting curve between statistical data and hotness which is fitted in advance is adopted to fit the hotness of each code branch; Or, according to the statistical data, the compilation frequency of each code branch is obtained, and then the hotness of each code branch is determined according to the compilation frequency.
7. The method of claim 1, wherein, The compiling machine is multiple, and the target configuration code branch is pre-configured into the code environment of the compiling machine, including: Obtaining the corresponding compiling code parameters from the compiling task, the compiling code parameters including software code parameters and code branch parameters corresponding to the target configuration code branch; According to the software code parameters, the corresponding software code is obtained from the code repository; According to the code branch parameters, the target configuration code branch is obtained from the software code; The target configuration code branch is stored into the code environment of the compiling machine.
8. The method of claim 1, wherein, The target configuration code branch is pre-configured into the code environment of the compiling machine, including: The storage space of each compiling machine is divided into a plurality of sub-storage spaces; A code environment of the target configuration code branch is pre-configured in each sub-storage space.
9. The method of claim 8, wherein, The target configuration code branch is a sub-code branch, and after the storage space of each compiling machine is divided into a plurality of sub-storage spaces, the configuration method of the compiling environment further includes: A first sub-storage space is obtained from each sub-storage space, and a code environment of a main code branch is pre-configured in the first sub-storage space; The code environment of the target configuration code branch is pre-configured in each sub-storage space, including: A second sub-storage space is obtained from each sub-storage space, and a code environment of the sub-code branch is pre-configured in the second sub-storage space, the second sub-storage space being any sub-storage space except the first sub-storage space in each sub-storage space.
10. A method of compiling, characterized by, Including the following steps: In response to a compiling instruction, a code environment of a target compiling branch is obtained from the code environment of the compiling machine, the code environment of the compiling machine being pre-configured by the method of any one of claims 1-9, and the target compiling branch being a code branch corresponding to a target compiling task in the compiling instruction; The target compiling task is executed by using the code environment of the target compiling branch.
11. An apparatus for configuring a compilation environment, characterized by Including: An obtaining module is configured to obtain statistical data of all code branches corresponding to a compiling task in a first time period; A hotness determining module is configured to determine the hotness of each code branch according to the statistical data; A determining and pre-configuring module is configured to obtain a target configuration code branch from each of the code branches according to the hotness, and pre-configure the target configuration code branch into a code environment of a compiling machine, wherein the target configuration code branch is the code branch ranked before a first threshold in a descending order of the hotness, or the target configuration code branch is the code branch ranked after a second threshold in an ascending order of the hotness. A storage module is configured to store a correspondence between the target configuration code branch and the compiling task into the compiling machine.
12. The configuration apparatus of a compiling environment according to claim 11, wherein, The determining and pre-configuring module comprises: A division module is configured to divide a storage space of each of the compiling machines into a plurality of sub-storage spaces. A pre-configuring module is configured to pre-configure a code environment of the target configuration code branch in each of the sub-storage spaces.
13. An electronic device, comprising: The apparatus comprises a processor and a memory. The memory stores a program. The processor executes the program to implement the method in any one of claims 1-10.
14. A storage medium, characterized by The storage medium stores a program, and the program is executed by the processor to implement the method in any one of claims 1-10.
15. A computer program product comprising computer instructions, characterized in that, The computer instructions are executed by the processor to implement the method in any one of claims 1-10.
Citation Information
Patent Citations
Filtering method and device for to-be-compiled codes
CN107368347A
Incremental compilation control method and device, storage medium and electronic equipment
CN112269580A