Multitasking optimization method for desktop applications

By segmenting the application into subtasks and performing fragmented management, the problem of insufficient computing power in multitask processing by mobile terminals is solved, efficient utilization of resources and orderly concurrent execution of tasks are achieved, and system lag is reduced.

CN120085992BActive Publication Date: 2025-08-29BEIJING REYUAN NETWORK CULTURE MEDIA CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510552295.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-29
Estimated Expiration
2045-04-29

AI Technical Summary

Technical Problem

When existing mobile terminals process multiple applications in parallel, insufficient computing power leads to lag, and existing container technology and cloud technology fail to effectively perform granular scheduling and matching task resources.

Method used

The target application is divided into multiple subtasks, obtain the attribute information and dependencies of each subtask, form a task relationship diagram, and match the subtask set and nodes based on the node resource information. By dividing CPU, GPU and memory resource units for fragmentation management, ensuring efficient resource utilization.

Benefits of technology

It improves the multi-task processing efficiency of mobile terminals, reduces system lag, and realizes the maximum utilization rate of hardware resources and the orderly concurrent execution of multi-tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120085992B_ABST
    Figure CN120085992B_ABST
Patent Text Reader

Abstract

The present invention relates to a multi-task processing optimization method for desktop applications, comprising: dividing a target application into multiple subtasks to obtain a set of subtasks; obtaining attribute information of each subtask; obtaining multiple subtask sets and a task relationship graph of each subtask set; obtaining task set resource information of the subtask sets; obtaining node resource information of all nodes in a cluster; matching subtask sets with nodes based on the task set resource information of each subtask set and the node resource information of each node in the cluster; and executing each subtask in the subtask set on the corresponding node. The present invention ensures maximum utilization of node hardware resources from the perspective of the finest granularity management, while ensuring the orderly and concurrent execution of multiple tasks to the greatest extent possible, thereby improving the response efficiency of the service terminal and reducing the occurrence of system freezes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of multitasking, and in particular to a multitasking optimization method for desktop applications. Background Art

[0002] With the increasing demand for mobile terminals and the introduction of various application software, it is an inevitable requirement for mobile terminals to provide multi-tasking management.

[0003] However, for some mobile terminals with limited computing power, when users open multiple applications in parallel and switch back and forth between multiple applications, the computing power of existing mobile terminals cannot support the execution of a large number of concurrent tasks, resulting in frequent application freezes and affecting the user experience.

[0004] Container technology and cloud technology are currently common technologies for concurrent multi-tasking processing. Container technology can isolate hardware resources into different nodes to perform targeted task scheduling and resource allocation, thereby improving resource utilization. Cloud technology can provide multiple cloud platforms to process workflows in parallel to improve workflow processing efficiency. In this case, applications on mobile terminals can use the hardware resources on the local machine or utilize resources on remote servers.

[0005] However, when performing task scheduling, existing container or cloud technologies mostly focus on the resources that the node itself can provide and the resources required by the task, and do not have a technical solution that slices and divides tasks and node resources to achieve more granular resource scheduling and matching. Summary of the Invention

[0006] To address the deficiencies of the prior art, the present invention provides a multi-tasking optimization method for desktop applications, comprising the following steps:

[0007] Step S1: Split the target application into multiple subtasks to obtain a set of subtasks;

[0008] Step S2: Acquire attribute information of each subtask, including the dependency relationship between the corresponding subtask and other subtasks and task resource information required to execute the corresponding subtask;

[0009] Step S3: Based on the attribute information of each subtask, a plurality of subtask sets and a task relationship diagram of each subtask set are obtained;

[0010] Step S4: for each subtask set, based on the task resource information of each subtask, obtain the task set resource information of the subtask set;

[0011] Step S5: Obtain node resource information of all nodes in the cluster;

[0012] Step S6: matching subtask sets with nodes based on the task set resource information of each subtask set and the node resource information of each node in the cluster;

[0013] Step S7: Based on the task relationship graph of each subtask set, complete the execution of each subtask in each subtask set on the corresponding node.

[0014] In step S3, the subtask set is divided into the following steps:

[0015] Step S31: Take a subtask from the subtask set, mark it as the first subtask, and obtain the dependent task set of the first subtask, which consists of all subtasks that have a dependent relationship with the first subtask;

[0016] Step S32: adding the first subtask and all subtasks in the dependent task set of the first subtask into a set to obtain an initial subtask set;

[0017] Step S33: Mark all subtasks in the dependent task set obtained in step S31 as second subtasks;

[0018] Step S34: Sequentially extract the second subtasks from the initial subtask set, and perform the following operations for each second subtask:

[0019] Step S341: Mark it as the first subtask;

[0020] Step S342: Obtain its dependent task set, which consists of all subtasks that have a dependency relationship with the extracted second subtask;

[0021] Step S343: Determine whether there is a subtask in the dependent task set that is not included in the initial subtask set. If so, mark the subtask that is not included in the initial subtask set as the second subtask and add it to the initial subtask set to obtain an updated initial subtask set.

[0022] Step S35: Determine whether there is a second subtask in the initial subtask set:

[0023] If not, the final initial subtask set is determined as a subtask set, and step S36 is executed;

[0024] If yes, then re-execute step S34;

[0025] Step S36: Determine whether there are unfinished subtasks. If so, obtain a subtask from the unfinished subtasks as the first subtask and repeat steps S31 to S35. If not, terminate.

