Code execution method and device

By introducing a pre-preparation service module into the code execution system, downloading and storing the code version that complies with the pre-preparation policy in advance, the problem of long download time during the compilation and construction process is solved, improving code processing efficiency and avoiding resource waste.

CN113553050BActive Publication Date: 2025-04-29HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010337776.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-26
Publication Date
2025-04-29
Estimated Expiration
2040-04-26

AI Technical Summary

Technical Problem

During the compilation and construction process, the time to download the code file is long, resulting in low compilation and construction efficiency. Especially in large software products, the executor needs to download the code file at the same time, resulting in waste of resources and repeated downloads.

Method used

The preparatory service module is introduced. According to the preparatory policy set by the user, the updated code version is downloaded from the code hosting platform and stored in the storage cluster. When the user triggers the code execution request, the code content is directly obtained from the storage cluster to avoid repeated downloads.

Benefits of technology

It improves the efficiency of code processing processes such as compilation and construction, code inspection and code analysis, reduces download time, and avoids the problems of waste of resources and repeated downloads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553050B_ABST
    Figure CN113553050B_ABST
Patent Text Reader

Abstract

The present application provides a code execution method and device. The method includes: a pre-preparation service module obtains a pre-preparation strategy set by a user; the pre-preparation service module downloads the updated code files included in the updated code version from the code hosting platform to the storage cluster according to the pre-preparation strategy; the pre-preparation service module receives a code execution request, and determines the storage address of the code content corresponding to the code execution request in the storage cluster according to the code execution request; the pre-preparation service module sends the storage address to the execution machine; the execution machine obtains the code content according to the received storage address; the execution machine executes the obtained code content. The problem of low efficiency of compilation and construction due to the long downloading time in the prior art can be avoided, and the problem of repeated downloading of code files caused by overlapping execution tasks received by the execution machine in the prior art can also be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development technology, and in particular to a code execution method and device. Background Art

[0002] Tools such as compilation and code checking are indispensable in the process of making software packages. These tools are executed and operated based on a specific version of the code. When using these tools, you need to obtain the above specific version of the code. This acquisition process has a crucial impact on the execution efficiency of the above tools.

[0003] In the prior art, the user selects the code version to be compiled and built in the compilation and build system. The downloader in the compilation and build system downloads the corresponding code from the code version control system according to the code version selected by the user, and then distributes the downloaded code to each execution machine according to the dependency relationship, and then each execution machine completes the compilation and execution operation.

[0004] However, for some larger software products, hundreds or even thousands of execution machines may be required to initiate download actions to the code hosting platform at the same time. The download process takes a long time, resulting in low compilation and build efficiency. Summary of the invention

[0005] The present application provides a code execution method and device for improving the completion efficiency of code processing processes such as compilation and construction, code checking, and code analysis.

[0006] In a first aspect, the present application provides a code execution method, which is applied to a code execution system, wherein the code execution system includes: a pre-prepared service module, a storage cluster, and an execution machine, and the method includes:

[0007] The pre-preparation service module obtains the pre-preparation strategy set by the user;

[0008] The pre-preparation service module downloads the updated code files included in the updated code version from the code hosting platform to the storage cluster according to the pre-preparation strategy;

[0009] The pre-preparation service module receives a code execution request, and determines, according to the code execution request, a storage address of the code content corresponding to the code execution request in the storage cluster;

[0010] The pre-preparation service module sends the storage address to the execution machine;

[0011] The execution machine obtains the code content according to the received storage address;

[0012] The execution machine executes the acquired code content.

[0013] In a possible design, the pre-preparation service module downloads the updated code files included in the updated code version from the code hosting platform to the storage cluster according to the pre-preparation strategy, including:

[0014] The pre-preparation service module receives a code version update notification sent by the code hosting platform;

[0015] The pre-preparation service module determines whether the updated code version complies with the pre-preparation policy according to the code version update notification and the pre-preparation policy;

[0016] If the updated code version complies with the pre-prepared strategy, the updated code files included in the updated code version are downloaded from the code hosting platform to the storage cluster.

[0017] In a possible design, the pre-preparation strategy includes: a first submission type; the code version update notification includes: a submission type corresponding to the updated code version;

[0018] The pre-preparation service determines, according to the code version update notification and the pre-preparation policy, whether the updated code version complies with the pre-preparation policy, including:

