Resource optimization method, electronic equipment, storage medium and program product
Through the sliding time window algorithm, the target time period for the subprogram is arranged for the subprogram during the time period when the main program resource utilization is low, solving the problem of subprogram interfering with the operation of the main program, and achieving efficient resource utilization and system stability.
Patent Information
- Application Number
- CN202411570977.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art is difficult to effectively balance the resource use of subroutines and main programs, resulting in the operation of subroutines during high load periods and interfering with the normal operation of the main program.
By determining the operation index data of the subprogram, a sliding time window algorithm is used to arrange a target time period for the subprogram to meet its high-demand resources during the time period when the main program has low resource utilization, and to control the operation of the subprogram during this time period. .
It realizes efficient operation of subroutines and main programs at the same time, improves the efficiency of computing resources utilization, and adapts to business changes through dynamic adjustments to maintain the stability of the system.
Smart Images

Figure CN119473606A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of resource management, and in particular to a resource optimization method, electronic equipment, storage medium and program product. Background Art
[0002] As the program runs, new requirements may arise, such as data synchronization, sorting, cleaning, and statistics, which are usually handled by subroutines. Because these tasks can be very time-consuming and resource-intensive, they may interfere with the normal operation of the main program. Usually, these subroutines are run during periods of low system load, such as at night, but this approach is not always the best choice because it can cause resource competition and affect the efficiency of the main program. Therefore, a more complete method is needed to balance the resource usage of subroutines and main programs to ensure that both can run efficiently. Summary of the invention
[0003] The present application provides a resource optimization method, electronic device, storage medium and program product, which are used to improve the utilization efficiency of computing resources while achieving normal business operation.
[0004] In a first aspect, the present application provides a resource optimization method, the method comprising: determining operating index data of at least one subprogram to be run, the operating index data of the subprogram including the running time of the subprogram and the high-demand resource index of the subprogram; for each subprogram in at least one subprogram, within a first time period, based on the operating index data of each subprogram, using a sliding time window algorithm to determine a target time period for the running of each subprogram, the length of the target time period being greater than or equal to the running time of the subprogram, and the resources within the target time period satisfying the high-demand resource index of the subprogram; the first time period is a time period in which the resource utilization rate of the main program is less than or equal to a first preset threshold; controlling at least one subprogram to run in the target time period corresponding to the subprogram.
[0005] The technical solution provided by the present application brings at least the following beneficial effects: the present application observes the resource utilization of the main program and evaluates the resource utilization of the subprogram, and combines the sliding time window algorithm to find the time period suitable for the subprogram to run during the subprogram runnable time period, and controls the subprogram to run in the appropriate time period, so as to achieve normal operation of the main program and subprograms, and at the same time, improve the efficiency of computing resource utilization.
[0006] A possible implementation method is to use a sliding time window algorithm to determine the target time period for each subprogram to run within a first time period based on the running indicator data of each subprogram, including: configuring the window length and sliding step of the sliding time window algorithm; wherein the window length is greater than or equal to the running time of the subprogram; determining in turn based on the window length and the sliding step whether the resources within each time window meet the high-demand resource indicators of the subprogram until a time window that meets the high-demand resource indicators of the subprogram is selected; and determining the target time period based on the time window that meets the high-demand resource indicators of the subprogram.
[0007] Another possible implementation method is that at least one subprogram includes a target subprogram, and the target subprogram is any subprogram of the at least one subprogram; determining the operating indicator data of at least one subprogram to be run, including: detecting the values of various resource indicators of the target subprogram during the trial run, and the running time of the target subprogram; when the value of the target resource indicator of the target subprogram is the maximum value among the values of the target resource indicators of at least one subprogram, using the target resource indicator as the high-demand resource indicator of the target subprogram.
[0008] In another possible implementation manner, the method further includes: determining the first time period based on a time period in which the resource utilization rate of the main program is less than or equal to a first preset threshold value in a plurality of historical operation cycles.
[0009] In another possible implementation, after controlling at least one subprogram to run in a target time period corresponding to the subprogram, the method further includes: when it is determined that the running of the subprogram affects the running of the main program, adjusting the target time period for the running of the subprogram to obtain an adjusted target time period; and controlling the subprogram to run in the adjusted target time period.
[0010] Another possible implementation method is to determine whether the operation of the sub-program affects the operation of the main program, including: periodically detecting the resource utilization of the main program; and determining that the operation of the sub-program affects the operation of the main program when the difference between the resource utilization of the main program at a first moment in a first operation cycle and the resource utilization of the main program at a first moment in a second operation cycle is greater than or equal to a second preset threshold.
[0011] In another possible implementation, determining whether the execution of the subprogram affects the execution of the main program includes: when a fault is detected in the main program, determining whether the execution of the subprogram affects the execution of the main program.
[0012] In a second aspect, the present application provides a resource optimization device, which can implement the resource optimization method provided by the present application. The resource optimization device includes: a detection unit, a processing unit and a control unit.
[0013] A detection unit, used to determine the running indicator data of at least one subprogram to be run, wherein the running indicator data of the subprogram includes the running time of the subprogram and the high demand resource indicator of the subprogram;
[0014] The processing unit determines, for each subprogram of at least one subprogram, a target time period for the operation of each subprogram based on the operation index data of each subprogram within a first time period by using a sliding time window algorithm, wherein the length of the target time period is greater than or equal to the operation time of the subprogram, and the resources within the target time period meet the high-demand resource index of the subprogram; the first time period is a time period in which the resource utilization rate of the main program is less than or equal to a first preset threshold value;
[0015] The control unit controls at least one subprogram to run in a target time period corresponding to the subprogram.
[0016] A possible implementation method is a processing unit, which is specifically used to configure the window length and sliding step of the sliding time window algorithm; wherein the window length is greater than or equal to the running time of the subroutine; based on the window length and the sliding step, it is determined in turn whether the resources in each time window meet the high-demand resource indicators of the subroutine, until a time window that meets the high-demand resource indicators of the subroutine is selected; based on the time window that meets the high-demand resource indicators of the subroutine, a target time period is determined.
[0017] Another possible implementation method is that at least one subprogram includes a target subprogram, and the target subprogram is any subprogram of the at least one subprogram; a detection unit is specifically used to detect the values of various resource indicators of the target subprogram during the trial operation, as well as the running time of the target subprogram; when the value of the target resource indicator of the target subprogram is the maximum value among the values of the target resource indicators of at least one subprogram, the target resource indicator is used as a high-demand resource indicator of the target subprogram.
[0018] In another possible implementation, the processing unit is specifically configured to determine the first time period based on a time period in which the resource utilization rate of the main program in a plurality of historical operation cycles is less than or equal to a first preset threshold.
[0019] In another possible implementation, the processing unit is further used to adjust the target time period for the subprogram to obtain an adjusted target time period when it is determined that the operation of the subprogram affects the operation of the main program; the control module is further used to control the subprogram to run in the adjusted target time period.
[0020] In another possible implementation, the processing unit is specifically used to periodically detect the resource utilization of the main program; when the difference between the resource utilization of the main program at the first moment of the first operating cycle and the resource utilization of the main program at the first moment of the second operating cycle is greater than or equal to a second preset threshold, it is determined that the operation of the sub-program affects the operation of the main program.
[0021] In another possible implementation, the processing unit is specifically configured to determine whether the operation of the subprogram affects the operation of the main program when a fault in the main program is detected.
[0022] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory; the memory stores instructions executable by the processor; when the processor is configured to execute the instructions, the electronic device implements the method of the first aspect above.
[0023] In a fourth aspect, the present application provides a computer-readable storage medium, which includes: computer software instructions; when the computer software instructions are executed in an electronic device, the electronic device implements the method according to the first aspect.
[0024] In a fifth aspect, the present application provides a computer program product, which includes a computer program; when the computer program runs in an electronic device, the electronic device implements the method according to the first aspect.
[0025] The beneficial effects of the second to fifth aspects mentioned above refer to the corresponding description of the first aspect and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic diagram of the structure of a resource optimization system provided for this application;
[0027] Figure 2 A flow chart of a resource optimization method provided for this application;
[0028] Figure 3 A flowchart of another resource optimization method provided for this application;
[0029] Figure 4 A flowchart of another resource optimization method provided by this application;
[0030] Figure 5 A flowchart of another resource optimization method provided by this application;
[0031] Figure 6 A schematic diagram of the structure of a resource optimization device provided in this application;
[0032] Figure 7A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0033] A call bill data recording method provided by the present application will be described in detail below with reference to the accompanying drawings.
[0034] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0035] The terms "first" and "second" and the like in the specification and drawings of this application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0036] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0037] It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0038] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical items or similar items with basically the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order.
[0039] In the description of the present application, unless otherwise specified, “plurality” means two or more.
[0040] During software development and maintenance, as business needs continue to evolve, the program may need to perform some additional tasks, which are usually called subroutines. These subroutines may include periodic data synchronization, data collation, data cleaning, and data statistics. Although these tasks do not require real-time execution, they often affect the operation of the main program because of their long time consumption and high resource consumption. For example, data synchronization may require a higher network transmission rate, while data collation, cleaning, and statistics may require more CPU computing power and memory resources. If these operations also require data persistence, such as writing to a database, then there will also be high requirements for the read and write speed of the disk.
[0041] The traditional approach is to run these subroutines during periods of low system load, such as at night, to reduce the impact on the main program. However, this approach has limitations because it does not take into account that the optimal running time of different subroutines may be different, and the fixed running time may not always match the actual availability of system resources. In addition, even during off-peak hours, if the resource requirements of the subroutines overlap with the main program, it may still cause resource contention and affect the performance of the main program. Therefore, a more complete method is needed to balance the resource usage of subroutines and the main program so that both can run efficiently.
[0042] In response to the above technical problems, the present application provides a resource optimization method, the idea of which is to: determine the operation index data of at least one subprogram to be run, the operation index data of the subprogram includes the subprogram's running time and the subprogram's high-demand resource index; for each subprogram in at least one subprogram, within a first time period, based on the operation index data of each subprogram, a sliding time window algorithm is used to determine the target time period for the operation of each subprogram, the length of the target time period is greater than or equal to the subprogram's running time, and the resources within the target time period meet the subprogram's high-demand resource index; the first time period is a time period in which the resource utilization rate of the main program is less than or equal to the first preset threshold; control at least one subprogram to run in the target time period corresponding to the subprogram. The present application observes the resource utilization of the main program and evaluates the resource utilization of the subprogram, and in the subprogram's runnable time period, combines the sliding time window algorithm to find a time period suitable for the subprogram to run, and controls the subprogram to run in a suitable time period, so as to achieve normal operation of the main program and subprograms, and at the same time, improve the efficiency of computing resource utilization.
[0043] The resource optimization method provided in the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0044] The resource optimization method provided in the embodiment of the present application can be applied to the resource optimization system 100. Figure 1 FIG. 1 shows a structure of the resource optimization system. Figure 1As shown, the resource optimization system includes:
[0045] Subprogram performance analysis device 101: used to analyze the subprogram's running index data, including resource utilization and running time;
[0046] Main program performance detection device 102: used to detect the resource utilization of the main program within the target period, and to obtain the resource utilization law of the main program running process according to the historical resource utilization;
[0047] Data processing device 103: using a sliding window algorithm to calculate a suitable subroutine running time period;
[0048] Evaluation device 104: used to evaluate the rationality of the sub-program running time period, and appropriately adjust the sub-program running time period in the case that the running of the sub-program affects the running of the main program.
[0049] In some embodiments, after the subprogram performance analysis device 101 and the main program performance detection device 102 respectively obtain the subprogram's operating index data and the main program's resource utilization, the data processing device 103 calculates the time period suitable for the subprogram to run according to the subprogram's operating index data and the main program's resource utilization, and controls the subprogram to run in the target time period. Then the evaluation device 104 determines whether the subprogram affects the main program by evaluating the main program's resource utilization after the subprogram runs. In the case where the subprogram affects the main program, the time period suitable for the subprogram to run is recalculated, and the subprogram's running time is adjusted.
[0050] It should be noted that the application scenarios of the embodiments of the present disclosure are not limited. The system architecture and business scenarios described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute limitations on the technical solutions provided by the embodiments of the present disclosure. It is known to those skilled in the art that with the evolution of technology and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.
[0051] The resource optimization method provided in the embodiment of the present application is described in detail below.
[0052] Figure 2 A flowchart of a resource optimization method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method includes:
[0053] S100: Determine the operation index data of at least one subroutine to be executed.
[0054] The subprogram's running indicator data includes the subprogram's running time and the subprogram's high-demand resource indicators.
[0055] In some embodiments, the at least one subprogram may be at least one subprogram subdivided from the same business requirement, or may be at least one subprogram that meets different business requirements, which is not limited in the present application.
[0056] The specific implementation process of the above step S100 is introduced in the following steps S101-S102 and will not be repeated here.
[0057] S200: For each subprogram of at least one subprogram, within a first time period, based on the operation index data of each subprogram, a sliding time window algorithm is used to determine a target time period for the operation of each subprogram.
[0058] Among them, the length of the target time period is greater than or equal to the running time of the subroutine, and the resources within the target time period meet the high-demand resource indicators of the subroutine; the first time period is a time period in which the resource utilization of the main program is less than or equal to the first preset threshold.
[0059] Among them, the resource utilization of the main program is less than or equal to the first preset threshold value, which means that the load operation can support additional sub-programs. The first preset threshold value is determined according to actual needs and is not limited in this application.
[0060] In some embodiments, the first time period may be a time period in which the resource utilization of the main program is low, as determined empirically, or a time period in which the resource utilization of the main program is low, as determined by calculation, wherein determining the first time period by calculation is specifically implemented as follows: determining the first time period based on time periods in which the resource utilization of the main program in multiple historical operating cycles is less than or equal to a first preset threshold.
[0061] In some embodiments, the historical operation cycle is determined according to the operation cycle of the business demand, and the first time period is determined by observing the average of the main program resource utilization rate at the time granularity in the historical operation cycle.
[0062] For example, assuming that the operation cycle of the business demand is one week and the time granularity is one minute, then for the utilization rate of each resource indicator of the main program, the data at the same time granularity is recorded every day within a week, and the average of these data is taken. In this way, the average of a total of 1440 time granularities is calculated every day, and finally the historical law of the main program resource utilization rate is obtained, and then the first time period is determined according to the historical law of the main program resource utilization rate.
[0063] It should be noted that during the period of observing the historical pattern of the resource utilization of the main program, the target subprogram was not running.
[0064] It should be noted that the sliding window algorithm is an algorithm that operates on a data stream or a continuous data sequence. It processes data by maintaining a fixed-size window and sliding it on the data sequence. This window can be of fixed size or dynamically changing, but the window always contains a portion of the continuous elements in the data sequence.
[0065] The specific implementation process of the above step S200 is introduced in the following steps S201-S203 and will not be repeated here.
[0066] S300: Control at least one subroutine to run in a target time period corresponding to the subroutine.
[0067] It can be understood that the present application observes the resource utilization of the main program and evaluates the resource utilization of the sub-program. During the sub-program runnable time period, combined with the sliding time window algorithm, it searches for a time period suitable for the sub-program to run, and controls the sub-program to run in a suitable time period, so as to achieve normal operation of the main program and sub-programs, and at the same time, improve the efficiency of computing resource utilization.
[0068] In some embodiments, when at least one subprogram includes a target subprogram, the target subprogram is any one of the at least one subprogram, such as Figure 3 As shown, the above step S100 can be specifically implemented as steps S101-S102:
[0069] S101: Detecting the values of various resource indicators of a target subprogram during a trial run, and the running time of the target subprogram.
[0070] The trial operation process of the target subprogram refers to the process of the target subprogram running alone.
[0071] Exemplarily, each resource indicator of the target subprogram includes, but is not limited to, at least one of the following: CPU utilization, memory utilization, and disk I / O speed.
[0072] In some embodiments, the present application uses different methods to detect the values of various resource indicators of the target subroutine for different computing systems. For example, for Windows systems, the performance monitor (WindowsPerformance Monitor) is used to detect indicators such as CPU usage, memory utilization, and disk I / O speed; for Linux systems, the top command, htop command, iostat command, vmstat command, etc. can be used to respectively detect the real-time status of CPU utilization, memory utilization, and I / O; for macOS systems, the activity monitor (Activity Monitor) can be used to view system resource usage.
[0073] S102: When the value of the target resource indicator of the target subprogram is the maximum value among the values of the target resource indicators of at least one subprogram, the target resource indicator is used as the high-demand resource indicator of the target subprogram.
[0074] Exemplarily, when the CPU utilization of the target subprogram is the maximum value among the CPU utilizations of at least one subprogram, the CPU utilization is used as the high-demand resource indicator of the target subprogram.
[0075] In some embodiments, the present application first allocates each target resource indicator as a high-demand resource indicator to a subprogram, and then determines the high-demand resource indicators for the remaining subprograms in turn until the high-demand resource indicators for all subprograms are determined.
[0076] Exemplarily, assuming that the resource indicators to be considered include indicator 1, indicator 2 and indicator 3, and the subprograms for which the running time period needs to be determined include program a, program b, program c, program d, program e and program f, firstly, for each subprogram, respectively detect the values of their indicators 1, indicator 2 and indicator 3. For indicator 1, if the value of indicator 1 of program a is the largest among all subprograms, then indicator 1 is determined as the high-demand resource indicator of program a; for indicator 2, if the value of indicator 2 of program b is the largest among all subprograms, then indicator 2 is determined as the high-demand resource indicator of program b; for indicator 3, if the value of indicator 3 of program c is the largest among all subprograms, then indicator 3 is determined as the high-demand resource indicator of program c. In this way, a subprogram is selected for each indicator. Then exclude program a, program b and program c, repeat the above process, and determine the high-demand resource indicators for the remaining programs d, program e and program f. If the same subprogram has multiple resource indicator values that are the largest, then the one with the largest utilization rate among multiple indicators is selected as the high-demand resource indicator of the subprogram.
[0077] In some embodiments, Figure 4 As shown, the above step S200 can be specifically implemented as steps S201-S203:
[0078] S201: Configure the window length and sliding step size of the sliding time window algorithm.
[0079] The window length is greater than or equal to the running time of the subroutine to ensure that all relevant data during the running of the subroutine can be captured. For example, if the subroutine is expected to run for 30 minutes, the window length should be at least 30 minutes to ensure that data from the entire running cycle is taken into account.
[0080] In some embodiments, if it is necessary to consider the resource utilization in the first time period as fully as possible, a smaller step size can be selected, such as 1 minute or 5 minutes, to obtain more fine-grained analysis results and improve the accuracy of the analysis results. However, a smaller step size may increase the computational burden. Therefore, the sliding step size can be set according to actual needs, and this application does not limit this.
[0081] S202: determining in sequence whether the resources in each time window meet the high-demand resource index of the subprogram based on the window length and the sliding step size, until a time window that meets the high-demand resource index of the subprogram is selected.
[0082] In some embodiments, starting from the start position of the first time period, a first time window is set. After completing the resource evaluation of the first time window, the window slides backward by a sliding step and starts to evaluate the next time window. The above process continues until the window sliding track completely covers the entire first time period. During the sliding process, all time windows that meet the high-demand resource indicators of the subroutine are recorded, and these time windows will be used as candidates for subsequent target time period selection.
[0083] S203: Determine a target time period based on a time window that satisfies a high-demand resource indicator of a subroutine.
[0084] In some embodiments, there may be multiple time windows that can meet the high demand indicators of the subroutine in the first time. In this case, further evaluation is required to determine the best target time period. Usually, the time window with the least resource usage is selected as the target time period. This reduces the operation of the subroutine without causing excessive impact on other parts of the system.
[0085] It can be understood that the sliding window algorithm can accurately identify the time period with low resource usage in the first time period by flexibly adjusting the window length and sliding step size, and allocate the most appropriate running time for the subroutine. This method optimizes resource allocation and makes resource management more efficient and accurate.
[0086] It should be noted that, in addition to occupying various resources, the subroutine may also cause other interferences to the main program during its operation. Since the target time period selected in the above step S300 does not take into account the actual impact of the subroutine, it is necessary to determine whether the target time period for the subroutine needs to be adjusted based on the actual operation of the subroutine.
[0087] In some embodiments, Figure 5 As shown, after the above step S300, the resource optimization method provided by the present application further includes steps S400-S500:
[0088] S400: When it is determined that the running of the subprogram affects the running of the main program, a target time period for the running of the subprogram is adjusted to obtain an adjusted target time period.
[0089] As a possible implementation manner, the above-mentioned determination of whether the running of the subprogram affects the running of the main program can be specifically implemented as steps a1-a2:
[0090] a1: Periodically detect the resource utilization of the main program.
[0091] a2: when the difference between the resource utilization rate of the main program at the first moment of the first operation cycle and the resource utilization rate of the main program at the first moment of the second operation cycle is greater than or equal to a second preset threshold, it is determined that the operation of the subprogram affects the operation of the main program.
[0092] In some embodiments, after the control subprogram runs in the target time period, if the resource utilization of the main program at a certain moment suddenly increases and changes greatly, it means that the operation of the subprogram has affected the main program. For example, if the CPU utilization of the main program changes by more than 5% in two consecutive operation cycles, that is, a large fluctuation occurs, it may indicate that the operation of the subprogram has a significant impact on the main program. Among them, the second threshold is set according to the specific situation and historical data of the main program, and this application does not limit it here.
[0093] As another possible implementation, the above-mentioned determination that the operation of the subprogram affects the operation of the main program may also be specifically implemented as step b1: when a fault is detected in the main program, determining that the operation of the subprogram affects the operation of the main program.
[0094] Exemplarily, the main program failure may be an unexpected interruption, an infinite loop, etc.
[0095] S500: The control subroutine runs during the adjusted target time period.
[0096] In some embodiments, when it is determined that the operation of the subprogram affects the operation of the main program, the target time period is reselected for the subprogram according to the specific method of the above step S200 and steps S201-S203. In this process, the resource utilization of the main program detected is the resource utilization of the main program detected when the subprogram is running.
[0097] In some embodiments, as time goes by, due to the influence of various unknown factors, the overall business will inevitably undergo some changes in the long run. In order to ensure the continuity of the overall process, the operation of the main program and sub-programs is regularly evaluated and the operation mode of the sub-programs is adjusted.
[0098] It is understandable that the resource optimization method provided in the embodiment of the present application determines its high-demand resource indicators, such as CPU utilization or memory utilization, by detecting the resource occupancy and running time of the subroutine during the trial run, and then uses the sliding time window algorithm to arrange a target time period that meets its resource requirements for each subroutine during the time period when the resource utilization of the main program is low. This method not only ensures the operation of the main program, but also maximizes the efficiency of the use of computing resources. In addition, by periodically detecting and dynamically adjusting the operation mode of the subroutine, the system can adapt to business changes and maintain the continuity and stability of the process.
[0099] It can be seen that the above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, the embodiment of the present application provides a hardware structure and / or software module corresponding to each function. It should be easily appreciated by those skilled in the art that, in combination with the modules and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0100] The embodiment of the present application can divide the resource optimization device into functional modules according to the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. Optionally, the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0101] Figure 6 This is a schematic diagram of the structure of a resource optimization device provided in an embodiment of the present application, which can implement the resource optimization method provided in the above method embodiment. Figure 6 As shown, the resource optimization device 200 includes: a detection unit 201, a processing unit 202 and a control unit 203.
[0102] The detection unit 201 is used to determine the running indicator data of at least one subprogram to be run, where the running indicator data of the subprogram includes the running time of the subprogram and the high demand resource indicator of the subprogram;
[0103] The processing unit 202 determines, for each subprogram of at least one subprogram, a target time period for the operation of each subprogram based on the operation index data of each subprogram within a first time period by using a sliding time window algorithm, wherein the length of the target time period is greater than or equal to the operation time of the subprogram, and the resources within the target time period meet the high-demand resource index of the subprogram; the first time period is a time period in which the resource utilization rate of the main program is less than or equal to a first preset threshold value;
[0104] The control unit 203 controls at least one subprogram to run in a target time period corresponding to the subprogram.
[0105] A possible implementation method, processing unit 202, is specifically used to configure the window length and sliding step of the sliding time window algorithm; wherein the window length is greater than or equal to the running time of the subroutine; based on the window length and the sliding step, it is determined in turn whether the resources in each time window meet the high-demand resource indicators of the subroutine, until a time window that meets the high-demand resource indicators of the subroutine is selected; based on the time window that meets the high-demand resource indicators of the subroutine, a target time period is determined.
[0106] In another possible implementation, at least one subprogram includes a target subprogram, and the target subprogram is any subprogram in the at least one subprogram; the detection unit 201 is specifically used to detect the values of various resource indicators of the target subprogram during the trial operation, as well as the running time of the target subprogram; when the value of the target resource indicator of the target subprogram is the maximum value among the values of the target resource indicators of at least one subprogram, the target resource indicator is used as a high-demand resource indicator of the target subprogram.
[0107] In another possible implementation, the processing unit 202 is specifically configured to determine the first time period based on a time period in which the resource utilization rate of the main program is less than or equal to the first preset threshold value in a plurality of historical operation cycles.
[0108] In another possible implementation, the processing unit 202 is further used to adjust the target time period for the subprogram to obtain an adjusted target time period when it is determined that the operation of the subprogram affects the operation of the main program; the control unit 203 is further used to control the subprogram to run in the adjusted target time period.
[0109] In another possible implementation, the processing unit 202 is specifically used to periodically detect the resource utilization of the main program; when the difference between the resource utilization of the main program at the first moment of the first operating cycle and the resource utilization of the main program at the first moment of the second operating cycle is greater than or equal to a second preset threshold, it is determined that the operation of the sub-program affects the operation of the main program.
[0110] In another possible implementation, the processing unit 202 is specifically configured to determine whether the operation of the subprogram affects the operation of the main program when a failure of the main program is detected.
[0111] In the case of implementing the functions of the above-mentioned integrated modules in the form of hardware, the embodiment of the present invention provides a possible structural diagram of the electronic device involved in the above-mentioned embodiment. Figure 7 As shown, the electronic device 900 includes: a processor 902 , a communication interface 903 , and a bus 904 . Optionally, the electronic device 900 may further include a memory 901 .
[0112] The processor 902 may be a processor that implements or executes various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of the present application. The processor 902 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of the present application. The processor 902 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0113] The communication interface 903 is used to connect with other devices via a communication network, such as Ethernet, wireless access network, wireless local area network (WLAN), etc.
[0114] The memory 901 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0115] As a possible implementation, the memory 901 may exist independently of the processor 902, and the memory 901 may be connected to the processor 902 via a bus 904 to store instructions or program codes. When the processor 902 calls and executes the instructions or program codes stored in the memory 901, the resource optimization method provided in the embodiment of the present invention can be implemented.
[0116] In another possible implementation, the memory 901 may also be integrated with the processor 902 .
[0117] The bus 904 may be an extended industry standard architecture (EISA) bus, etc. The bus 904 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0118] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the service calling device can be divided into different functional modules to complete all or part of the functions described above.
[0119] The present application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by computer program instructions to instruct the relevant hardware, and the program can be stored in the above computer-readable storage medium. When the computer program instructions are executed on a computer, the computer executes the resource optimization method described in any of the above embodiments.
[0120] Exemplarily, the above-mentioned computer-readable storage media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks or magnetic tapes, etc.), optical disks (e.g., compact disks (CD), digital versatile disks (DVD), etc.), smart cards and flash memory devices (e.g., erasable programmable read-only memory (EPROM), cards, sticks or key drives, etc.). The various computer-readable storage media described in the present disclosure may represent one or more devices and / or other machine-readable storage media for storing information. The term "machine-readable storage medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing and / or carrying instructions and / or data.
[0121] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program product is run on a computer, the computer is enabled to execute any one of the resource optimization methods provided in the above embodiments.
[0122] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A resource optimization method, characterized in that: The method comprises: Determine running indicator data of at least one subprogram to be run, wherein the running indicator data of the subprogram includes a running time of the subprogram and a high-demand resource indicator of the subprogram; For each subprogram in at least one of the subprograms, within a first time period, based on the running indicator data of each subprogram, a sliding time window algorithm is used to determine a target time period for the running of each subprogram, the length of the target time period is greater than or equal to the running time of the subprogram, and the resources within the target time period meet the high-demand resource indicators of the subprogram; the first time period is a time period in which the resource utilization rate of the main program is less than or equal to a first preset threshold; Control at least one of the subroutines to run during a target time period corresponding to the subroutines.
2. The method according to claim 1, characterized in that In the first time period, based on the operation index data of each subroutine, a sliding time window algorithm is used to determine the target time period for the operation of each subroutine, including: Configure the window length and sliding step length of the sliding time window algorithm; wherein the window length is greater than or equal to the running time of the subroutine; Determining in sequence whether the resources in each time window meet the high-demand resource index of the subprogram based on the window length and the sliding step size, until a time window that meets the high-demand resource index of the subprogram is selected; The target time period is determined based on a time window that satisfies the high-demand resource indicator of the subroutine.
3. The method according to claim 1, characterized in that: The at least one subprogram includes a target subprogram, and the target subprogram is any subprogram in the at least one subprogram; The step of determining the operation index data of at least one subroutine to be executed includes: Detecting the values of various resource indicators of the target subprogram during the trial operation and the running time of the target subprogram; When the value of the target resource indicator of the target subprogram is the maximum value among the values of the target resource indicators of the at least one subprogram, the target resource indicator is used as the high-demand resource indicator of the target subprogram.
4. The method according to claim 1, characterized in that The method further comprises: The first time period is determined based on a time period in which the resource utilization of the main program is less than or equal to a first preset threshold in a plurality of historical operation cycles.
5. The method according to claim 1, characterized in that After the controlling at least one of the subprograms is executed during the target time period corresponding to the subprogram, the method further comprises: In the case where it is determined that the running of the subprogram affects the running of the main program, adjusting the target time period for the running of the subprogram to obtain an adjusted target time period; The subroutine is controlled to run during the adjusted target time period.
6. The method according to claim 5, characterized in that The determining that the running of the subroutine affects the running of the main program includes: Periodically detecting resource utilization of the main program; When the difference between the resource utilization rate of the main program at the first moment of the first operation cycle and the resource utilization rate of the main program at the first moment of the second operation cycle is greater than or equal to a second preset threshold, it is determined that the operation of the sub-program affects the operation of the main program.
7. The method according to claim 5, characterized in that The determining that the running of the subroutine affects the running of the main program includes: In the case where a fault is detected in the main program, it is determined that the operation of the sub-program affects the operation of the main program.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the processor is coupled to the memory; the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor to enable a computer device to implement the resource optimization method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes computer-executable instructions. When the computer-executable instructions are executed on a computer, the computer is enabled to execute the resource optimization method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed on an electronic device, the electronic device executes the resource optimization method according to any one of claims 1 to 7.