[0026] The unfinished subtask is a subtask that exists in the set of subtasks but does not exist in any subtask set.

[0027] In step S3, a task relationship diagram of each subtask set is formed through the following steps:

[0028] Step S37: Traverse all subtasks in the subtask set, determine for any subtask that it is the third subtask, and obtain the task relationship value of the third subtask and each subtask in its dependent task set based on the dependency relationship between the third subtask and the subtasks in its dependent task set;

[0029] Step S38: Obtaining the levels of all subtasks in each subtask set in the task relationship graph based on the existing task relationship values;

[0030] Step S39: Starting from the first level, obtain the dependency relationship between each subtask in each level and each subtask in the next level to obtain the final task relationship graph.

[0031] In step S5, the node resource information of all nodes in the cluster includes CPU resource information, GPU resource information and memory resource information.

[0032] In step S6, matching of subtask sets with nodes is completed based on the task set resource information of each subtask set and the node resource information of each node in the cluster, including:

[0033] Step S61: Based on the CPU resource information, GPU resource information, and memory resource information of each node in the cluster, obtain the resource occupancy rate of each node;

[0034] Step S62: Apply for a first queue and sort the nodes based on resource occupancy;

[0035] Step S63: Apply for a second queue and sort the subtask sets based on the task set resource information;

[0036] Step S64: Take a subtask set from the second queue in order and match it with the first node in the first queue:

[0037] If the match is successful, the extracted subtask set is scheduled to the first node;

[0038] If the match fails, the next node is taken out in sequence for matching until a match succeeds.

[0039] Update the node resource information of the successfully matched node;

[0040] Step S65: re-execute step S64, and sequentially take out the next subtask set from the second queue for matching, until all subtask sets are successfully scheduled.

[0041] Among them, in step S61, the CPU resource information is the number of CPU resource units obtained after dividing the CPU resources into multiple CPU resource units, the GPU resource information is the number of GPU resource units obtained after dividing the GPU resources into multiple GPU resource units, and the memory resource information is the number of memory resource units obtained after dividing the memory resources into multiple memory resource units.

[0042] Wherein, in the step S61,

[0043] When dividing CPU resources into multiple CPU resource units, the CPU resource volume of each node is determined based on the CPU system clock frequency, instruction cycle, word length, and CPU cache. The CPU resource volume is divided based on the CPU resource volume, and each CPU resource unit provides the same CPU resource volume.

[0044] When dividing GPU resources into multiple GPU resource units, they are divided according to the number of GPU hardware cores, and each GPU resource unit provides the same number of hardware cores;

[0045] When memory resources are divided into multiple memory resource units, they are divided according to the memory size, and each memory resource unit provides the same memory size.

[0046] In step S61, the resource occupancy rate of each node is obtained by the following formula:

[0047] ;

[0048] in, 、 and Respectively represent the number of idle CPU resource units, idle GPU resource units, and idle memory resource units of the corresponding node;

[0049] 、 and Represents the total number of idle CPU resource units, total number of idle GPU resource units, and total number of idle memory resource units of all nodes in the cluster respectively;

[0050] α, β, and γ represent the weights of CPU resources, GPU resources, and memory resources, respectively, when measuring the hardware resource capabilities of a node.

[0051] The present invention fragments the target application tasks and the hardware resources of the nodes, and performs targeted scheduling and execution of each subtask based on the division results. In this way, from the perspective of the most fine-grained management, the maximum utilization of the node hardware resources is ensured, and at the same time, the orderly and concurrent execution of multiple tasks is ensured to the greatest extent, thereby improving the response efficiency of the service terminal and reducing the occurrence of system freezes. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 The figure is a logic flow chart of the desktop application-oriented multi-tasking optimization method of the present invention.

[0053] Figure 2 This is a flow chart of a method for implementing subtask set partitioning in the desktop application-oriented multitasking optimization method of the present invention.

[0054] Figure 3 This is a task relationship diagram of the desktop application-oriented multi-tasking optimization method of the present invention.

[0055] Figure 4 This is another task relationship diagram in the desktop application-oriented multi-tasking optimization method of the present invention.

[0056] Figure 5 This is another task relationship diagram in the desktop application-oriented multi-tasking optimization method of the present invention.

[0057] Figure 6 This is a flowchart for implementing the method for optimizing desktop application multitasking of the present invention for determining the levels of all subtasks in a subtask set in a task relationship diagram. DETAILED DESCRIPTION

[0058] In order to have a further understanding of the technical solution and beneficial effects of the present invention, the technical solution and beneficial effects of the present invention are described in detail below with reference to the accompanying drawings.

[0059] 1. Multi-tasking optimization method

[0060] Please combine Figure 1 FIG. 1 is a logic flow chart of a multi-tasking optimization method for desktop applications according to the present invention. The multi-tasking optimization method for desktop applications according to the present invention comprises the following steps:

[0061] Step S1: Split the target application into multiple subtasks to obtain a set of subtasks, wherein the target application is a desktop application triggered by the user;

[0062] Step S2: Acquire attribute information of each subtask, including the dependency relationship between the corresponding subtask and other subtasks and task resource information required to execute the corresponding subtask;

[0063] Among them, obtaining the dependency relationship of subtasks and the task resource information required to execute subtasks are both existing technologies; the task resource information required to execute subtasks can be evaluated based on resource data of historical tasks.

