A time-sharing scheduling method, terminal and storage medium based on priority
By adopting a priority-based time-sharing scheduling method in the resource management system, the target task is determined based on the user's priority and the duration of the running task, which solves the problem of uneven progress of low-priority user tasks caused by priority scheduling of high-priority user tasks. , achieving both uniformity of task progress and priority.
Patent Information
- Application Number
- CN202110141136.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-01
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-02-01
AI Technical Summary
In resource management systems, priority scheduling of tasks for high-priority users in the prior art results in uneven task processing progress for low-priority users and serious resource allocation conflicts.
Adopting a priority-based time-sharing scheduling method, by determining the user to whom each task to be scheduled belongs, obtaining the duration and priority weight of the user's running tasks, calculating the duration weight, selecting the user with the largest difference as the target user, and based on Preset attribute sorting determines target tasks, allocates running resources, and ensures uniformity of task progress.
The completion progress of each user's tasks is more even, taking into account the user's priority, and avoiding the problem of high-priority users being unable to run for a long time.
Smart Images

Figure CN112817722B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of task scheduling, and in particular to a priority-based time-sharing scheduling method, a terminal and a storage medium. Background Art
[0002] In resource management systems such as Kubernetes, the scheduling support for multiple users is not perfect, and users inevitably face conflicts in resource allocation. When resources are scarce, the existing technology will give priority to scheduling tasks of high-priority users, which will cause the tasks of low-priority users to be unable to run for a long time, resulting in uneven task processing progress for each user.
[0003] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0004] In view of the above-mentioned defects of the prior art, the present invention provides a priority-based time-sharing scheduling method, terminal and storage medium, aiming to solve the problem in the prior art that limited scheduling of tasks of high-priority users leads to uneven task processing progress of each user.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:
[0006] A first aspect of the present invention provides a priority-based time-sharing scheduling method, the method comprising:
[0007] Determine the user to whom each task to be scheduled belongs;
[0008] Obtaining the duration of tasks that have been run by each user within a first preset duration, and determining a target task among the tasks to be scheduled according to the duration of tasks that have been run by each user;
[0009] Allocate operating resources to the target task.
[0010] The priority-based time-sharing scheduling method, wherein, before determining the user to which each task to be scheduled belongs, the method further comprises:
[0011] Determining the allocated time for each user within the second preset time according to the priority of each user;
[0012] When the running time of the task of the first user reaches the allocated time of the first user within the second preset time, pausing the running task of the first user and converting the running task of the first user into the task to be scheduled;
[0013] Among them, the second preset time length is greater than the first preset time length.
[0014] The priority-based time-sharing scheduling method, wherein the step of determining the target task among the tasks to be scheduled according to the duration of the tasks already run by the respective users, comprises:
[0015] Obtaining the priority weight of each user;
[0016] Respectively obtaining the duration weights of the tasks that have been run by each user within the first preset duration;
[0017] The target user is determined according to the priority weight and the duration weight of each user, and the target task is determined according to the target user.
[0018] The priority-based time-sharing scheduling method, wherein the step of determining the target user according to the priority weight and duration weight of each user includes:
[0019] Taking the user with the largest first difference as the target user;
[0020] The first difference is a value obtained by subtracting the duration weight from the priority weight.
[0021] The priority-based time-sharing scheduling method, wherein determining the target task according to the target user comprises:
[0022] The first task among the tasks to be scheduled and belonging to the target user after being sorted according to preset attributes is used as the target task;
[0023] The preset attributes include at least one of submission time and priority.
[0024] The priority-based time-sharing scheduling method, wherein the step of allocating operating resources to the target task includes:
[0025] When the idle running resources meet the running requirements of the target task, directly allocate the running resources to the target task;
[0026] When the idle running resources do not meet the running requirements of the target task, a first task is selected from the running tasks and is paused to obtain the idle running resources.
[0027] The priority-based time-sharing scheduling method, wherein, after determining the user to which each task to be scheduled belongs, the method further comprises:
[0028] When the priority level of the task to be scheduled is a preset level, resources occupied by each running task are obtained, and the running second task is suspended to allocate the running resources of the second task to the task to be scheduled;
[0029] The resources occupied by the second task meet the resource requirements of the task to be scheduled.
[0030] The priority-based time-sharing scheduling method, wherein the task is a deep learning task and the operating resources are GPU computing resources.
[0031] The second aspect of the present invention provides a terminal, which includes a processor and a storage medium communicatively connected to the processor, the storage medium is suitable for storing multiple instructions, and the processor is suitable for calling the instructions in the storage medium to execute the steps of implementing any of the priority-based time-sharing scheduling methods described above.
[0032] According to a third aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any of the priority-based time-sharing scheduling methods described above.
[0033] Compared with the prior art, the present invention provides a priority-based time-sharing scheduling method, terminal and storage medium. When scheduling tasks for each user, the task that currently needs to be allocated running resources is determined based on the length of time each user has run tasks within a certain period of time, so that the task completion progress of each user can be more balanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flowchart of an embodiment of a priority-based time-sharing scheduling method provided by the present invention;
[0035] Figure 2 A flow chart of sub-steps of step S200 in an embodiment of a priority-based time-sharing scheduling method provided by the present invention;
[0036] Figure 3 A schematic diagram of the principles of an embodiment of a terminal provided by the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0038] Embodiment 1
[0039] The priority-based time-sharing scheduling method provided by the present invention can be executed by a terminal, and the terminal includes but is not limited to various mobile phones, computers, tablet computers, wearable devices, etc.
[0040] like Figure 1As shown, in one embodiment of the priority-based time-sharing scheduling method provided by the present invention, the steps are as follows:
[0041] S100: Determine the user to whom each task to be scheduled belongs.
[0042] Specifically, in resource management systems such as Kubernetes, multiple users are supported to submit task requests. At present, deep learning technology has made great progress and has been applied to more and more scenarios. Many researchers and practitioners have begun to use deep learning technology to try to solve the problems they encounter. In deep learning technology, it is necessary to use existing data for training to obtain feature models, and apply them to unknown data through reasoning. Both training tasks and reasoning tasks in deep learning are extremely resource-intensive. Nowadays, they are mainly calculated through expensive, specially designed accelerators such as GPUs. Due to the high computing cost of GPUs, research institutes, educational institutions, and the industrial sector often form computing clusters of a certain scale to provide computing services to users in a shared manner. In this scenario, resource allocation conflicts are inevitable.
[0043] In this application, the task to be scheduled is an unfinished task that needs to be allocated with running resources. In this embodiment, the task is a deep learning task, and the running resources of the task are GPU computing resources. When there are tasks to be scheduled in the resource management system, the users of each task to be scheduled are first determined.
[0044] S200: Determine the duration of tasks that have been executed by each user within a first preset duration, and determine a target task from each task to be scheduled according to the duration of tasks that have been executed by each user.
[0045] When the available running resources in the system meet the running resource requirements of all tasks to be scheduled, the running resources can be directly allocated to each task to be scheduled. When the available running resources in the system cannot meet the running resource requirements of all tasks to be scheduled, it is necessary to determine the task to be allocated running resources at the current moment among the tasks to be scheduled, that is, the target task.
[0046] Specifically, Figure 2 As shown in the figure, the target task is determined among the tasks to be scheduled according to the duration of the tasks that each user has run, including:
[0047] S210: Obtain the priority weight of each user.
[0048] In this embodiment, corresponding priorities are set for all users in advance, and the priority weight of each user can be determined according to the priority of each user. Specifically, the priority can be represented by a numerical value, and the larger the number, the higher the priority. The priority weight of each user can be the ratio of its own priority value to the sum of the priority weights of all users. For example, there are three users A, B, and C, and their priorities are 2, 5, and 9 respectively. Then the priority weights of the three are 1 / 8, 5 / 16, and 9 / 16 respectively.
[0049] S220: Obtain the duration weight of the tasks that have been executed by each user within the first preset duration.
[0050] The first preset duration can be a period of time with the current moment as the end point. The first preset duration can be set accordingly according to the actual situation, such as 10 minutes, 1 hour, etc. The running time of each user's running tasks within the first preset duration before the current moment is obtained respectively, and the proportion of the time used by each user within the first preset duration to the first preset duration is obtained as the duration weight of the tasks that each user has run within the first preset duration, wherein the tasks that have been run include tasks that have been completed and tasks that are being run. For example, the first preset duration is 10 minutes, and the running tasks of three users A, B, and C have run for 3 minutes, 2 minutes, and 5 minutes respectively within 10 minutes before the current moment, then the duration weights of the tasks that the three have run within the first preset duration are 3 / 10, 1 / 5, and 1 / 2 respectively.
[0051] S230: Determine a target user according to the priority weight and duration weight of each user, and determine a target task according to the target user.
[0052] Specifically, the target user is determined according to the priority weight and duration weight of each user, including:
[0053] The user with the largest first difference is taken as the target user.
[0054] Among them, the first difference is the value obtained by subtracting the duration weight from the priority weight, that is, the corresponding running resources are allocated to the tasks of the user whose duration ratio of the tasks that have been run within the first preset duration is the largest difference with the priority ratio. In this way, the gap between the actual allocated running time of the user and the time divided according to the optimization weight can be narrowed, and the situation that the running resources are always allocated to the users with high priority, resulting in the delay of the tasks of the users with low priority, can be prevented. The task execution of each user can be averaged, while taking into account the high and low priorities of each user.
[0055] Determine target tasks based on target users, including:
[0056] The first task among the tasks to be scheduled and belonging to the target user after being sorted according to preset attributes is taken as the target task.
[0057] The preset attributes include at least one of submission time and priority. Among the tasks to be scheduled, there may be multiple tasks belonging to the same user. After the target user is determined, the tasks belonging to the target user are sorted according to the preset attributes, and the task ranked first is used as the target task. Specifically, the sorting can be based on the early or late submission time, that is, the earlier the task is submitted to the scheduling system to request resource allocation, the priority of allocating running resources to it. Each user can also set the task priority for his own task individually. For the tasks of the same user, they can be sorted according to the task priority, and the running resources are allocated first to the tasks with high task priority.
[0058] Furthermore, in a possible implementation, the occupancy time of the user in a longer period of time is controlled according to the priority of each user. Specifically, before determining the user to whom each task to be scheduled belongs, the priority-based time-sharing scheduling method provided in this embodiment further includes the following steps:
[0059] Determining the allocated time for each user within the second preset time period according to the priority of each user;
[0060] When the running time of the first user's task reaches the allocated time of the first user within the second preset time, the first user's running task is suspended and the first user's running task is converted into a task to be scheduled.
[0061] The second preset duration is greater than the first preset duration. Determining the allocated duration of each user within the second preset duration according to the priority of each user can be to allocate a corresponding duration to each user within the second preset duration according to the priority weight of each user. For example, there are three users A, B, and C, whose priorities are 2, 5, and 9 respectively, and the second preset duration is 1 hour. Then, the allocated durations of the three within the second preset duration are 1 / 8 hour, 5 / 16 hour, and 9 / 16 hour respectively. Of course, in practice, the allocated duration of the user can be obtained by rounding the value obtained by multiplying the priority weight of the user by the second preset duration.
[0062] When the running time of the task that the first user has run within the second preset time before the current moment reaches the allocated time of the first user, the task that the first user is running is suspended and converted into a task to be scheduled. In this way, it can be ensured that the time occupied by each user will not have a large difference with the degree of priority.
[0063] Please refer again Figure 1 The priority-based time-sharing scheduling method provided in this embodiment further includes the following steps:
[0064] S300: Allocate operating resources to the target task.
[0065] Specifically, when the idle running resources meet the running requirements of the target task, the running resources are directly allocated to the target task. When the idle running resources do not meet the running requirements of the target task, the first task is selected from the running tasks and paused to obtain the idle running resources.
[0066] The first task may be any one or more of the tasks being run, and the running resources occupied by the first task should meet the running requirements of the target task. In a possible implementation, the first task may be determined by combining the priority weights and duration weights of each task. For example, the first task may be selected from the tasks of the user whose priority weights and duration weights are closest.
[0067] The resource scheduling system can support the user to define the priority of the task as an absolute priority. In a possible implementation, after determining the user of each task to be scheduled, the system further includes the following steps:
[0068] When the priority level of the task to be scheduled is a preset level, resources occupied by each running task are obtained, and the running second task is suspended to allocate the running resources of the second task to the task to be scheduled.
[0069] Among them, the resources occupied by the second task meet the needs of the task to be scheduled. Specifically, the resource scheduling system can support users to define the priority of tasks as absolute priority. When there are tasks with absolute priority, running resources are directly allocated to them. When the idle resources in the system do not meet the resources required by the task to be scheduled, the tasks whose occupied resources meet the needs of the task to be scheduled are selected and suspended to obtain idle resources that meet the needs of the task to be scheduled, and the idle resources are allocated to the task to be scheduled.
[0070] To sum up, this embodiment provides a priority-based time-sharing scheduling method. When scheduling tasks for each user, the task that currently needs to be allocated running resources is determined based on the length of time each user has run tasks within a certain period of time, so that the task completion progress of each user can be more balanced.
[0071] It should be understood that, although the various steps in the flowcharts given in the accompanying drawings of the present specification are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0072] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0073] Embodiment 2
[0074] Based on the above embodiments, the present invention also provides a terminal, such as Figure 3 As shown, the terminal includes a processor 10 and a memory 20. It can be understood that Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0075] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a priority-based time-sharing scheduler 30 is stored on the memory 20, and the priority-based time-sharing scheduler 30 can be executed by the processor 10, thereby realizing the priority-based time-sharing scheduling method in the present application.
[0076] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other chip, used to run the program code or process data stored in the memory 20, such as executing the priority-based time-sharing scheduling method.
[0077] Embodiment 3
[0078] The present invention also provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the priority-based time-sharing scheduling method as described above.
[0079] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A time-sharing scheduling method based on priority, It is characterized in that The method comprises: Determine the user to whom each task to be scheduled belongs; Obtaining the duration of tasks that have been run by each user within a first preset duration, and determining a target task among the tasks to be scheduled according to the duration of tasks that have been run by each user; Allocating operating resources to the target task; Before determining the users to whom each task to be scheduled belongs, the method further includes: Determining the allocated time for each user within the second preset time according to the priority of each user; When the running time of the task of the first user reaches the allocated time of the first user within the second preset time, pausing the running task of the first user and converting the running task of the first user into the task to be scheduled; Wherein, the second preset duration is greater than the first preset duration; The step of determining a target task from among the tasks to be scheduled according to the duration of tasks that have been run by each user includes: Obtaining the priority weight of each user; Respectively obtaining the duration weights of the tasks that have been run by each user within the first preset duration; Determine the target user according to the priority weight and duration weight of each user, and determine the target task according to the target user; The priority is represented by a number, a larger number indicates a higher priority, and the priority weight of each user is the ratio of its own priority value to the sum of the priority weights of all users; The user's allocated time is obtained by multiplying the user's priority weight by the second preset time and rounding the value obtained. The determining the target user according to the priority weight and duration weight of each user includes: Taking the user with the largest first difference as the target user; Wherein, the first difference is the value obtained by subtracting the duration weight from the priority weight; The resource scheduling system supports users to define the priority of tasks as absolute priority. When there are tasks with absolute priority, running resources are directly allocated to them. When the idle resources in the system do not meet the resources required by the tasks to be scheduled, the tasks that occupy resources to meet the needs of the tasks to be scheduled are selected and suspended, so as to obtain idle resources that meet the needs of the tasks to be scheduled, and the idle resources are allocated to the tasks to be scheduled.
2. The priority-based time-sharing scheduling method according to claim 1, It is characterized in that The determining the target task according to the target user includes: The first task among the tasks to be scheduled and belonging to the target user after being sorted according to preset attributes is used as the target task; The preset attributes include at least one of submission time and priority.
3. The priority-based time-sharing scheduling method according to claim 1, It is characterized in that The allocating running resources to the target task includes: When the idle running resources meet the running requirements of the target task, directly allocate the running resources to the target task; When the idle running resources do not meet the running requirements of the target task, a first task is selected from the running tasks and is paused to obtain the idle running resources.
4. The priority-based time-sharing scheduling method according to claim 1, It is characterized in that After determining the users to which each task to be scheduled belongs, the method further includes: When the priority level of the task to be scheduled is a preset level, resources occupied by each running task are obtained, and the running second task is suspended to allocate the running resources of the second task to the task to be scheduled; The resources occupied by the second task meet the resource requirements of the task to be scheduled.
5. The priority-based time-sharing scheduling method according to any one of claims 1 to 4, It is characterized in that The task is a deep learning task, and the operating resources are GPU computing resources.
6. A terminal, It is characterized in that The terminal includes: a processor, a storage medium communicatively connected to the processor, the storage medium being suitable for storing a plurality of instructions, and the processor being suitable for calling the instructions in the storage medium to execute the steps of implementing the priority-based time-sharing scheduling method described in any one of claims 1-5 above.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the priority-based time-sharing scheduling method as described in any one of claims 1-5.
Citation Information
Patent Citations
Big data resource scheduling method and device, server and storage medium
CN111352736A
Multi-task dynamic resource scheduling method
CN111767134A
Method for controlling heating, and terminal
WO2016197651A1