[0019] According to the submission type corresponding to the updated code version, determining whether the submission type corresponding to the updated code version and the first submission type are the same submission type;

[0020] If so, it is determined that the updated code version complies with the pre-prepared policy.

[0021] In a possible design, the pre-preparation strategy includes: a first code branch; the code version update notification includes: information about the code branch where the updated code version is located;

[0022] The pre-preparation service determines, according to the code version update notification and the pre-preparation policy, whether the updated code version complies with the pre-preparation policy, including:

[0023] According to the information of the code branch where the updated code version is located, determining whether the code branch where the updated code version is located and the first code branch are the same code branch;

[0024] If so, it is determined that the updated code version complies with the pre-prepared policy.

[0025] In one possible design, the code version update notification further includes: an identifier of the updated code version, and the method further includes:

[0026] The pre-preparation service module determines, according to the identifier of the updated code version, M code files corresponding to the updated code version, where M is a positive integer;

[0027] Obtaining a storage address of the code content of each of the M code files in the storage cluster;

[0028] A file tree object corresponding to the updated code version is generated according to the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster.

[0029] In one possible design, the code execution request carries information of at least one code version requested to be executed by the user;

[0030] The pre-preparation service module determines, according to the code execution request, a storage address of the code content corresponding to the code execution request in the storage cluster, including:

[0031] The pre-preparation service module determines the storage address of the code content corresponding to each code version in the at least one code version according to the information of the at least one code version and the file tree object;

[0032] The execution machine obtains the code content according to the received storage address, including:

[0033] The execution machine determines the storage address to be read according to the storage address of the code content corresponding to each code version in the at least one received code version, and the storage addresses contained in the storage address to be read are different;

[0034] The execution machine reads code content from the storage cluster according to the storage address to be read.

[0035] In a second aspect, the present application provides a code execution device, including:

[0036] The pre-preparation service module is used to obtain the pre-preparation strategy set by the user; according to the pre-preparation strategy, download the updated code files included in the updated code version from the code hosting platform to the storage cluster; receive a code execution request, and according to the code execution request, determine the storage address of the code content corresponding to the code execution request in the storage cluster; send the storage address to the execution machine;

[0037] The execution module is used to obtain the code content according to the received storage address; and execute the obtained code content.

[0038] In a possible design, the pre-preparation service module is specifically used for:

[0039] Receive a code version update notification sent by the code hosting platform; determine whether the updated code version complies with the pre-preparation policy based on the code version update notification and the pre-preparation policy; if the updated code version complies with the pre-preparation policy, download the updated code files included in the updated code version from the code hosting platform to the storage cluster.

[0040] In a possible design, the pre-preparation strategy includes: a first submission type; the code version update notification includes: a submission type corresponding to the updated code version;

[0041] The pre-preparation service module is specifically used to: determine whether the submission type corresponding to the updated code version and the first submission type are the same submission type according to the submission type corresponding to the updated code version; if so, determine that the updated code version complies with the pre-preparation strategy.

[0042] In a possible design, the pre-preparation strategy includes: a first code branch; the code version update notification includes: information about the code branch where the updated code version is located;

[0043] The pre-preparation service module is specifically used to: determine whether the code branch where the updated code version is located and the first code branch are the same code branch based on the information of the code branch where the updated code version is located; if so, determine that the updated code version complies with the pre-preparation strategy.

[0044] In one possible design, the pre-preparation service module is also used to: determine the M code files corresponding to the updated code version based on the identifier of the updated code version, where M is a positive integer; obtain the storage address of the code content of each of the M code files in the storage cluster; and generate a file tree object corresponding to the updated code version based on the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster.

[0045] In one possible design, the code execution request carries information of at least one code version requested to be executed by the user;

[0046] The pre-preparation service module is specifically used to: determine the storage address of the code content corresponding to each code version in the at least one code version according to the information of the at least one code version and the file tree object;

[0047] Correspondingly, the execution module is specifically used to: determine the storage address to be read according to the storage address of the code content corresponding to each code version in at least one received code version, and the storage addresses contained in the storage address to be read are different; read the code content from the storage cluster according to the storage address to be read.

[0048] In a third aspect, the present application provides a readable storage medium having a computer program stored thereon; when the computer program is executed, the above-mentioned code execution method is implemented.