[0064] Step S3: Based on the attribute information of each subtask, multiple subtask sets and a task relationship graph of each subtask set are obtained; specifically, based on the dependency relationship between each subtask and other subtasks, multiple subtask sets and a task relationship graph of each subtask set are obtained; wherein, the multiple subtask sets have no dependency relationship with each other, in other words, any subtask in a subtask set has no dependency relationship with all subtasks in other subtask sets;

[0065] Step S4: For each subtask set, based on the task resource information of each subtask (i.e., the task resource information required to execute each subtask), obtain the task set resource information of the subtask set. The task set resource information can be understood as the sum of the resources required to execute all subtasks in the subtask set.

[0066] Step S5: Obtain node resource information of all nodes in the cluster. Node resource information can be understood as the hardware resources that the nodes can provide.

[0067] Step S6: matching subtask sets with nodes based on the task set resource information of each subtask set and the node resource information of each node in the cluster;

[0068] Step S7: Based on the task relationship graph of each subtask set, complete the execution of each subtask in the subtask set on the corresponding node. After each subtask is executed, release the executed subtask from the subtask set and the task relationship graph. After each subtask is executed, release the node resources on the node to which the subtask set belongs, and update the node resource information of the node to which it belongs.

[0069] 2. Subtask Set Division

[0070] Figure 2 This is a flow chart of the implementation method of subtask set division in the desktop application-oriented multitasking optimization method of the present invention, such as Figure 2 As shown, in the present invention, the subtask set division specifically includes the following steps:

[0071] 1. Take a subtask from the subtask set, mark it as the first subtask, and obtain the dependent task set of the first subtask. The dependent task set consists of all subtasks that have a dependency relationship with the first subtask;

[0072] 2. Add the first subtask and all subtasks in its dependent task set to a set to obtain an initial subtask set;

[0073] 3. Mark all subtasks in the dependent task set obtained in step 1 as second subtasks;

[0074] 4. Sequentially take a second subtask from the initial subtask set and perform the following operations:

[0075] 41. Mark it as the first subtask;

[0076] 42. Obtain its dependent task set, which consists of all subtasks that have a dependency relationship with the retrieved second subtask;

[0077] 43. Determine whether there are subtasks in the dependent task set that are not included in the initial subtask set: If so, mark the subtask that is not included in the initial subtask set as the second subtask and add it to the initial subtask set to obtain an updated initial subtask set;

[0078] 5. Determine whether there is a second subtask in the initial subtask set:

[0079] If it does not exist, the final initial subtask set is determined as a subtask set and step 6 is executed;

[0080] If it exists, execute step 4 again.

[0081] 6. Determine whether there are unfinished subtasks. If so, get a subtask from the unfinished subtask as the first subtask and repeat steps 1-5. If not, end.

[0082] The unfinished subtask is a subtask that exists in the set of subtasks but does not exist in any subtask set.

[0083] Table 1 shows the dependent task set and task relationship value corresponding to each subtask in the set of subtasks of the present invention. The dependent task set of each subtask is composed of all subtasks that have a dependency relationship with the subtask. The meaning of the task relationship value is detailed below.

[0084] Table 1: The dependent task set and task relationship value corresponding to each subtask in the subtask set

[0085]

[0086] It should be noted that for a first subtask, the subtasks in its dependent task set are the subtasks that have direct or indirect dependencies on it. However, whether it is a direct dependency or an indirect dependency, the dependency path is unidirectional. Figures 3 to 5 To understand:

[0087] For subtask t1, since subtasks t3 and t5 depend on subtask t1, subtask t7 depends on subtasks t3 and t5, and subtask t8 depends on subtask t5, the dependent task set of subtask t1 includes subtasks t3, t5, t7, and t8; although subtask t8 depends on subtask t6, and subtask t6 depends on subtasks t2 and t3, subtask t7 depends on subtasks t3 and t5, and subtask t8 depends on subtask t5. 12 , but subtasks t6, t2 and t 12 The dependency path of subtask t8 has changed (turned back in the opposite direction), so subtasks t6, t2 and t 12 It cannot be included in the dependent task set of subtask t1;

[0088] Similarly: for subtask t3, its dependent task set includes subtasks t1 and t7, but not Figure 3 Other subtasks as shown;

[0089] For subtask t5, its dependent task set includes subtasks t1, t7, and t8, but not Figure 3 Other subtasks as shown;

[0090] For subtask t6, its dependent task set includes subtasks t2 and t8, but not Figure 3 Other subtasks as shown;

[0091] For subtask t2, its dependent task set includes subtasks t6 and t8, but not Figure 3 Other subtasks as shown.

[0092] The dependent task sets of the remaining subtasks can be deduced in the same way, and the present invention will not elaborate on them one by one here.

[0093] Therefore, when obtaining dependency relationships, the present invention only obtains dependency relationships with subtasks that have a one-way dependency path. In this way, the attribute information of each subtask is relatively simple, avoiding the subtask attribute information from occupying too much space, and avoiding the excessive cumbersomeness in collecting the attribute information of the subtask, which helps to reduce system power consumption.

[0094] Combined with Table 1 and Figures 3 to 5 , an example is given to illustrate the method of dividing the subtask set of the present invention:

[0095] 1. For the set of subtasks {t1, t2, t3, t4, t5, t6, t7, t8, t9, t 10 , t11 , t 12 , t 13 , t 14 , t 15 , t 16 , t 17 , t 18}, take out a subtask t1, mark it as the first subtask, and obtain the dependent task set {t3, t5, t7, t8}; add subtask t1 and all subtasks in its dependent task set into a set to obtain the initial subtask set {t1, t3, t5, t7, t8};

