Task scheduling method and electronic equipment
By estimating task resource size and automatically scheduling tasks, the problem of untimely task scheduling caused by users manually querying server resources is solved, thus improving task scheduling efficiency and user experience.
Patent Information
- Application Number
- CN202511035295.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-11-14
AI Technical Summary
Users need to manually check whether server resources meet the task requirements, resulting in untimely task scheduling, poor user experience, and cumbersome operation.
By acquiring the task data of the tasks to be scheduled, estimating the resource size required by the tasks, adding the tasks to the queuing queue, and scheduling based on the resource size, automatic scheduling is achieved.
It improves the timeliness and efficiency of task scheduling, simplifies user operations, and enhances the user experience.
Smart Images

Figure CN120950201A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to a task scheduling method and electronic device. Background Technology
[0002] Users often submit tasks (such as model training tasks) to the server to utilize the server's resources, such as GPUs, to process the task. Since server resources are limited, the server can immediately schedule and execute the task when its resources can meet the task's requirements.
[0003] However, when the server's resources are insufficient to meet the task's requirements, the server will output a message such as "Try again later." After waiting for a certain period, the user can determine whether the server's resources can meet the task's requirements. If the requirements are met, the user can submit the task to the server. If the requirements are not met, the user must continue to wait until the server's resources can meet the task's requirements.
[0004] Since users are querying server resources, there's a possibility that they won't find enough resources to meet their task requirements in a timely manner, leading to delayed task scheduling. Furthermore, users may need to query repeatedly, resulting in a poor user experience. Summary of the Invention
[0005] This application provides a task scheduling method and electronic device to achieve automatic task scheduling, ensure the timeliness of task scheduling, thereby improving task scheduling efficiency and enhancing user experience.
[0006] On one hand, embodiments of this application provide a task scheduling method applied to an electronic device, the method comprising:
[0007] Obtain task data for tasks to be scheduled;
[0008] Based on the task data, the resource size occupied by the task to be scheduled is estimated;
[0009] Add the task to be scheduled to the queue;
[0010] The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
[0011] In some embodiments, estimating the resource size occupied by the task to be scheduled based on the task data includes:
[0012] If a target resource size matching the task data exists in the preset task resource proportion library, the target resource size shall be used as the resource size occupied by the task to be scheduled.
[0013] If the target resource size matching the task data does not exist in the preset task resource proportion library, a target task data that is similar to the task data is determined, and the resource size occupied by the task to be scheduled is determined according to the resource size matching the target task data.
[0014] In some embodiments, the task data includes at least one task parameter; the target task data includes first task data, wherein the task parameter in the first task data is greater than or equal to the task parameter in the task data of the task to be scheduled.
[0015] Determining the resource size occupied by the task to be scheduled based on the resource size matching the target task data includes:
[0016] Determine the smallest resource size from the resource sizes that match the data of the first task;
[0017] If the minimum resource size is less than or equal to the resource threshold corresponding to the user to which the task to be scheduled belongs, the resource size occupied by the task to be scheduled is determined based on the minimum resource size.
[0018] In some embodiments, the target task data further includes second task data, wherein the task parameters in the second task data are smaller than the task parameters in the task data of the task to be scheduled;
[0019] Determining the resource size occupied by the task to be scheduled based on the resource size matching the target task data includes:
[0020] If the minimum resource size is greater than the resource threshold, the maximum resource size is determined from the resource sizes that match the second task data;
[0021] If the maximum resource size is less than or equal to the resource threshold, the resource size occupied by the task to be scheduled is determined based on the maximum resource size.
[0022] In some embodiments, estimating the resource size occupied by the task to be scheduled based on the task data includes:
[0023] Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the resource size occupied by the task to be scheduled.
[0024] In some embodiments, the step of using a random forest algorithm and combining the task data to perform linear regression prediction based on historical task data and corresponding resource sizes includes:
[0025] If the difference between the minimum resource size and the resource threshold is greater than the first difference, or the difference between the maximum resource size and the resource threshold is greater than the second difference, a random forest algorithm is used to perform linear regression prediction based on historical task data and the corresponding resource size, combined with the task data.
[0026] In some embodiments, the step of using a random forest algorithm, combined with linear regression estimation based on historical task data and corresponding resource sizes, to obtain the resource size occupied by the task to be scheduled includes:
[0027] Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the first resource size;
[0028] If the difference between the first resource size and the second resource size is greater than or equal to the preset resource growth rate, the first resource size is used as the resource size occupied by the task to be scheduled; wherein, the task parameters in the historical task data corresponding to the second resource size are smaller than the task parameters in the task data of the task to be scheduled.
[0029] In some embodiments, scheduling the tasks in the queue based on the resource size occupied by the tasks to be scheduled includes:
[0030] If the task to be scheduled meets the first preset condition, the task to be scheduled in the queue is scheduled based on the amount of resources occupied by the task to be scheduled.
[0031] The first preset condition includes that there are no tasks in execution among the tasks of the user to which the task to be scheduled belongs, or that the number of concurrent tasks in execution among the tasks of the user to which the task to be scheduled belongs is less than the number of concurrent tasks corresponding to the user.
[0032] In some embodiments, scheduling the tasks in the queue based on the resource size occupied by the tasks to be scheduled includes:
[0033] If the size of the idle resources is greater than or equal to the size of the resources occupied by the task to be scheduled, the task to be scheduled is scheduled; wherein, the size of the idle resources is determined based on the size of the resources reserved for tasks of users other than the user to whom the task to be scheduled belongs.
[0034] In some embodiments, the method further includes:
[0035] Record the estimated queuing time for tasks in the queue.
[0036] On the other hand, embodiments of this application also provide a task scheduling device, the device comprising:
[0037] The task acquisition module is configured to acquire task data for tasks to be scheduled.
[0038] The resource estimation module is configured to estimate the amount of resources occupied by the task to be scheduled based on the task data.
[0039] The queuing module is configured to add the task to be scheduled to a queuing queue;
[0040] The task scheduling module is configured to schedule the tasks in the queue based on the amount of resources occupied by the tasks to be scheduled.
[0041] On the other hand, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program or instructions, and when the computer program or instructions are executed by the processor, the processor performs the following steps:
[0042] Obtain task data for tasks to be scheduled;
[0043] Based on the task data, the resource size occupied by the task to be scheduled is estimated;
[0044] Add the task to be scheduled to the queue;
[0045] The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
[0046] In some embodiments, the aforementioned electronic device may be a server.
[0047] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a computer program or instructions thereon, wherein the computer program or instructions, when executed by a processor, implement the steps in any of the task scheduling methods provided in embodiments of this application.
[0048] On the other hand, embodiments of this application also provide a computer program product, including a computer program or instructions, characterized in that, when the computer program or instructions are executed by a processor, they implement the steps in any of the task scheduling methods provided in embodiments of this application.
[0049] The task scheduling method provided in this application, after obtaining the task data of a task to be scheduled, indicates that the task needs to be scheduled. Based on the task data, the method estimates the resource size required by the task. The task is then added to a queue to await scheduling. Subsequently, based on the estimated resource size, the tasks in the queue are scheduled, ensuring that they are scheduled promptly when their resource requirements are met. This achieves automatic task scheduling and guarantees timeliness. Furthermore, it eliminates the need for repeated user queries, improving task scheduling efficiency and enhancing the user experience. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a schematic diagram of a task scheduling system provided in the embodiments of this application;
[0052] Figure 2 This is a flowchart illustrating a task scheduling method provided in an embodiment of this application. Figure 1 ;
[0053] Figure 3 This is a flowchart illustrating a task scheduling method provided in an embodiment of this application. Figure 2 ;
[0054] Figure 4 This is a task status update graph provided in the embodiments of this application;
[0055] Figure 5 This is a flowchart illustrating a task scheduling method provided in an embodiment of this application. Figure 3 ;
[0056] Figure 6 This is a schematic diagram of the structure of a task scheduling device provided in the embodiments of this application;
[0057] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0058] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0059] In the following description, specific embodiments of the invention will be illustrated with reference to steps and symbols performed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be referred to several times as being performed by a computer, and computer execution as referred to herein includes operations by a computer processing unit representing electronic signals of data in a structured format. This operation transforms the data or maintains it at a location in the computer's memory system, which can be reconfigured or otherwise alter the operation of the computer in a manner well known to those skilled in the art. The data structure maintained by the data is the physical location of the memory, which has specific characteristics defined by the data format. However, the principles of the invention described above are not intended to be limiting, and those skilled in the art will understand that many of the steps and operations described below can also be implemented in hardware.
[0060] The terms "module" or "unit" as used herein can be considered as software objects executing on the computing system. The various components, modules, engines, and services described herein can be considered as implementations on the computing system. While the apparatus and methods described herein are preferably implemented in software, they can also be implemented in hardware, both of which are within the scope of this invention.
[0061] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when an element is “connected” or “coupled” to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein may include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0062] Figure 1 This is a schematic diagram illustrating a task scheduling system provided in an embodiment of this application. Please refer to [link / reference]. Figure 1 The task scheduling system may include: user terminal 10 and server 20.
[0063] User terminal 10 can be any type of smart device, including mobile terminals and terminals with relatively fixed locations. For example, user terminal 10 can be a mobile phone, computer, game console, e-reader, wearable device, smart home device, vehicle, Internet of Things device, etc.
[0064] Server 20 includes, but is not limited to, computers, network hosts, single network servers, sets of multiple network servers, or cloud servers composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing. In embodiments of the present invention, communication between the server and the client can be achieved through any communication method, including but not limited to, mobile communication based on the 3rd Generation Partnership Project (3GPP), Long Term Evolution (LTE), and Worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on the TCP / IP Protocol Suite (TCP / IP) and User Datagram Protocol (UDP).
[0065] Server 20 communicates and interacts with user terminal 10 to schedule tasks submitted by user terminal 10. That is, user terminal 10 can send task data of the task to be scheduled to server 20, and server 20 schedules the task based on the task data. For example, if the task to be scheduled is a model training task, server 20 can execute the model training task submitted by user terminal 10.
[0066] In this embodiment of the application, it is understood that the user terminal 10 used in this embodiment can be understood as a client device, including: cellular or other electronic devices, which have a single-line display, a multi-line display, or a cellular or other electronic device without a multi-line display. Specifically, the user terminal 10 can be a desktop terminal or a mobile terminal, such as a mobile phone, tablet computer, laptop computer, etc.
[0067] When the server's resources are sufficient to meet the requirements of a user-submitted task, the server can immediately schedule and execute the task. When the server's resources are insufficient to meet the task's requirements, the server will output a message such as "Try again later".
[0068] After a certain waiting period, the user checks if the server's resources can meet the task's requirements. If they can, the user can submit the task to the server. If they cannot, the user must continue waiting until the server's resources can meet the task's requirements. Here, "task requirements" refers to the resources needed for the task, which can be estimated by the user based on experience to determine if the server's resources can meet those requirements.
[0069] Alternatively, when there are multiple servers, users can search among the servers to find one with the resources to meet the task's requirements, and then submit the task to that server for task scheduling.
[0070] Additionally, when server resources are insufficient, users may not be able to submit tasks and can only check whether the server resources meet the task requirements.
[0071] However, due to the need for server resources, users may repeatedly query server resources, or fail to find server resources that can meet the task's requirements in a timely manner, resulting in delayed task scheduling and a poor user experience. Alternatively, users may need to query multiple servers to see if their task resources meet the requirements, making the process cumbersome and further degrading the user experience.
[0072] Therefore, to address the aforementioned problems, this application provides a method for dynamically scheduling tasks. An electronic device can estimate the resource size required by a user-submitted task, and then determine whether the task needs to remain in the queue based on this resource size. If queuing is not required, the electronic device can schedule the task, achieving automatic task scheduling. This eliminates the need for the user to select an electronic device with sufficient resources from multiple devices, and also eliminates the need for the user to repeatedly check whether the resources of the electronic devices meet the requirements of the task, simplifying the task scheduling process and improving task scheduling efficiency.
[0073] The aforementioned electronic devices may be devices with data processing capabilities, such as servers (e.g., server 20 mentioned above), and this application does not impose any restrictions on the type of electronic devices.
[0074] The following will combine Figure 2 This section describes the method for dynamically scheduling tasks, which is the detailed implementation process of the task scheduling method provided in this application. For example... Figure 2 As shown, the implementation process includes S201-S204.
[0075] S201, The electronic device acquires the task data of the task to be scheduled.
[0076] In this embodiment of the application, the electronic device obtains the task information (such as the task identifier, such as the task ID and other necessary parameters) of the task submitted by the user terminal (such as the user terminal 10 mentioned above), and the task can be used as a task to be scheduled.
[0077] The aforementioned task data represents the data required to execute the scheduled task. For example, task data may include one or more task parameters such as task type, task specifications, resource size locked at different task stages, and resource proportion influencing factors.
[0078] The task type can represent the algorithm type or the model type, such as a model used for image segmentation.
[0079] The task specification refers to one or more of the image's width, height, and batch size. An image batch can be understood as the number of images processed concurrently. For example, if the task specification is 640×640_6, the image width and height are both 640, and the image batch size is 6.
[0080] The resource sizes locked and released at different task stages represent the amount of resources requested or released at different stages of task execution. For example, the resource size requested during the training stage is 6402.0 MiB, and the resource size requested during the evaluation stage is 2098.0 MiB.
[0081] The factors influencing resource allocation represent the factors that affect the resource allocation of tasks to be scheduled, such as user level and number of concurrent users.
[0082] Optionally, some or all of the task parameters in the above task data can be determined through event tracking data. For example, a user initiates a task queue by making an HTTP request to the server's backend interface. The interface performs parameter security verification and pre-tracks event tracking based on the task information submitted by the user to obtain event tracking data. Alternatively, the task parameters in the task data can also be submitted by the user.
[0083] For example, such as Figure 3 As shown, the process of determining task parameters (i.e., the video memory size influence factor) through embedded data can include:
[0084] S301. Receive and verify the necessary parameters required by the user-submitted task to be scheduled. S302. Determine whether the task to be scheduled requires a multi-stage locking mechanism. S303. The electronic device can distinguish the task type.
[0085] S304. The electronic device performs data embedding to obtain embedding data. S305. Based on the embedding data, the electronic device analyzes and obtains the memory size influencing factor.
[0086] The video memory may be GPU video memory, which is an example of the resource described in this application.
[0087] S202. The electronic device estimates the amount of resources required by the task to be scheduled based on the task data.
[0088] The resource size occupied by the task to be scheduled can represent the amount of resources required to execute the task. For example, an electronic device can estimate the resource size matching the task data of the task to be scheduled to obtain the resource size occupied by the task to be scheduled.
[0089] In some embodiments, the process of determining the resource size occupied by the task to be scheduled may include:
[0090] If a target resource size matching the task data exists in the preset task resource allocation database, the target resource size is used as the resource size occupied by the task to be scheduled. Alternatively, after obtaining the specific resource size, the electronic device can determine that the verification is successful and record the target resource size in a cache for the queuing scheduler to automatically analyze when and whether there are sufficient resources to dequeue the task to be scheduled.
[0091] If there is no target resource size matching the task data in the preset task resource proportion library, determine the target task data that is similar to the task data, and determine the resource size occupied by the task to be scheduled based on the resource size matching the target task data.
[0092] The preset task resource allocation library, also known as the task video memory allocation library or video memory allocation library, can include different historical task data and the corresponding video memory value for each historical task.
[0093] Optionally, if a target resource size matching the task data exists, the electronic device can further determine whether the task to be scheduled supports algorithm acceleration (speed_up) based on the aforementioned task data. The task data indicates whether algorithm acceleration is supported.
[0094] If algorithm acceleration is supported, the electronic device will use half the size of the target resource as the resource size occupied by the task to be scheduled.
[0095] If algorithmic calculation is not supported, electronic devices can directly use the target resource size as the resource size occupied by the task to be scheduled.
[0096] It should be noted that electronic devices can also use the product of the target resource size and a preset coefficient as the resource size occupied by the task to be scheduled, thereby effectively improving the success rate of task execution. The preset coefficient can be set according to actual conditions; for example, it could be 1.02 or 1.05. For instance, the resource might be video memory. The actual size of the electronic device's video memory is 24GB, but the amount of video memory occupied by each running task may differ from the actual size.
[0097] Based on this, the electronic device can determine whether there is historical task data in the preset task resource ratio library that is identical to the task data of the task to be scheduled. If there is historical task data that is identical to the task data of the task to be scheduled, the electronic device can use the resource size corresponding to the historical task data in the preset task resource ratio library as the target resource size for matching the task data of the task to be scheduled, thereby determining the specific resource size.
[0098] If no historical task data matching the task data to be scheduled exists, it indicates that no target resource size matches the task data to be scheduled. Therefore, target task data similar to the task data to be scheduled is determined from the preset task resource proportion database to obtain a certain range of resource sizes. Then, the resource size occupied by the task to be scheduled is determined from the resource size corresponding to this target task data in the preset task resource proportion database (i.e., the resource size matching the target task data).
[0099] Optionally, the historical task data that is identical to the task data of the task to be scheduled refers to historical task data whose first target task parameters are identical to those in the task data of the task to be scheduled. The first target task parameters may include size parameters and batch size. The size parameters may include width and height. Furthermore, when the width of the task to be scheduled is the same as the height in the historical task data, and the height of the task to be scheduled is the same as the width in the historical task data, it is determined that the size parameters of the task to be scheduled are identical to the size parameters of the historical task data. For example, if the first task parameter of the task to be scheduled is 512*544_6, and the historical task data is 544*512_6, then it is determined that the task data of the task to be scheduled is identical to the historical task data.
[0100] Optionally, the target task data that is similar to the task data includes the first task data and / or the second task data.
[0101] The task parameters in the first task data are greater than or equal to the task parameters in the task data of the task to be scheduled, or, in other words, the first target task parameter in the first task data is greater than or equal to the first target task parameter in the task data of the task to be scheduled. The resource size corresponding to the first task data is the upper limit of the resource size occupied by the task to be scheduled.
[0102] The first target task parameters include size parameters and batch size. The electronic device can search for historical task data 1 (i.e., the aforementioned first task data) in a preset task resource proportion library where the size parameter is greater than or equal to the size parameter in the task data to be scheduled, and the batch size is greater than or equal to the batch size in the task data to be scheduled. It should be understood that if the size parameter in historical task data 1 is equal to the size parameter in the task data to be scheduled, and the batch size is greater than or equal to the batch size in the task data to be scheduled, it indicates that there exists a target resource size in the preset task resource proportion library that matches the task data to be scheduled; that is, the target resource size is the resource size corresponding to historical task data 1.
[0103] The task parameters in the second task data are less than the task parameters in the task data of the task to be scheduled, or, in other words, the second target task parameters in the second task data are greater than the second target task parameters in the task data of the task to be scheduled. The resource size corresponding to the second task data is the lower limit of the resource size occupied by the task to be scheduled.
[0104] The second target task parameters include size parameters and batch size. The electronic device can search for historical task data 2 (i.e., the aforementioned second task data) from the preset task resource proportion library, where the size parameter is less than or equal to the size parameter in the task data to be scheduled, and the batch size is less than or equal to the batch size in the task data to be scheduled.
[0105] In some embodiments, determining the resource size occupied by the task to be scheduled based on the resource size matching the target task data includes:
[0106] Determine the smallest resource size from the resource sizes that match the data of the first task.
[0107] If the minimum resource size is less than or equal to the resource threshold corresponding to the user to which the task to be scheduled belongs, the resource size occupied by the task to be scheduled is determined based on the minimum resource size.
[0108] The resource threshold for a user can be the resource threshold corresponding to that user's user level. For example, a regular user has 12GB, while a very important person (VIP) has 24GB.
[0109] Based on this, the smallest upper limit value is selected, i.e., the minimum resource size. Then, it is determined whether this smallest upper limit value is less than or equal to the resource threshold corresponding to the user to whom the task to be scheduled belongs, to predict whether the resource size required by the task to be scheduled will exceed the limit. If the smallest resource size is less than or equal to the resource threshold corresponding to the user to whom the task to be scheduled belongs, it indicates whether the resource size required by the task to be scheduled will exceed the limit, and the smallest resource size is taken as the resource size used by the task to be scheduled.
[0110] Optionally, determining the minimum resource size from the resource sizes matching the first task data, so that the process of determining the resource size occupied by the resource to be scheduled based on the minimum resource size may include:
[0111] In one implementation, for each piece of first task data, the resource size corresponding to that first task data is obtained, i.e., the resource size that matches that first task data. Then, the smallest resource size is determined from all the resource sizes corresponding to the first task data, and the smallest resource size is used as the resource size occupied by the resource to be scheduled.
[0112] In another implementation, task data A with different widths and heights and task data B with the same width and height are selected from the first task data. Then, the task data corresponding to the smallest resource size among the resource sizes of task data B is taken as task data BC. Next, task data D with the smallest resource size is searched from task data A and task data BC.
[0113] If there exists task data D with the same size parameter (or scale) as the task to be scheduled, and the number of task data D is greater than 1, that is, there are multiple batches of task data D that are different from the batches of the task to be scheduled, but have the same size parameter as the task to be scheduled, then the two task data D with the largest batch value can be selected, namely task data D1 and task data D2.
[0114] In task data D1, the batch number is y1, and in task data D2, the batch number is y2. The resource size corresponding to task data D1 is x1, and the resource size corresponding to task data D2 is x2. y1 is greater than y2. Therefore, x1 is greater than x2.
[0115] The electronic device can calculate the resource size occupied by the task to be scheduled based on the resource size occupied by the task to be scheduled = (num-b) / k. Where k = (y2-y1) / (x2-x1), b = y1-k*x1.
[0116] If there exists task data D with the same size parameter (or scale) as the task to be scheduled, and the quantity of task data D is 1, then the resource size occupied by the task to be scheduled is calculated as (the resource size corresponding to task data D * the batch size of the task to be scheduled) / the batch size in task data D.
[0117] In the absence of task data D with the same size parameters (or scale) as the task to be scheduled, the resource size occupied by the task to be scheduled is determined by the following formula: Resource size occupied by the task to be scheduled = Resource size corresponding to task data D * (Batch size of the task to be scheduled + 1) / 2.
[0118] The above describes the case where the minimum resource size is less than or equal to the resource threshold corresponding to the user to which the task to be scheduled belongs. Of course, there may also be cases where the minimum resource size is greater than the resource threshold corresponding to the user to which the task to be scheduled belongs.
[0119] If the minimum resource size is greater than the resource threshold, the maximum resource size is determined from the resource sizes matching the second task data. If the maximum resource size is less than or equal to the resource threshold, the resource size occupied by the task to be scheduled is determined based on the maximum resource size. The process of determining the resource size occupied by the task to be scheduled based on the maximum resource size can refer to the previous process of determining the resource size occupied by the task to be scheduled based on the minimum resource size. For example, the maximum resource size can be used as the resource size occupied by the task to be scheduled.
[0120] Based on this, if the minimum upper limit is greater than the user's corresponding resource threshold, it indicates that the resource size required by the task to be scheduled may exceed the limit. Therefore, we can determine whether the maximum lower limit, i.e., the maximum resource size, also exceeds the limit. If it does not exceed the limit, it indicates that the resource size required by the task to be scheduled may not exceed the limit. Therefore, the maximum resource size can be taken as the resource size occupied by the task to be scheduled.
[0121] In some embodiments, if the maximum resource size is also greater than the user's corresponding resource threshold, it indicates that the probability of the resource size required by the task to be scheduled exceeding the limit is high. Therefore, the electronic device determines that the verification fails and does not add the task to be scheduled to the queue. Instead, it prompts the user to modify the task data, such as modifying the batch, to reduce the resources required by the task to be scheduled.
[0122] In some embodiments, the electronic device can also use a random forest algorithm, combined with the task data, to perform linear regression estimation based on historical task data and corresponding resource sizes in a preset task resource proportion database, to obtain the resource size occupied by the task to be scheduled. Based on this, the resource size required by the task to be scheduled can be estimated.
[0123] Optionally, the above-mentioned linear regression prediction method can be used when the upper or lower limit values are inaccurately predicted. If the difference between the minimum resource size and the resource threshold is greater than a first difference, or the difference between the maximum resource size and the resource threshold is greater than a second difference, it indicates that the minimum upper limit value is much larger than the user's corresponding resource threshold, or the maximum upper limit value is much smaller than the user's corresponding resource threshold. In other words, the minimum or maximum upper limit value may be inaccurately predicted. Therefore, electronic devices can use a random forest algorithm, combined with the task data, to perform linear regression prediction based on historical task data and the corresponding resource size, ensuring the accuracy of the predicted resource size required by the scheduled task.
[0124] In some embodiments, if the resource size estimated by linear regression is less than or equal to the user's corresponding resource threshold, it indicates that the estimated resource size has not exceeded the user's limit. In this case, the estimated resource size (i.e., the first resource size) can be used as the resource size occupied by the task to be scheduled.
[0125] If the resource size estimated by linear regression is greater than the user's corresponding resource threshold, it indicates that the estimated resource size exceeds the user's limit. Therefore, the verification is deemed to have failed, and the task to be scheduled is not added to the queue. Instead, the user is prompted to modify the task data, such as modifying the batch, to reduce the resources required by the task to be scheduled.
[0126] Optionally, considering the limitation of the random forest algorithm, which can only predict data within the training set, a task parameter (or factor) can be specified within a visible range, such as batch size. For continuous prediction, if the actual value exceeds the maximum value range of the training set, the predicted value will become a small fluctuation, or it may appear as a horizontal straight line, or even show a downward trend (within the normal range, it is an increasing straight line). For example, if the resources (such as video memory) occupied by 512×512×8 are 20G, then the actual value of 512×512×16 must exceed 24G. However, the predicted value (i.e., the estimated resource size) is less than 24G, and there is even a possibility that the predicted value will decrease instead of increase.
[0127] Therefore, to ensure the accuracy of the predicted values, the electronic device employs continuous prediction and sets a maximum amplitude to determine the accuracy of the predicted values. Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with task data, to perform linear regression estimation to obtain the first resource size;
[0128] If the difference between the first resource size and the second resource size is greater than or equal to the preset resource growth rate, it indicates that the prediction value is accurate. Therefore, the electronic device can use the first resource size as the resource size occupied by the task to be scheduled. The task parameters in the historical task data corresponding to the second resource size (here, or alternatively described as second target task parameters) are smaller than the task parameters in the task data of the task to be scheduled. Optionally, the second target task parameter can be a batch.
[0129] If the difference between the first resource size and the second resource size is less than the preset resource growth rate, it indicates that the predicted value is inaccurate, and the electronic device can prompt the user to modify the factor.
[0130] Optionally, the second target task parameter in the historical data corresponding to the second resource size is smaller than the second target task parameter of the task to be scheduled, and the size parameters are the same. The same size parameters can be referred to the relevant description above.
[0131] For example, if we start predicting a batch of data from 512×512×1 to 512×512×32, the maximum amplitude (i.e., the preset resource growth rate) is 300. Then, working backwards, if the amplitude of a later value is less than 300 compared to its adjacent predecessor, it can be considered erroneous data. Thus, we can accurately determine that the predicted value of 512×512×16 is incorrect and exceeds the limit.
[0132] S203. The electronic device adds the task to be scheduled to the queue.
[0133] In some embodiments, after estimating the resource size of the task to be scheduled, the task is added to the queuing queue, and its task status is updated to "waiting". Figure 4 The task status is updated as shown. Then, the task to be scheduled is inserted into or removed from the queue to achieve scheduling. The process of scheduling tasks will be described below.
[0134] S204. The electronic device schedules the tasks in the queue based on the amount of resources occupied by the tasks to be scheduled.
[0135] For example, an electronic device can periodically (e.g., every few seconds) traverse, i.e., schedule tasks in the queue. Each round of scheduling maintains a corresponding scheduling cache to record the status of each task in that round. The data structure for this task status can be as follows:
[0136] {
[0137] "ids":[
[0138] "3746", # The task ID, a unique identifier. This is ordered. The `ids` parameter reflects the actual order in which the task was enqueued (submitted).
[0139] "3698",
[0140] "3554"
[0141] ],
[0142] "attrs":{#Here, attrs doesn't care about the order of task IDs; it only records the relevant attributes, resources, or queuing information corresponding to each task ID.}
[0143] "3554":{
[0144] "task_type":"train", # The task type in the queue is a training task, model validation task, etc.
[0145] "task_substage_type": [This is data from the event tracking; it's a parameter that needs to be carried when the task is dequeued for execution.]
[0146] "evaluate"
[0147] ],
[0148] "gpu_count": 1, # Number of GPUs: Determines whether a task meets the dequeueing conditions. For example, some tasks require both GPUs to meet the conditions before they can be dequeued.
[0149] "enable_gpu":true, # Whether GPU is required; this is the type of training task.
[0150] "virtual_use_time":1800, # The estimated total time for the current task to run and finish, in seconds.
[0151] "algorithm_name":"Det.v1", #Algorithm name
[0152] "algorithm_type":"detection", #Algorithm type
[0153] "algorithm_network":"m", # Algorithm network name
[0154] "image_scale":[#Image width and height dimensions]
[0155] 2464, 2048
[0157] ],
[0158] "batch_size":2, # Image batch size
[0159] "specification": null, # Resource threshold corresponding to the user to whom this task belongs.
[0160] "img_count":null, # Some algorithm tasks still need to estimate the GPU memory size based on the number of images.
[0161] "lock_gpu_fast":true, # Whether to lock the graphics card immediately before dequeueing (placeholder)
[0162] "max_duration":432000, # The maximum time the task will run; the task will automatically terminate if this time is exceeded.
[0163] "user_id":670,#User ID
[0164] "task_stage":null, #Task execution stage
[0165] "task_ids":[
[0166] "3554"
[0167] ],
[0168] "enqueue_type":"append", # Three modes: submit queue, adjustable queue order, manual dequeue.
[0169] "queue_lock_name":"train:queued_lock", # Queue scheduling lock name
[0170] "queue_name":"train:queued_info", #Scheduled queue name
[0171] "query_thres":16293, # Estimated GPU memory size for this task
[0172] "multi_stage_thres":{#Memory size of other stages of the task}
[0173] "train":16293,#Training phase
[0174] "evaluate":6418, # The amount of GPU memory required for the validation phase after training.
[0175] },
[0176] "speed_up":false, #Algorithm acceleration: Affects video memory size and whether the task supports algorithm acceleration.
[0177] "wait_reason":"wait_for_gpu", # Queuing reasons: insufficient video memory, concurrency limit, queuing in the user's own queue.
[0178] "wait_time":9000, #Estimated waiting time
[0179] "wait_count":1, # Estimated number of waiting tasks
[0180] "wait_progress": 100, # The waiting progress of tasks, representing a percentage of the total queued tasks.
[0181] }
[0182] In some embodiments, as described above, the electronic device can also calculate the queuing status of tasks in the queue, such as estimated queuing time and the number of waiting tasks. The electronic device can record the estimated queuing time of tasks in the queue. Additionally, the electronic device can also record the number of waiting tasks in the queue.
[0183] For example, the electronic device reads queue details data to determine the waiting reason for each task in the queue. These reasons primarily include insufficient electronic device resources, limited concurrent user tasks, and blockage in the user's own small queue. The electronic device can then determine the queuing status of the tasks in the queue based on the waiting reasons.
[0184] Optionally, for the earliest task a in the queue, the electronic device can use the estimated time required for the execution of the task in progress to be completed as the estimated queuing time for task a.
[0185] For other users whose earliest queued task b is not the user to whom the earliest queued task belongs, the electronic device can use the shorter of the estimated time required for the currently executing task to complete and the time required for the completed task a with reserved resources to complete as the estimated queuing time for task b.
[0186] For example, the queue includes tasks 1-5. Tasks 1-5 are arranged in the order they were added to the queue. Task 1 was added earliest. Tasks 2, 4, and 5 belong to user A, and tasks 1 and 3 belong to user B. The estimated queuing time for task 1 can be the estimated time required for task c, which is currently executing, to complete. Furthermore, the number of waiting tasks for task 1 can be 0.
[0187] For Task 2, after Task c completes, since Task 1 has reserved resources, it's possible that Task 1 will execute first, and then Task 2 will execute. Alternatively, Task 1 might not have reserved resources, or it might be unable to execute due to excessive concurrency or resource limitations. In that case, Task 2 will execute after Task c completes.
[0188] Therefore, the shorter of the estimated time required for task c to complete and the estimated time required for task 1 to complete can be used as the estimated queuing time for task 2. Furthermore, when the shorter time is the estimated time required for task c to complete, the number of waiting tasks for task 2 can be 0.
[0189] If the time required for Task 1 to complete is relatively short, the number of waiting tasks for Task 2 can be 1.
[0190] Here, Task 1 can be Task a from above, and Task 2 can be Task b from above.
[0191] Optionally, for task 3, since task 3 and task 1 are tasks in the same user's subqueue, the estimated queuing time for task 3 can be obtained by adding t to the estimated queuing time for task 1. t is a preset time.
[0192] For task 4, since tasks 2 and 4 are in the same user's subqueue, the estimated queuing time for task 4 can be obtained by adding t to the estimated queuing time for task 2. Similarly, the estimated queuing time for task 5 can be obtained by adding 2t to the estimated queuing time for task 2.
[0193] It should be noted that the task queuing situation described above is only one possible implementation. Other methods can also be used to determine the task queuing situation. For example, the queuing time can be estimated based on the order in which tasks are entered into the queue. Taking the queue containing tasks 1-5 as an example, the estimated queuing time for task 1 is the estimated time required for task c, which is currently executing, to complete. The estimated queuing time for task 2 is the estimated queuing time for task 1 plus t. …The estimated queuing time for task 5 is the estimated queuing time for task 5 plus 4t.
[0194] In some embodiments, such as Figure 5 As shown, in step S501, the electronic device reads the queue details data and determines the waiting reason for each task in the queue. Then, in step S502, based on the waiting reason, the electronic device parses out the target task with the shortest waiting time between the currently executing task and the task with reserved resources in the front queue. For example, the target task includes Task 1 and Task 2 mentioned above.
[0195] S503, The electronic device updates the estimated queuing time and / or the number of waiting tasks for the target task to the queue details data.
[0196] Based on this, the queuing status of the target task is updated in the queue details data, making it easier for queuing query interfaces to query the task's queuing progress. Alternatively, the queuing status can be output, such as by sending the queuing information to the user terminal of the user to whom the target task belongs.
[0197] In addition, the queuing status of tasks in the queue mentioned above, such as the estimated queuing time, can be the estimated queuing time of the target task in the queue.
[0198] In some embodiments, for each task in the traversed queue, it is determined whether the task meets a first preset condition. The first preset condition may include that there are no tasks currently executing in the user's tasks to which the task to be scheduled belongs, or that the number of concurrent tasks currently executing in the user's tasks to which the task to be scheduled belongs is less than the number of concurrent tasks corresponding to the user.
[0199] If the scheduled task meets the first preset condition, it indicates that the scheduled task cannot be executed, and the scheduled task can continue to be queued.
[0200] If the task to be scheduled meets the first preset condition, it indicates that the task to be scheduled may be executable. Then, the task to be scheduled in the queue can be scheduled based on the amount of resources occupied by the task to be scheduled.
[0201] Optionally, if the task to be scheduled meets the first preset condition, and the size of the idle resources is greater than or equal to the size of the resources occupied by the task to be scheduled, the task to be scheduled is scheduled to be executed; wherein, the size of the idle resources is determined based on the size of the resources reserved for tasks of users other than the user to whom the task to be scheduled belongs.
[0202] In addition, if the available resources are less than the resources occupied by the task to be scheduled, and the task to be scheduled cannot be executed temporarily, the task to be scheduled will continue to be queued if the task meets the first preset condition.
[0203] Furthermore, the size of the idle resources is determined based on the reserved resources and the occupied resources of tasks of users other than the user to whom the task to be scheduled belongs.
[0204] Based on this, tasks in the queue are polled. If a task meets the first preset condition, the system further checks whether the available resources are sufficient to meet the task's requirements. If the requirements are met, the task can be executed directly, ensuring timely completion. This effectively prevents situations where a user submits a large number of tasks at once, consuming significant resources and causing other users' tasks to wait for extended periods due to insufficient resources. Additionally, it prevents resource contention.
[0205] In some embodiments, for each task being traversed, it is determined whether the user to which the task belongs already has a task queued in the scheduling cache. If a task is queued, it means that the previously enqueued task is still in the queue, therefore, the task needs to continue queuing and does not need to be dequeued. Alternatively, the task can be added to the subqueue corresponding to the user to which the task belongs.
[0206] If no tasks are queued, the electronic device can continue to determine whether the tasks being traversed meet the first preset condition, such as whether there are any tasks currently being executed among the user's tasks, and whether the number of concurrent tasks currently being executed has reached the set upper limit (i.e., the number of concurrent tasks corresponding to the user). If the upper limit has been reached, it indicates that there is no need to schedule any tasks for traversal, and the electronic device can continue to traverse the next task.
[0207] If there are no tasks in progress, or the upper limit has not been reached, the electronic device can continue to check whether the tasks being traversed are limited by the resources of the electronic device itself, such as the graphics card, that is, to determine whether the remaining resources of the electronic device can meet the needs of the traversed tasks.
[0208] If other users' tasks that were queued before the task being iterated have reserved resources, making it impossible for the available resources on the electronic device to meet the needs of the task being iterated (e.g., a reserved graphics card belonging to the task being iterated), then the task being iterated does not meet the execution conditions and cannot be scheduled, remaining in the queue. Furthermore, the task being iterated must wait for the task that reserved the resources to release them before being scheduled.
[0209] If the user of the task being iterated over has more electronic device resources, high concurrency, or other value-added resources such as accelerator cards, then the electronic device can use idle resources to schedule the task being iterated over, provided that other users' tasks have reserved available resources for that task. If scheduling fails, it means the task being iterated over is temporarily unavailable and continues to wait in the queue. Additionally, the estimated queuing time (i.e., expected waiting time) and / or the number of waiting tasks for the task being iterated over can be recalculated. If scheduling succeeds, the electronic device removes the task being iterated over from the queue (i.e., dequeues) and begins executing the task. In general, resources are not reserved for tasks of users with concurrency limits. However, if the electronic device itself is resource-constrained (e.g., insufficient graphics card resources), resources will be reserved for users to prevent the priority execution of tasks from later-entered users during subsequent scheduling. This effectively avoids a situation where one user submits a large number of tasks, causing other users to run out of resources and have to queue up, and also prevents resource contention issues.
[0210] Among them, the accelerator card is a reserved and dedicated resource, which may be idle.
[0211] Optionally, in the event of task scheduling failure during the traversal, the electronic device can also reserve resources for the failed tasks to prevent them from remaining unexecuted for an extended period. For example, the resources could be graphics cards. The electronic device can sequentially retrieve all reserved graphics cards from the queue, and determine from the retrieved reserved graphics cards the graphics card capable of running the failed task. Then, the electronic device can determine whether the waiting time required to release the task from the determined graphics card is shorter than the waiting time required to release a graphics card from an executing task, and thus reserve the graphics card with the shorter waiting time as the graphics card for the failed task.
[0212] It is understandable that the tasks traversing the queue mentioned above, i.e. the tasks being polled, may include tasks waiting to be scheduled.
[0213] In some embodiments, electronic devices can prioritize using the allocated graphics card based on the resource size of the task to be scheduled, allowing the task to share the graphics card with other tasks. When scheduling large tasks that consume a lot of resources, the graphics card can be used independently, making full and reasonable use of the resource consumption of tasks of different sizes. This allows a single electronic device (such as a server) to run many small and large tasks simultaneously. Furthermore, it can perform load balancing across multiple servers, preventing excessive server load.
[0214] In some embodiments, the system can automatically switch to new electronic device resources based on the user's latest level. For example, if the user's latest level is VIP, VIP users can use acceleration cards, so a new acceleration card can be assigned to that user to speed up the task progress. Additionally, the estimated queuing time and the number of waiting tasks can be updated synchronously.
[0215] In some embodiments, the preset task resource ratio library can be automatically expanded. The electronic device can periodically read task data from historical tasks in the relevant database, such as the resource size, size parameters, batches, etc. of the historical tasks. Then, the electronic device can add the read historical task data to the preset task resource ratio library, thereby facilitating the self-learning of the electronic device and ensuring the accuracy of resource estimation.
[0216] Among them, self-learning refers to the fact that electronic devices support the linear regression and periodic training functions of the random forest algorithm. The more training data there is, the more accurate the resource prediction will be.
[0217] In this application, the electronic device automatically and reasonably determines the resource requirements based on the user's submitted task and allocates resources accordingly. Furthermore, it automatically verifies and enters the corresponding queue based on the user's level. Then, according to the scheduling system, it automatically arranges for the task to be executed at an appropriate time, realizing the intelligent queuing and automatic scheduling function for batch tasks on the AI platform.
[0218] To facilitate better implementation of the task scheduling method provided in this application, this application also provides a task scheduling apparatus based on the above-described task scheduling method. The meanings of the terms used are the same as in the task scheduling method described above, and specific implementation details can be found in the descriptions within the method embodiments.
[0219] Figure 6 This is a schematic diagram of a task scheduling device provided in an embodiment of this application. Please refer to [link / reference]. Figure 6 This task scheduling device has the functionality to implement the method example described above on the electronic device side. This functionality can be implemented in hardware or by hardware executing corresponding software. The task scheduling device can be the electronic device described above, or it can be installed within an electronic device. For example... Figure 6 As shown, the task scheduling device 600 may include: a task acquisition module 610, a queuing module 620, and a task scheduling module 630.
[0220] The task acquisition module is used to acquire task data for tasks to be scheduled.
[0221] The resource estimation module is used to estimate the amount of resources occupied by the task to be scheduled based on the task data.
[0222] The queuing module is used to add the task to be scheduled to the queuing queue;
[0223] The task scheduling module is used to schedule the tasks in the queue based on the amount of resources occupied by the tasks to be scheduled.
[0224] In one example, the resource estimation module is specifically used for:
[0225] If a target resource size matching the task data exists in the preset task resource proportion library, the target resource size shall be used as the resource size occupied by the task to be scheduled.
[0226] If there is no target resource size matching the task data in the preset task resource proportion library, target task data that is similar to the task data is determined, and the resource size occupied by the task to be scheduled is determined according to the resource size matching the target task data.
[0227] In one example, the task data includes at least one task parameter; the target task data includes first task data, wherein the task parameters in the first task data are greater than or equal to the task parameters in the task data of the task to be scheduled.
[0228] Correspondingly, the resource estimation module is specifically used for:
[0229] Determine the smallest resource size from the resource sizes that match the data of the first task;
[0230] If the minimum resource size is less than or equal to the resource threshold corresponding to the user to which the task to be scheduled belongs, the minimum resource size shall be used as the resource size occupied by the task to be scheduled.
[0231] In one example, the target task data further includes second task data, where the task parameters in the second task data are smaller than the task parameters in the task data of the task to be scheduled;
[0232] Correspondingly, the resource estimation module is specifically used for:
[0233] If the minimum resource size is greater than the resource threshold, the maximum resource size is determined from the resource sizes that match the second task data;
[0234] If the maximum resource size is less than or equal to the resource threshold, the resource size occupied by the task to be scheduled is determined based on the maximum resource size, such as using the maximum resource size as the resource size occupied by the task to be scheduled.
[0235] In one example, the resource estimation module is specifically used for:
[0236] Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the resource size occupied by the task to be scheduled.
[0237] In one example, the resource estimation module is specifically used for:
[0238] If the difference between the minimum resource size and the resource threshold is greater than the first difference, or the difference between the maximum resource size and the resource threshold is greater than the second difference, a random forest algorithm is used to perform linear regression prediction based on historical task data and the corresponding resource size, combined with the task data.
[0239] In one example, the resource estimation module is specifically used for:
[0240] Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the first resource size;
[0241] If the difference between the first resource size and the second resource size is greater than or equal to the preset resource growth rate, the first resource size is used as the resource size occupied by the task to be scheduled; wherein, the task parameters in the historical task data corresponding to the second resource size are less than or equal to the task parameters in the task data of the task to be scheduled.
[0242] In one example, the task scheduling module is specifically used for:
[0243] If the task to be scheduled meets the first preset condition, the task to be scheduled in the queue is scheduled based on the amount of resources occupied by the task to be scheduled.
[0244] The first preset condition includes that there are no tasks in execution among the tasks of the user to which the task to be scheduled belongs, or that the number of concurrent tasks in execution among the tasks of the user to which the task to be scheduled belongs is less than the number of concurrent tasks corresponding to the user.
[0245] In one example, the task scheduling module is specifically used for:
[0246] If the size of the idle resources is greater than or equal to the size of the resources occupied by the task to be scheduled, the task to be scheduled is scheduled; wherein, the size of the idle resources is determined based on the size of the resources reserved for tasks of users other than the user to whom the task to be scheduled belongs.
[0247] In one example, the queuing module is also used for:
[0248] Record the estimated queuing time for tasks in the queue.
[0249] Figure 7 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application. Figure 7 The dashed line in the text indicates that the unit or module is optional. Figure 7 The electronic device 700 can be used to implement the methods described in the above method embodiments. The electronic device 700 can be a chip, a terminal device, or a server.
[0250] Electronic device 700 may include one or more processors 710. The processor 710 can support the electronic device 700 in implementing the methods described in the preceding method embodiments. The processor 710 may be a general-purpose processor or a special-purpose processor. For example, the processor may be a Central Processing Unit (CPU). Alternatively, the processor may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0251] The electronic device 700 may also include one or more memories 720. Computer programs are stored on the memories 720. The memories 720 may be independent of the processor 710 or integrated into the processor 710.
[0252] The electronic device 700 may also include a transceiver 730. The processor 710 can communicate with other devices or chips via the transceiver 730. For example, the processor 710 can send and receive data with other devices or chips via the transceiver 730.
[0253] The computer program in memory 720 can be executed by processor 710, causing processor 710 to perform the following steps:
[0254] Obtain task data for tasks to be scheduled;
[0255] Based on the task data, the resource size occupied by the task to be scheduled is estimated;
[0256] Add the task to be scheduled to the queue;
[0257] The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
[0258] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0259] Therefore, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, the computer program being loaded by a processor to execute the steps described in the above-described method embodiments of this application. For example, the computer program, when loaded by a processor, can execute the following steps:
[0260] Obtain task data for tasks to be scheduled;
[0261] Based on the task data, the resource size occupied by the task to be scheduled is estimated;
[0262] Add the task to be scheduled to the queue;
[0263] The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
[0264] For details on the implementation of each of the above operations / steps, please refer to the previous examples, which will not be repeated here.
[0265] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0266] Since the computer program stored in the computer-readable storage medium can execute the steps in any of the above method embodiments provided in the embodiments of this application, the beneficial effects that the methods described in any of the above method embodiments can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0267] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the methods provided in the various optional implementations of the above embodiments.
[0268] The above provides a detailed description of a task scheduling method and electronic device provided by the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A task scheduling method, characterized in that, include: Obtain task data for tasks to be scheduled; Based on the task data, the resource size occupied by the task to be scheduled is estimated; Add the task to be scheduled to the queue; The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
2. The method according to claim 1, characterized in that, The step of estimating the resource size occupied by the task to be scheduled based on the task data includes: If a target resource size matching the task data exists in the preset task resource proportion library, the target resource size shall be used as the resource size occupied by the task to be scheduled. If there is no target resource size matching the task data in the preset task resource proportion library, target task data that is similar to the task data is determined, and the resource size occupied by the task to be scheduled is determined according to the resource size matching the target task data.
3. The method according to claim 2, characterized in that, The task data includes at least one task parameter; the target task data includes first task data, wherein the task parameter in the first task data is greater than or equal to the task parameter in the task data of the task to be scheduled. Determining the resource size occupied by the task to be scheduled based on the resource size matching the target task data includes: Determine the smallest resource size from the resource sizes that match the data of the first task; If the minimum resource size is less than or equal to the resource threshold corresponding to the user to which the task to be scheduled belongs, the resource size occupied by the task to be scheduled is determined based on the minimum resource size.
4. The method according to claim 3, characterized in that, The target task data also includes second task data, where the task parameters in the second task data are smaller than the task parameters in the task data of the task to be scheduled. Determining the resource size occupied by the task to be scheduled based on the resource size matching the target task data includes: If the minimum resource size is greater than the resource threshold, the maximum resource size is determined from the resource sizes that match the second task data; If the maximum resource size is less than or equal to the resource threshold, the resource size occupied by the task to be scheduled is determined based on the maximum resource size.
5. The method according to any one of claims 1 to 4, characterized in that, The step of estimating the resource size occupied by the task to be scheduled based on the task data includes: Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the resource size occupied by the task to be scheduled.
6. The method according to claim 5, characterized in that, The process of using a random forest algorithm, combined with the task data, to perform linear regression prediction based on historical task data and corresponding resource sizes includes: If the difference between the minimum resource size and the resource threshold is greater than the first difference, or the difference between the maximum resource size and the resource threshold is greater than the second difference, a random forest algorithm is used to perform linear regression prediction based on historical task data and the corresponding resource size, combined with the task data.
7. The method according to claim 5, characterized in that, Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the resource size occupied by the task to be scheduled, including: Based on historical task data and corresponding resource sizes, a random forest algorithm is used, combined with the task data, to perform linear regression estimation to obtain the first resource size; If the difference between the first resource size and the second resource size is greater than or equal to the preset resource growth rate, the first resource size is used as the resource size occupied by the task to be scheduled; wherein, the task parameters in the historical task data corresponding to the second resource size are less than or equal to the task parameters in the task data of the task to be scheduled.
8. The method according to any one of claims 1 to 4, characterized in that, The step of scheduling the tasks in the queue based on the resource size occupied by the tasks to be scheduled includes: If the task to be scheduled meets the first preset condition, the task to be scheduled in the queue is scheduled based on the amount of resources occupied by the task to be scheduled. The first preset condition includes that there are no tasks in execution among the tasks of the user to which the task to be scheduled belongs, or that the number of concurrent tasks in execution among the tasks of the user to which the task to be scheduled belongs is less than the number of concurrent tasks corresponding to the user.
9. The method according to claim 8, characterized in that, The step of scheduling the tasks in the queue based on the resource size occupied by the tasks to be scheduled includes: If the size of the idle resources is greater than or equal to the size of the resources occupied by the task to be scheduled, the task to be scheduled is scheduled; wherein, the size of the idle resources is determined based on the size of the resources reserved for tasks of users other than the user to whom the task to be scheduled belongs.
10. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Record the estimated queuing time for tasks in the queue.
11. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores computer programs or instructions, and when the computer programs or instructions are executed by the processor, the processor causes the processor to perform the following steps: Obtain task data for tasks to be scheduled; Based on the task data, the resource size occupied by the task to be scheduled is estimated; Add the task to be scheduled to the queue; The tasks to be scheduled in the queue are scheduled based on the amount of resources occupied by the tasks to be scheduled.
12. A computer-readable storage medium, characterized in that, It stores computer programs or instructions that, when executed by a processor, implement the steps of the task scheduling method as described in any one of claims 1 to 10.