[0049] In a fourth aspect, the present application provides an electronic device, including: a memory and a processor;

[0050] The memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the above code execution method.

[0051] The code execution method and device provided in this embodiment allow users to set pre-preparation strategies by themselves. The pre-preparation service module can obtain the code version that complies with the strategy in advance based on the pre-preparation strategy and store it in the storage cluster. When the user triggers a code execution request, the code content can be directly obtained from the storage cluster. Therefore, the problem of low compilation and construction efficiency caused by the long download time can be avoided. After receiving multiple storage addresses, the execution machine filters out duplicate storage addresses to obtain the storage address to be read. Since the storage addresses contained in the storage address to be read are different, the problem of repeated reading can be avoided, thereby solving the problem of repeated downloading of code files when the execution tasks received by the execution machine overlap in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 A framework diagram of the compilation and construction system provided for the prior art;

[0053] Figure 2 A framework diagram of the code execution system provided for this application;

[0054] Figure 3 A flowchart of an embodiment of a code execution method provided by the present application;

[0055] Figure 4 A schematic diagram of the code branches provided for this application;

[0056] Figure 5 Schematic diagram of the file tree object provided for this application;

[0057] Figure 6 User interface diagram provided for this application;

[0058] Figure 7A schematic diagram of the structure of the code execution device 700 provided in this application;

[0059] Figure 8 A schematic diagram of the hardware structure of the electronic device 800 provided in this application. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0061] In the present application, it should be explained that the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " is generally used to indicate that the objects associated with each other are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a alone, b alone, c alone, a combination of a and b, a combination of a and c, a combination of b and c, or a combination of a, b and c, where a, b, c can be single or multiple.

[0062] For the same software product, as R&D personnel continue to improve its functions and fix vulnerabilities, many code versions will be generated. When making a software package for a certain code version, tools such as compilation and construction, code checking, and code analysis are required. Take the compilation and construction tool as an example, see Figure 1As shown, the compilation and construction process of the prior art is as follows: the user selects the code version to be compiled and constructed, and the distribution module in the compilation and construction system determines the multiple code files corresponding to the code version according to the code version selected by the user, and then sends the execution task to each execution machine according to the dependency relationship between these code files. After the execution machine receives the execution task, it first downloads the corresponding code file from the code hosting platform, and then performs the compilation and construction operation. For example: the code version selected by the user is version A, and the distribution module determines that the code files corresponding to version A include: file 1, file 2, file 3 and file 4, among which file 1 and file 3 have a dependency relationship, file 2 and file 4 have a dependency relationship, and file 2 and file 3 have a dependency relationship. Then, according to the above dependency relationship, file 1 and file 3 can be used as an execution task, file 2 and file 4 can be used as an execution task, and file 2 and file 3 can be used as an execution task. These three execution tasks can be sent to Figure 1 The three execution machines shown in the figure, after receiving the execution task, first download the corresponding code file from the code hosting platform, and then perform a compile operation on the code content in the downloaded code file.

[0063] However, for some relatively large software products, it may require hundreds or thousands of execution machines to initiate download actions to the code hosting platform at the same time. The download process takes a long time, resulting in low compilation and construction efficiency. Moreover, when the user wants to build multiple code versions, if the execution tasks received by the execution machine overlap, it will cause repeated downloads of code files. For example: the user wants to build code version A and code version B, and the execution tasks corresponding to code version A received by the execution machine include files 1 and file 2, and the execution tasks corresponding to code version B include files 1 and file 3. Then the execution tasks received by the execution machine overlap, and the execution machine needs to repeatedly download file 1, resulting in a waste of download resources.

[0064] It should be noted that the above is an explanation using the compilation and construction tool as an example. Code checking tools and code analysis tools are similar to compilation and construction tools in obtaining code versions, and are both downloaded directly from the code hosting platform by the execution machine. Therefore, these two tools also have problems similar to compilation and construction, namely, low code checking efficiency and low code analysis efficiency.

[0065] In view of the above technical problems existing in the prior art, the present application provides a code execution method, which can be based on Figure 2 The code shown executes the system implementation, Figure 2 The code execution system shown includes: a pre-preparation service module, a storage cluster and an execution machine cluster, and the execution machine cluster is composed of multiple execution machines. The pre-preparation service module can be integrated into the code execution system or can be a separate module. Figure 2The example is integrated in the code execution system. Users can configure the pre-preparation strategy of the code version through the pre-preparation service module.