[0096] 2. Mark all subtasks in the dependent task set {t3, t5, t7, t8} as the second subtask;

[0097] 3. Traverse the second subtask in the initial subtask set, such as:

[0098] After traversing to subtask t3, we mark it as the first subtask and then obtain its dependent task set {t1, t7}. The subtasks in this dependent task set {t1, t7} already exist in the initial subtask set {t1, t3, t5, t7, t8}.

[0099] After traversing to subtask t5, mark it as the first subtask and then obtain its dependent task set {t1, t7, t8}. The subtasks in the dependent task set {t1, t7, t8} also exist in the initial subtask set {t1, t3, t5, t7, t8}.

[0100] After traversing to subtask t7, we mark it as the first subtask and then obtain its dependent task set {t1, t3, t5}. The subtasks in this dependent task set {t1, t3, t5} also exist in the initial subtask set {t1, t3, t5, t7, t8}.

[0101] Traversing to subtask t8, first mark it as the first subtask, and then obtain its dependent task set {t1, t2, t5, t6, t 12}, there are subtasks t2, t6, t7 that are not included in the initial subtask set {t1, t3, t5, t7, t8} 12 , and subtasks t2, t6, and t 12 are marked as the second subtask and added to the initial subtask set {t1, t3, t5, t7, t8}, and the updated initial subtask set {t1, t3, t5, t7, t8, t2, t6, t8} is obtained. 12};

[0102] 4. Determine whether the second subtasks t2, t6, and t12 , continue to traverse the second subtask in the initial subtask set, such as:

[0103] Traversing to subtask t2, first mark it as the first subtask, and then obtain its dependent task set {t6, t8}. The subtasks in the dependent task set {t6, t8} already exist in the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t8}. 12}middle;

[0104] Traversing to subtask t6, first mark it as the first subtask, and then obtain its dependent task set {t2, t8, t 12}, the dependent task set {t2, t8, t 12} also exist in the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12}middle;

[0105] Traversed to subtask t 12 , first mark it as the first subtask, then obtain its dependent task set {t6, t8, t 13}, there are tasks that are not included in the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12} in the subtask t 13 , and subtask t 13 Mark it as the second subtask and add it to the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12}, the updated initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12 , t 13};

[0106] 5. Determine whether the second subtask t exists in the initial subtask set 13 , for subtask t 13 , first mark it as the first subtask, then get its dependent task set {t 12}, the dependent task set {t 12} already exists in the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12 , t 13}middle.

[0107] 6. At this time, the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12 , t 13}, then the initial subtask set {t1, t3, t5, t7, t8, t2, t6, t 12 , t13}Identified as a subtask set.

[0108] 7. Determine whether there are unfinished subtasks t4, t9, and t 10 , t 11 , t 14 , t 15 , t 16 , t 17 , t 18 , pick one out of them, repeat steps 1-6, and perform the determination of the next subtask set.

[0109] 3. Formation of Task Relationship Diagram

[0110] The method for forming a task relationship graph of a subtask set in the desktop application-oriented multitasking optimization method of the present invention comprises the following steps:

[0111] 1. Traverse all subtasks in the subtask set, determine for any subtask that it is the third subtask, and obtain the task relationship value of the third subtask and each subtask in its dependent task set based on the dependency relationship between the third subtask and the subtasks in its dependent task set;

[0112] Among them, the task relationship value can be expressed as R i,j , R i,j It is a non-zero integer. The positive or negative value represents the direction of the dependency relationship. The absolute value of the value represents the length of the dependency path. The subscripts i and j represent subtask i and subtask j respectively.

[0113] Specifically, R i,j When the value of is positive, it means that the execution of subtask j depends on the execution of subtask i. i,j When the value is negative, it means that the execution of subtask i depends on the execution of subtask j. Therefore, it can be understood that: for subtask i and subtask j with a dependent relationship, R i,j With R j,i The values ​​of are one positive and one negative, but the absolute values ​​are the same.

[0114] In addition, R i,j When the absolute value of is 1, it means that there is a direct dependency relationship between subtasks i and j; when the absolute value is 2, it means that there is an indirect dependency relationship between subtasks i and j, and the dependency relationship between the two is generated through another subtask; when the absolute value is 3, it means that there is an indirect dependency relationship between subtasks i and j, and the dependency relationship between the two is generated through two other subtasks, and so on.

[0115] The task relationship values ​​between each subtask and the subtasks in its dependent task set are shown in Table 1.

[0116] 2. Based on the existing task relationship value R i,j Get the levels of all subtasks in the task relationship graph of the subtask set;

[0117] When implementing it specifically, Figure 6 The following is a detailed implementation flow chart, please refer to Figure 6 As shown, the implementation process of the desktop application-oriented multitasking optimization method of the present invention for determining the hierarchy of all subtasks in a task relationship graph in a subtask set based on the existing task relationship values ​​is as follows:

[0118] (1) Randomly determine a subtask as the benchmark subtask;

[0119] (2) Obtain the dependent task set of the benchmark subtask, mark all subtasks in the benchmark subtask dependent task set as non-benchmark subtasks, traverse the non-benchmark subtasks in the benchmark subtask dependent task set, and for each non-benchmark subtask, determine its level correction value relative to the benchmark subtask as R i,j ; Where i and j represent the non-benchmark subtask and the benchmark subtask respectively;

[0120] (3) All subtasks in the benchmark subtask dependency task set that have completed calibration are marked as calibrated subtasks, and all subtasks other than the benchmark subtask and the calibrated subtask in the subtask set are marked as uncalibrated subtasks;

[0121] (4) Determine whether there are uncalibrated subtasks in the subtask set:

[0122] If it does not exist, go to step (7);

[0123] If it exists, execute step (5);

[0124] (5) Traverse the uncalibrated subtasks and perform the following operations for each uncalibrated subtask:

[0125] Determine whether there are any subtasks in the calibrated subtask that have dependencies on the uncalibrated subtask:

[0126] If so, randomly select one and determine the level correction value of the uncalibrated subtask based on the following formula. Then, mark the uncalibrated subtask as a calibrated subtask.

[0127] Level correction value of uncalibrated subtask = H + R m,n ;

[0128] Where H is the level correction value of the randomly selected calibrated subtask that has a dependency relationship with the uncalibrated subtask; R m,nis the task relationship value between the randomly selected calibrated subtask and the uncalibrated subtask that has a dependency relationship with the uncalibrated subtask; where m represents the uncalibrated subtask, and n represents the randomly selected calibrated subtask that has a dependency relationship with the uncalibrated subtask;

[0129] If it does not exist, its level correction value will not be determined in this round of operation;

[0130] (6) Re-execute step (4) until there are no uncalibrated subtasks in the subtask set, that is, all subtasks in the subtask set have obtained a level correction value based on the above method;

[0131] (7) The priority of the benchmark subtask in the task relationship diagram is determined to be level 0. The level correction value of other subtasks other than the benchmark subtask is their priority in the task relationship diagram. The level of each subtask in the task relationship diagram is determined according to the priority.

[0132] 3. Starting from the first level, obtain the dependency relationship between each subtask in each level and each subtask in the next level to obtain the final task relationship diagram.

[0133] Still Figure 3 As shown, Figure 3 The corresponding subtask set includes {t1, t2, t3, t5, t6, t7, t8, t 12 , t 13}, the method for determining the task relationship diagram for this subtask set is as follows.

[0134] 1. Determine the task relationship values ​​between all subtasks and the subtasks in their dependent task set, which are shown in Table 1.

[0135] 2. Determine the hierarchy

[0136] (1) Randomly determine a subtask, such as subtask t7 as the benchmark subtask;

[0137] (2) Obtain the dependent task set {t1, t3, t5} of the benchmark subtask, mark all subtasks in the dependent task set {t1, t3, t5} as non-benchmark subtasks, traverse the non-benchmark subtasks in the dependent task set {t1, t3, t5}, and for each non-benchmark subtask, determine its level correction value relative to the benchmark subtask, which are R 1,7 、R 3,7 、R 5,7 The values ​​of are 2, 1, and 1 respectively;

[0138] (3) Mark the subtasks t1, t3, and t5 in the dependent task set {t1, t3, and t5} of the benchmark subtask t7 that has completed the calibration as calibrated subtasks, and mark the subtask set {t1, t2, t3, t5, t6, t7, t8, t9} as calibrated subtasks. 12 , t 13} in the benchmark subtask and other subtasks t2, t6, t8, t 12 , t 13 Marked as uncalibrated subtask;

[0139] (4) Determine whether there are uncalibrated subtasks t2, t6, t8, t 12 , t 13 ;

[0140] (5) First round: for uncalibrated subtasks t2, t6, t 12 , t 13 ,Among the existing calibrated subtasks t1, t3, and t5, there are no subtasks with ,dependencies, so in this round of operation, their level correction values ​​are ,not determined yet;

[0141] For the uncalibrated subtask t8, among the existing calibrated subtasks t1, t3, and t5, there are subtasks t1 and t5 that have a dependency relationship with it;

[0142] Randomly select one of the subtasks t5, and the level correction value of the uncalibrated subtask t8 is determined to be the level correction value of the calibrated subtask t5 + R 8,5 =1+(-1)=0;

[0143] Afterwards, the uncalibrated subtask t8 is marked as a calibrated subtask. At this time, the calibrated subtask includes subtasks t1, t3, t5, and t8.

[0144] (6) Re-execute step (4). At this time, there are uncalibrated subtasks t2, t6, and t 12 , t 13 ;

[0145] (7) Second round: for the uncalibrated subtask t 13 ,Among the existing calibrated subtasks t1, t3, t5, and t8, there is no subtask with which they have a ,dependency relationship, so in this round of operation, their level correction values ​​are ,temporarily determined;

[0146] For the uncalibrated subtasks t2, t6, t 12 Among the calibrated subtasks t1, t3, t5, and t8, there is a subtask t8 that has a dependency relationship with them. Based on the same logic as the first round, subtasks t2, t6, and t8 are determined. 12The level correction values ​​are: 2, 1, 2;

[0147] After that, the uncalibrated subtasks t2, t6, t 12 Marked as calibrated subtasks, the calibrated subtasks include subtasks t2, t6, t 12 , t1, t3, t5, t8;

[0148] (8) Re-execute step (4). At this time, only the uncalibrated subtask t exists in the subtask set. 13 ;