[0066] It should be noted that: when the code execution method provided in this application is applied in a compilation and construction scenario, the above-mentioned code execution system can be a compilation and construction system; when the code execution method provided in this application is applied in a code inspection scenario, the above-mentioned code execution system can be a code inspection system; when the code execution method provided in this application is applied in a code analysis scenario, the above-mentioned code execution system can be a code analysis system.

[0067] In the prior art, it takes a long time for the execution machine to download the corresponding code files from the code hosting platform, resulting in low compilation and construction efficiency. Based on this, the present application adds the above-mentioned pre-preparation service module. Users can configure the pre-preparation strategy of the code version through the pre-preparation service module. When the code hosting platform has a code version update, the pre-preparation service module can download the updated code files included in the updated code version from the code hosting platform to the storage cluster according to the above-mentioned pre-preparation strategy, so that the storage cluster stores all code versions that comply with the pre-preparation strategy set by the user. When the user needs to compile and build one or more of the code versions, a code execution request is triggered. After receiving the code execution request, the pre-preparation service module first determines the storage address of the code content corresponding to the code execution request in the storage cluster according to the code execution request, and then sends the storage address to the execution machine, so that the execution machine can obtain the code content according to the storage address and further execute the obtained code content.

[0068] It can be seen that the code execution method provided by the present application allows users to set the pre-preparation strategy by themselves. The pre-preparation service module can obtain the code version that complies with the strategy in advance based on the pre-preparation strategy and store it in the storage cluster. When the user triggers the code execution request, the code content can be directly obtained from the storage cluster. Therefore, the problem of low compilation and construction efficiency caused by the long download time can be avoided.

[0069] The following is a detailed description of the code execution method provided by this application through specific embodiments. Figure 2 The system shown, Figure 3 The following is a flow chart of an embodiment of the code execution method provided by the present application. Figure 3 As shown, the code execution method provided by this application includes:

[0070] S301: The pre-preparation service module obtains a pre-preparation strategy set by a user.

[0071] In one possible implementation, Figure 2The code execution system shown provides a user interaction interface, and the user can configure the pre-preparation strategy through the user interaction interface.

[0072] Optionally, the above pre-preparation strategy can be a certain code branch or a certain submission type.

[0073] S302: The pre-preparation service module downloads the updated code files included in the updated code version from the code hosting platform to the storage cluster according to the pre-preparation strategy.

[0074] In a possible implementation, this step may further include:

[0075] Step A: The pre-preparation service module receives the code version update notification sent by the code hosting platform.

[0076] Specifically, when the code hosting platform detects an updated code version, it sends a code version update notification to the pre-preparation service module. The code version update notification may include: the identifier of the updated code version, the information of the code branch where the updated code version is located, the submission type corresponding to the updated code version, and / or the information of the updated code files included in the updated code version.

[0077] The following is an explanation of the meaning of code branches, code versions, and code files in the code hosting platform:

[0078] See also Figure 4 As shown, assuming that the basic version of the software product is version 0, based on the purpose of optimizing product functions and fixing vulnerabilities, a new code version can be further developed based on version 0. Based on different development purposes, multiple code branches can be designed, and R&D personnel can update the code version on the corresponding code branch. Each code version is a version further developed based on the previous code version on the same code branch. Since the submission of each code version corresponds to a time point, each code version also corresponds to a time point. Each code version contains one or more code repositories, and each code repository contains multiple code files.

[0079] In a possible implementation, when a user submits a new code version, the code hosting platform can determine that there is a code version update, and can use the code version submitted by the user as the updated code version. The code hosting platform can further obtain the code file modified by the user in this submission, and use the code file as the updated code file included in the updated code version.

[0080] For example, suppose the user modifies file 110 included in version 11 on code branch 1 to obtain file 120, and after submitting, obtains version 12. The code hosting platform can use version 12 as the updated code version and file 120 as the updated code file included in version 12.

[0081] Step B: The pre-preparation service module determines whether the updated code version complies with the pre-preparation policy according to the code version update notification and the pre-preparation policy.

[0082] In a possible implementation, the pre-preparation strategy set by the user includes: a first submission type. In this case, whether the updated code version complies with the pre-preparation strategy can be determined in the following manner: according to the submission type corresponding to the updated code version, it is determined whether the submission type corresponding to the updated code version and the first submission type are the same submission type; if so, it is determined that the updated code version complies with the pre-preparation strategy.

[0083] Continuing with the example of step A: the code version update notification sent by the code hosting platform includes: the identifier of version 12, the information of the code branch where version 12 is located, the submission type corresponding to version 12, and / or the information of the updated code file 120 included in version 12. According to the submission type corresponding to version 12, it can be determined whether the submission type corresponding to version 12 and the first submission type are the same submission type; if so, it is determined that version 12 complies with the above-mentioned pre-preparation strategy. For example: the first submission type is code result rectification, and the submission type corresponding to version 12 is also code result rectification, then it can be determined that version 12 complies with the above-mentioned pre-preparation strategy.

[0084] In another possible implementation, the pre-preparation strategy set by the user includes: a first code branch. In this case, whether the updated code version complies with the pre-preparation strategy can be determined in the following manner: according to the information of the code branch where the updated code version is located, it is determined whether the code branch where the updated code version is located and the first code branch are the same code branch; if so, it is determined that the updated code version complies with the pre-preparation strategy.

[0085] Continuing with the example of step A, the code version update notification sent by the code hosting platform includes: the identifier of version 12, the information of the code branch where version 12 is located, the submission type corresponding to version 12, and / or the information of the updated code file 120 included in version 12. Based on the information of the code branch where version 12 is located, it can be determined whether the code branch where version 12 is located and the first code branch are the same code branch; if so, it is determined that version 12 meets the above-mentioned pre-preparation strategy.

[0086] Step C: If the updated code version complies with the pre-prepared strategy, the updated code files included in the updated code version are downloaded from the code hosting platform to the storage cluster.

[0087] In a possible implementation, as described above, since the code version update notification sent by the code hosting platform may include: information about the updated code files included in the updated code version, the corresponding files may be downloaded from the code hosting platform to the storage cluster according to the information about the updated code files included in the updated code version.

[0088] In one possible implementation, the pre-preparation service module can also determine whether the code files included in the updated code version stored in the storage cluster are complete in addition to the updated code files. If not, then while downloading the updated code files from the code hosting platform, the missing code files also need to be downloaded to the storage cluster.

[0089] In a possible implementation, the method provided in this embodiment may also include: the pre-preparation service module determines the M code files corresponding to the updated code version according to the identifier of the updated code version, where M is a positive integer; obtains the storage address of the code content of each of the M code files in the storage cluster; generates a file tree object corresponding to the updated code version according to the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster. The file tree object may also be stored in the storage cluster. Performing this operation on all updated code versions will yield the following result. Figure 5 The file tree object shown.

[0090] S303: The pre-preparation service module receives the code execution request, and determines, according to the code execution request, a storage address of the code content corresponding to the code execution request in the storage cluster.

[0091] The following are possible ways for users to trigger code execution requests:

[0092] The code execution request carries information about at least one code version that the user requests to execute. The information about each code version may include: an identifier of the code version and description information of the code version. The description information of the code version may be used to indicate the submission type corresponding to the code version.

[0093] In one possible implementation, the user can select Figure 6 To trigger a code execution request, Figure 6Each option box corresponds to two types of information. The information on the left is the identifier of the code version, and the information on the right is the description information of the code version. In this case, the code version requested to be executed by the user is the code version corresponding to the option box checked by the user. The information of the code version requested to be executed by the user includes: the information of the code version corresponding to the option box checked by the user. For example, if the user checks the first option box, the identifier of the code version requested to be executed by the user is 4358ca2e, and the description information of the code version requested to be executed by the user is: Fix#Code result correction.

[0094] In another possible implementation, the user can first check Figure 6 The option box in the code execution request is used to select the code version to be executed this time, and then the code execution button is triggered to trigger the code execution request. Similarly, in this case, the code version requested to be executed by the user is the code version corresponding to the option box checked by the user, and the information of the code version requested to be executed by the user is the information of the code version corresponding to the option box checked by the user.

[0095] In a possible implementation, after receiving a code execution request triggered by a user, the pre-preparation service module determines the storage address of the code content corresponding to each code version in the at least one code version according to the information of the at least one code version and the file tree object, and sends the storage address of the code content corresponding to each code version in the at least one code version to the execution machine.