[0149] (9) Round 3: Based on the uncalibrated subtask t 13 With the calibrated subtask t 12 Dependency relationship, determine the uncalibrated subtask t 13 The level correction value is 1, then the uncalibrated subtask t 13 Determined as a calibrated subtask, the calibrated subtask now includes subtask t 13 , t2, t6, t 12 , t1, t3, t5, t8;

[0150] (10) Re-execute step (4). At this time, there are no uncalibrated subtasks in the subtask set, and the process ends.

[0151] (11) The priority of the benchmark subtask in the task relationship diagram is determined to be level 0. The level correction value of other subtasks other than the benchmark subtask is the priority of each subtask in the task relationship diagram. The priority of each subtask is:

[0152] t1, t2, t 12 : Level 2;

[0153] t3, t5, t6, t 13 : Level 1;

[0154] t7, t8: Level 0.

[0155] The higher the priority of a task, the higher its level in the task relationship diagram, and the first task to be executed. For example, subtasks t1, t2, t 12 In the task relationship diagram, it is at the first level, subtasks t3, t5, t6, t 13 It is at the second level in the task relationship diagram, and subtasks t7 and t8 are at the third level in the task relationship diagram.

[0156] 3. Connect the tasks with dependency relationships between two adjacent levels to obtain a task relationship diagram.

[0157] So far, the present invention has completed the division of subtask sets and determined a task relationship graph for each subtask set.

[0158] 4. Cluster Node Sorting

[0159] In the present invention, the target application is divided into multiple subtask sets, and the subtasks of each subtask set have no dependencies on each other; this is equivalent to slicing the target application, providing a basis for subsequent node scheduling and resource matching.

[0160] To adapt to task slicing, the present invention also slices the resources in the node, performs granular management of the resources provided by each node, and divides the GPU resources, CPU resources and memory resources into multiple virtual resource units to avoid some small tasks monopolizing the entire GPU, CPU and memory resources, resulting in other tasks with higher computing power requirements not being executed in a timely manner.

[0161] In the present invention, the method for granularly managing node resources includes:

[0162] 1. Divide the CPU resources of each node into multiple CPU resource units to obtain the number of CPU resource units for each node. When dividing the CPU resources into multiple CPU resource units, determine the CPU resource volume of each node based on the CPU system clock frequency, instruction cycle, word length, and CPU cache. Then, divide the CPU resources based on the CPU resource volume, and ensure that each CPU resource unit provides the same CPU resource volume.

[0163] Divide the GPU resources of each node into multiple GPU resource units to obtain the number of GPU resource units of each node; when dividing the GPU resources into multiple GPU resource units, divide them according to the number of GPU hardware cores, and each GPU resource unit provides the same number of hardware cores;

[0164] The memory resources of each node are divided into multiple memory resource units to obtain the number of memory resource units of each node; when the memory resources are divided into multiple memory resource units, the memory resources are divided according to the size of the memory, and the memory size provided by each memory resource unit is consistent.

[0165] Take the CPU as an example:

[0166] (1) First, the CPU resource volume of each node is determined based on the CPU's system clock frequency, instruction cycle, word length, and CPU cache. A standard reference value and a weight value can be determined for each of the CPU's system clock frequency, instruction cycle, word length, and CPU cache. Then, the ratio of the actual value of the CPU's system clock frequency, instruction cycle, word length, and CPU cache in the corresponding node to the standard reference value is obtained, and the CPU resource volume is determined based on the ratio and weight value, as follows:

[0167] ;

[0168] in, 、 、 and They represent the system clock frequency, instruction cycle, word length and CPU cache of the CPU of the corresponding node respectively;

[0169] 、 、 and These represent the standard reference values ​​of the CPU's system clock frequency, instruction cycle, word length, and CPU cache, respectively, and can be set in advance based on the evaluation mean of the cluster nodes.

[0170] 、 、 and These represent the CPU's system clock frequency, instruction cycle, word length, and the contribution of the CPU cache to the node's resource size, and can be set in advance based on empirical values.

[0171] For the CPU, its computing power is positively correlated with the system clock frequency, word length, and CPU cache, and negatively correlated with the instruction cycle. Therefore, in the above formula, the system clock frequency, word length, and CPU cache of the node CPU are in the numerator, and the instruction cycle of the node CPU is in the denominator.

[0172] (2) After determining the CPU resource volume, you can select the node with the smallest CPU resource volume and divide its CPU resources into a certain number of CPU resource units, such as 100 CPU resource units. Then, based on the ratio of the CPU resource volume of other nodes to the CPU resource volume of the smallest node, determine the number of CPU resource units into which the CPU resource volume of other nodes is divided. For example, if the CPU resource volume of a node among other nodes is twice the CPU resource volume of the smallest node, the CPU resource of a node can be divided into 200 CPU resource units. In this way, it is ensured that the CPU resource volume provided by each CPU resource unit is consistent.

[0173] Therefore, it is not difficult to understand that when dividing GPU resources among nodes, you can also select the node with the smallest number of GPU hardware cores and divide its GPU resources into a certain number of GPU resource units. Then, based on the ratio of the number of GPU hardware cores in other nodes to the number of GPU hardware cores in the smallest node, determine the number of GPU resource units into which the GPU resources in other nodes are divided, to ensure that the number of hardware cores provided by each GPU resource unit is consistent.