[0096] Here are some examples:

[0097] See also Figure 5As shown, it is assumed that the storage cluster stores n file tree objects, namely file tree object 1, file tree object 2, ..., file tree object n, each file tree object corresponds to a code version. It is assumed that the code version corresponding to file tree object 1 is identified as 4358ca2e, the code version corresponding to file tree object 2 is identified as 17bfab15, the code version corresponding to file tree object 3 is identified as 1405fe59, the code version corresponding to file tree object 4 is identified as f4d598e2, the code version corresponding to file tree object 5 is identified as 04ad141a, the code version corresponding to file tree object 6 is identified as d32df9a5, and the code version corresponding to file tree object n is identified as version n. After receiving the code execution request triggered by the user, assuming that the information of the two code versions is carried in the code execution request, based on the information of the two code versions, it can be determined that the identifiers of the two code versions are 4358ca2e and f4d598e2. Based on the relationship between the above-mentioned file tree object and the code version, it can be determined that the file tree object corresponding to 4358ca2e is file tree object 1. Since the code file corresponding to file tree object 1 includes file 1 and file 4, it can be determined that 4358ca2e includes file 1 and file 4, and the storage address of file 1 is address 1, and the storage address of file 4 is address 4; the file tree object corresponding to f4d598e2 is file tree object 4. Since the code file corresponding to file tree object 4 includes file 1 and file 5, it can be determined that f4d598e2 includes file 1 and file 5, and the storage address of file 1 is address 1, and the storage address of file 4 is address 5.

[0098] S304: The pre-preparation service module sends the storage address to the execution machine.

[0099] Continuing with the example of S303: S303 may determine that the storage addresses of the code content corresponding to 4358ca2e are address 1 and address 4, and the storage addresses of the code content corresponding to f4d598e2 are address 1 and address 5. Then, the pre-preparation service module sends address 1 and address 4 corresponding to 4358ca2e, and address 1 and address 5 corresponding to f4d598e2 to the execution machine.

[0100] S305: The execution machine obtains the code content according to the received storage address.

[0101] S306: The execution machine executes the acquired code content.

[0102] In a possible implementation, after receiving the storage address of the code content corresponding to each code version in at least one code version, the execution machine filters out the repeated storage addresses to determine the storage address to be read; the code content is read from the storage cluster according to the storage address to be read, for example: the storage address of the code content corresponding to version A received by the execution machine includes address 1 and address 2, and the storage address of the code content corresponding to version B includes address 1 and address 3, where address 1 is repeated, the redundant address 1 is filtered out, and the storage addresses to be read are obtained as address 1, address 2 and address 3, and then the code content is read from the storage cluster according to the three storage addresses. This avoids the phenomenon of repeated downloading of code files when the execution tasks received by the execution machine overlap in the prior art.

[0103] The code execution method provided in this embodiment allows the user to set the pre-preparation strategy by himself. The pre-preparation service module can obtain the code version that meets the strategy in advance based on the pre-preparation strategy and store it in the storage cluster. When the user triggers the code execution request, the code content can be directly obtained from the storage cluster. Therefore, the problem of low compilation and construction efficiency caused by the long download time can be avoided. After the execution machine receives multiple storage addresses, the duplicate storage addresses are filtered out to obtain the storage address to be read. Since the storage addresses contained in the storage address to be read are different, the problem of repeated reading can be avoided, thereby solving the problem of repeated downloading of code files when the execution tasks received by the execution machine overlap in the prior art.

[0104] Figure 7 Schematic diagram of the structure of the code execution device 700 provided in this application. Figure 7 As shown, the code execution device 700 provided in the present application includes: a pre-preparation service module 701 and an execution module 702; the pre-preparation service module 701 is used to obtain the pre-preparation strategy set by the user, and according to the pre-preparation strategy, download the updated code files included in the updated code version from the code hosting platform to the storage cluster; receive a code execution request, and according to the code execution request, determine the storage address of the code content corresponding to the code execution request in the storage cluster; send the storage address to the execution machine; the execution module 702 is used to obtain the code content according to the received storage address; and execute the obtained code content.

[0105] Optionally, the pre-preparation service module 701 is specifically used to: receive a code version update notification sent by the code hosting platform; determine whether the updated code version complies with the pre-preparation policy based on the code version update notification and the pre-preparation policy; if the updated code version complies with the pre-preparation policy, download the updated code files included in the updated code version from the code hosting platform to the storage cluster.