[0174] It is also not difficult to understand that when dividing memory resources among nodes, you can also select the node with the smallest memory size and divide its memory resources into a certain number of memory resource units. Then, based on the ratio of the memory size of other nodes to the memory size of the smallest node, determine the number of memory resource units into which the memory resources in other nodes are divided, to ensure that the memory size provided by each memory resource unit is consistent.

[0175] 2. The resource occupancy rate of each node is obtained by the following formula:

[0176] ;

[0177] in, 、 and Respectively represent the number of idle CPU resource units, idle GPU resource units, and idle memory resource units of the corresponding node;

[0178] 、 and Represents the total number of idle CPU resource units, total number of idle GPU resource units, and total number of idle memory resource units of all nodes in the cluster respectively;

[0179] α, β, and γ represent the weights of CPU resources, GPU resources, and memory resources, respectively, when measuring the hardware resource capabilities of a node. Typically, GPU resources have the highest weight, while memory resources have the lowest weight. In an example, the values ​​of α, β, and γ can be set to 0.2, 0.7, and 0.1, respectively.

[0180] 3. Apply for a first queue and sort the nodes based on resource occupancy rate from large to small.

[0181] In the present invention, the so-called nodes can be multiple containers isolated on the server, which is suitable for scenarios where resource utilization is improved based on container technology; they can also be multiple virtual machines in a cloud computing environment, which is suitable for scenarios where the server's processing capacity is improved based on cloud computing; they can also be a combination of multiple containers and multiple virtual machines, which is not limited by the present invention.

[0182] 5. Task Scheduling

[0183] 1. Apply for a second queue and sort the subtask sets in descending order of required resources based on the task set resource information;

[0184] 2. Take a subtask set from the second queue in order and match it with the first node in the first queue:

[0185] If the match is successful, the extracted subtask set is scheduled to the first node;

[0186] If the match fails, the next node is taken out in sequence for matching until a match succeeds.

[0187] A successful match means that the number of idle CPU resource units, idle GPU resource units, and idle memory resource units of the corresponding node can meet the requirements of the corresponding subtask set; the requirements of the corresponding subtask set are obtained based on the task set resource information of the subtask set;

[0188] After the match is successful, the node resource information of the node to which the subtask set successfully matched in this round belongs is updated. Specifically, the number of idle CPU resource units, idle GPU resource units, and idle memory resource units of the node are updated;

[0189] 3. Take the next subtask set from the second queue in order and repeat step 2 until all subtask sets are successfully scheduled.

[0190] At this point, the present invention has fragmented the target application tasks and the hardware resources of the nodes, and has performed targeted scheduling and execution of each subtask based on the division results. In this way, from the perspective of the most fine-grained management, the maximum utilization of the node hardware resources is ensured, and at the same time, the orderly and concurrent execution of multiple tasks is ensured to the greatest extent, thereby improving the response efficiency of the service terminal and reducing the occurrence of system freezes.

[0191] In addition, there may be more than one independent execution path within the same subtask set. In this case, multiple execution paths can also be executed concurrently. Figure 3 For example, the subtasks t1, t2, t 12 There is no dependency between them and they can be executed in parallel. After subtask t1 is completed, subtask t1 and its dependent path are released, and subtasks t3 and t5 at the second level can be executed in parallel, and so on. Figure 5 For example, the subtask t at the first level 15 and the subtask t at the second level 18 There is no dependency between them and they can be executed in parallel.

[0192] It should be noted that after all subtasks in a subtask set are executed, the node resources on the node to which they belong are released, and the node resource information on the node to which they belong is updated.

[0193] In addition, when a new application task is triggered, if the subtask set that has been divided and scheduled has not been completed at this time, then the new application task that is triggered will be directly divided into a new subtask set, the task relationship diagram will be determined, the cluster nodes will be sorted, the tasks will be scheduled and the new subtask set will be executed according to the method of the present invention, which will not conflict with the subtask set that has not been completed before.

[0194] Since the user's execution operation of a new application task can be triggered at any time, according to the above method, it cannot be ensured that the subtask sets being executed are all divided out of the same division cycle; therefore, the present invention can set a time period, such as 5 seconds, and every time the time period is exceeded, the subtask set division, task relationship diagram determination, cluster node sorting, task scheduling and execution are re-executed for all subtasks currently being executed, so as to regularly integrate subtasks, share node resources, and save node resources to the greatest extent.

[0195] In the present invention, when the target application is divided into subtasks, the division granularity can be determined based on actual needs. If the processing logic similarity between the target applications is high, the division granularity can be larger to save time in determining the subtask set and the task relationship diagram; if the processing logic similarity between the target applications is low, the division granularity can be smaller to maximize the proportion of repeated subtasks between multiple target applications and reduce the execution time of subtasks on the node.

[0196] Although the present invention has been described using the above preferred embodiments, they are not intended to limit the scope of protection of the present invention. Any person skilled in the art may make various changes and modifications to the above embodiments without departing from the spirit and scope of the present invention. These changes and modifications are still within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be based on the definition of the claims.

Claims

1. A multi-tasking optimization method for desktop applications, characterized in that: The steps include: S1: Split the target application into multiple subtasks to obtain a set of subtasks; S2: Obtain attribute information of each subtask, including the dependency relationship between the corresponding subtask and other subtasks and the task resource information required to execute the corresponding subtask; S3: Based on the attribute information of each subtask, multiple subtask sets are obtained; for each subtask set, its task relationship graph is obtained based on the following steps: the task relationship values ​​of each subtask and all subtasks in its dependent task set are obtained; Obtain subtask levels based on task relationship values; Starting from the first level, obtain the dependency relationship between each subtask in each level and each subtask in the next level to obtain the final task relationship graph; The level of each subtask in each subtask set is obtained through the following steps: S37: Determine a subtask as a benchmark subtask; S38: Mark all subtasks in the benchmark subtask dependent task set as non-benchmark subtasks, and determine the level correction value of each non-benchmark subtask relative to the benchmark subtask as R i,j ; S39: Mark the subtask that has completed calibration as a calibrated subtask, and mark the subtasks other than the calibrated subtask and the reference subtask as uncalibrated subtasks; S340: Determine whether there is an uncalibrated subtask in the subtask set: If it does not exist, execute S343; If it exists, execute S341; S341: For each uncalibrated subtask, if there is a subtask with a dependency relationship among the calibrated subtasks, randomly select one to determine its level correction value and mark it as a calibrated subtask; if there is no subtask with a dependency relationship among the calibrated subtasks, then temporarily determine its level correction value; S342: Jump to S340; S343: The priority of the base subtask is determined to be level 0. The level correction values ​​of other subtasks are their priorities. The level of each subtask is determined according to the priority. S4: for each subtask set, based on the task resource information of each subtask, obtain the task set resource information of the subtask set; S5: Get node resource information of all nodes in the cluster; S6: Based on the task set resource information of each subtask set and the node resource information of each node in the cluster, complete the matching of the subtask set and the node; The node resource information of the cluster includes: the number of CPU resource units obtained by dividing the CPU resources into multiple CPU resource units, the number of GPU resource units obtained by dividing the GPU resources into multiple GPU resource units, and the number of memory resource units obtained by dividing the memory resources into multiple memory resource units; When dividing CPU resources into multiple CPU resource units, the CPU resource volume of each node is determined based on the CPU system clock frequency, instruction cycle, word length, and CPU cache. The CPU resource volume is divided based on the CPU resource volume, and each CPU resource unit provides the same CPU resource volume. When dividing GPU resources into multiple GPU resource units, they are divided according to the number of GPU hardware cores, and each GPU resource unit provides the same number of hardware cores; When dividing memory resources into multiple memory resource units, the division is based on the memory size, and each memory resource unit provides the same memory size; S7: Based on the task relationship graph of each subtask set, the execution of each subtask in each subtask set is completed on the corresponding node, and the node is a plurality of containers isolated on the server.

2. The multi-tasking optimization method for desktop applications according to claim 1, wherein: In S3, the division of subtask sets is completed through the following steps: S31: Take a subtask from the subtask set, mark it as the first subtask, and obtain the dependent task set of the first subtask, where the dependent task set consists of all subtasks that have a dependent relationship with the first subtask; S32: Add the first subtask and all subtasks in the dependent task set of the first subtask into a set to obtain an initial subtask set; S33: Mark all subtasks in the dependent task set obtained in S31 as second subtasks; S34: Sequentially extract the second subtasks from the initial subtask set, and perform the following operations for each second subtask: S341: Mark it as the first subtask; S342: Obtain its dependent task set, which is composed of all subtasks that have a dependency relationship with the retrieved second subtask; S343: Determine whether there is a subtask in the dependent task set that is not included in the initial subtask set: If so, mark the subtask that is not included in the initial subtask set as the second subtask and add it to the initial subtask set to obtain an updated initial subtask set; S35: Determine whether the second subtask exists in the initial subtask set: If not, the final initial subtask set is determined as a subtask set, and S36 is executed; If it exists, re-execute S34; S36: Determine whether there are unfinished subtasks. If so, obtain a subtask from the unfinished subtasks as the first subtask and repeat S31-S35. If not, end. The unfinished subtask is a subtask that exists in the set of subtasks but does not exist in any subtask set.

3. The multi-tasking optimization method for desktop applications according to claim 1, wherein: In step S6, matching of subtask sets with nodes is completed based on the task set resource information of each subtask set and the node resource information of each node in the cluster, including: Step S61: Obtaining the resource occupancy rate of each node based on the number of CPU resource units, GPU resource units, and memory resource units of each node in the cluster; Step S62: Apply for a first queue and sort the nodes based on resource occupancy; Step S63: Apply for a second queue and sort the subtask sets based on the task set resource information; Step S64: Take a subtask set from the second queue in order and match it with the first node in the first queue: If the match is successful, the extracted subtask set is scheduled to the first node; If the match fails, the next node is taken out in sequence for matching until a match succeeds. Update the node resource information of the successfully matched node; Step S65: re-execute step S64, and sequentially take out the next subtask set from the second queue for matching, until all subtask sets are successfully scheduled.

4. The multi-tasking optimization method for desktop applications according to claim 3, wherein: In step S61, the resource occupancy rate of each node is obtained by the following formula: ; in, 、 and Respectively represent the number of idle CPU resource units, idle GPU resource units, and idle memory resource units of the corresponding node; 、 and Represents the total number of idle CPU resource units, total number of idle GPU resource units, and total number of idle memory resource units of all nodes in the cluster respectively; α, β, and γ represent the weights of CPU resources, GPU resources, and memory resources, respectively, when measuring the hardware resource capabilities of a node.

Citation Information

Patent Citations

  • Task and resource awareness-oriented micro-service deployment method

    CN111736983A

  • Task scheduling method and device

    CN113391914A