[0106] Optionally, the pre-preparation strategy includes: a first submission type; the code version update notification includes: a submission type corresponding to the updated code version; the pre-preparation service module 701 is specifically used to: based on the submission type corresponding to the updated code version, determine whether the submission type corresponding to the updated code version and the first submission type are the same submission type; if so, determine that the updated code version complies with the pre-preparation strategy.

[0107] Optionally, the pre-preparation strategy includes: a first code branch; the code version update notification includes: information about the code branch where the updated code version is located; the pre-preparation service module 701 is specifically used to: determine whether the code branch where the updated code version is located and the first code branch are the same code branch based on the information about the code branch where the updated code version is located; if so, determine that the updated code version complies with the pre-preparation strategy.

[0108] Optionally, the pre-preparation service module 701 is also used to: determine the M code files corresponding to the updated code version according to the identifier of the updated code version, where M is a positive integer; obtain the storage address of the code content of each of the M code files in the storage cluster; and generate a file tree object corresponding to the updated code version according to the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster.

[0109] Optionally, the code execution request carries information of at least one code version requested to be executed by the user; the pre-preparation service module 701 is specifically used to: the pre-preparation service module determines the storage address of the code content corresponding to each of the at least one code version based on the information of the at least one code version and the file tree object; correspondingly, the execution module 702 is specifically used to determine the storage address to be read based on the storage address of the code content corresponding to each of the at least one code version received, the storage addresses contained in the storage addresses to be read are different; and read the code content from the storage cluster according to the storage address to be read.

[0110] The above-mentioned code execution device provided in the present application can execute the steps in the above-mentioned method embodiment. Its implementation principles and beneficial effects are similar and will not be repeated here.

[0111] Figure 8 Schematic diagram of the hardware structure of the electronic device 800 provided in this application. Figure 8As shown, this generation of electronic device 800 includes: a memory 801 and at least one processor 802, the memory 801 is used to store program instructions, and the at least one processor 802 is used to call the program instructions in the memory 801 to execute the steps in the above method embodiment. Its implementation principles and beneficial effects are similar and will not be repeated here.

[0112] The present application also provides a readable storage medium, in which execution instructions are stored. When at least one processor 802 of the electronic device executes the execution instructions, the steps in the above method embodiment are implemented. The implementation principles and beneficial effects are similar and will not be repeated here.

[0113] The present application also provides a program product, which includes a computer program (i.e., an execution instruction), which is stored in a readable storage medium. At least one processor 802 of the electronic device can read the computer program from the readable storage medium, and at least one processor 802 executes the computer program so that the electronic device implements the above-mentioned code execution method.

[0114] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0115] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0116] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0117] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of various embodiments of the present application.

[0118] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0119] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0120] The bus can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0121] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state hard disk solid state disk, SSD), etc.

Claims

1. A code execution method, characterized in that: Applied to a code execution system, the code execution system includes: a pre-preparation service module, a storage cluster and an execution machine, the method includes: The pre-preparation service module obtains the pre-preparation strategy set by the user; The pre-preparation service module receives a code version update notification sent by the code hosting platform; The pre-preparation service module determines whether the updated code version complies with the pre-preparation policy according to the code version update notification and the pre-preparation policy; if the updated code version complies with the pre-preparation policy, downloading the updated code file included in the updated code version from the code hosting platform to the storage cluster; The pre-preparation service module receives the code execution request, and determines, according to the code execution request, a storage address of the code content corresponding to the code execution request in the storage cluster; The pre-preparation service module sends the storage address to the execution machine; The execution machine obtains the code content according to the received storage address; The execution machine executes the acquired code content.

2. The method according to claim 1, characterized in that: The pre-preparation strategy includes: a first submission type; the code version update notification includes: a submission type corresponding to the updated code version; The pre-preparation service determines, according to the code version update notification and the pre-preparation policy, whether the updated code version complies with the pre-preparation policy, including: According to the submission type corresponding to the updated code version, determining whether the submission type corresponding to the updated code version and the first submission type are the same submission type; If so, it is determined that the updated code version complies with the pre-prepared policy.

3. The method according to claim 1, characterized in that The pre-preparation strategy includes: a first code branch; the code version update notification includes: information about the code branch where the updated code version is located; The pre-preparation service determines, according to the code version update notification and the pre-preparation policy, whether the updated code version complies with the pre-preparation policy, including: According to the information of the code branch where the updated code version is located, determining whether the code branch where the updated code version is located and the first code branch are the same code branch; If so, it is determined that the updated code version complies with the pre-prepared policy.

4. The method according to any one of claims 1 to 3, characterized in that: The code version update notification further includes: an identifier of the updated code version, and the method further includes: The pre-preparation service module determines, according to the identifier of the updated code version, M code files corresponding to the updated code version, where M is a positive integer; Obtaining a storage address of the code content of each of the M code files in the storage cluster; A file tree object corresponding to the updated code version is generated according to the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster.

5. The method according to any one of claims 1 to 3, characterized in that: The code execution request carries information of at least one code version requested to be executed by the user; The pre-preparation service module determines, according to the code execution request, a storage address of the code content corresponding to the code execution request in the storage cluster, including: The pre-preparation service module determines the storage address of the code content corresponding to each code version in the at least one code version according to the information of the at least one code version and the file tree object; The execution machine obtains the code content according to the received storage address, including: The execution machine determines the storage address to be read according to the storage address of the code content corresponding to each code version in the at least one received code version, and the storage addresses contained in the storage address to be read are different; The execution machine reads code content from the storage cluster according to the storage address to be read.

6. A code execution device, characterized in that: include: The pre-preparation service module is used to obtain the pre-preparation strategy set by the user; According to the pre-preparation strategy, the updated code files included in the updated code version are downloaded from the code hosting platform to the storage cluster; receiving a code execution request, and determining, according to the code execution request, a storage address of code content corresponding to the code execution request in the storage cluster; Sending the storage address to an execution machine; The execution module is used to obtain the code content according to the received storage address; and execute the obtained code content; The pre-preparation service module is specifically used for: Receive a code version update notification sent by the code hosting platform; determine whether the updated code version complies with the pre-preparation policy based on the code version update notification and the pre-preparation policy; if the updated code version complies with the pre-preparation policy, download the updated code files included in the updated code version from the code hosting platform to the storage cluster.

7. The device according to claim 6, characterized in that The pre-preparation strategy includes: a first submission type; the code version update notification includes: a submission type corresponding to the updated code version; The pre-preparation service module is specifically used to: determine whether the submission type corresponding to the updated code version and the first submission type are the same submission type according to the submission type corresponding to the updated code version; if so, determine that the updated code version complies with the pre-preparation strategy.

8. The device according to claim 6, characterized in that The pre-preparation strategy includes: a first code branch; the code version update notification includes: information about the code branch where the updated code version is located; The pre-preparation service module is specifically used to: determine whether the code branch where the updated code version is located and the first code branch are the same code branch based on the information of the code branch where the updated code version is located; if so, determine that the updated code version complies with the pre-preparation strategy.

9. The device according to any one of claims 6 to 8, characterized in that: The pre-preparation service module is further used to: determine, according to the identifier of the updated code version, M code files corresponding to the updated code version, where M is a positive integer; obtain a storage address of the code content of each of the M code files in the storage cluster; A file tree object corresponding to the updated code version is generated according to the identifier of the updated code version, the M code files, and the storage address of the code content of each of the M code files in the storage cluster.

10. The device according to any one of claims 6 to 8, characterized in that: The code execution request carries information of at least one code version requested to be executed by the user; The pre-preparation service module is specifically used to: determine the storage address of the code content corresponding to each code version in the at least one code version according to the information of the at least one code version and the file tree object; Accordingly, the execution module is specifically used to: determine the storage address to be read according to the storage address of the code content corresponding to each code version in the at least one received code version, and the storage addresses contained in the storage address to be read are different; The code content is read from the storage cluster according to the storage address to be read.

11. A readable storage medium, characterized in that: The readable storage medium stores a computer program; when the computer program is executed, the method described in any one of claims 1 to 5 is implemented.

12. An electronic device, characterized in that: include: Memory and processor; The memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the method according to any one of claims 1 to 5.

13. A computer program product, characterized in that The invention comprises a computer program, which, when executed, implements the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for updating code file, device for updating code file, storage medium, processor and terminal

    CN107193607A

  • Software development project management system

    CN107291448A