Resource allocation method, device, and electronic equipment
By obtaining the resource size required for the task and adjusting the computing resource blocks, the flexible allocation of computing resources is solved, and the problem of low computing resource utilization is improved and the resource utilization and task execution efficiency is improved.
Patent Information
- Application Number
- CN202510772174.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-06-10
AI Technical Summary
The utilization rate of computing resources is low because the fixedly divided computing resource blocks do not match the size of computing resources required by the task.
Obtain the size of the computing resources required for the pending task and adjust the computing resource blocks of the target computing resource node to achieve flexible allocation and ensure that the computing resource blocks match the resources required for the task.
It improves the utilization rate of computing resources, avoids resource waste and insufficient resources, and improves task execution efficiency.
Smart Images

Figure CN120295796B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource allocation method and device, and electronic equipment. Background Art
[0002] When computing resources are processing a large number of tasks, computing resource nodes need to process multiple tasks in parallel. The amount of computing resources required for each task is different, so computing resources need to be allocated for the tasks.
[0003] In the relevant technology of resource allocation, a computing resource node is usually fixedly divided into multiple computing resource blocks. Different tasks are processed in different computing resource blocks. The size of computing resources required for different tasks is not the same. The fixed division of computing resource blocks does not match the size of computing resources required by the tasks, resulting in low utilization of computing resources. Summary of the Invention
[0004] The present application provides a method and device for resource allocation, and an electronic device to at least solve the problem of low utilization of computing resources in related technologies.
[0005] This application provides a resource allocation method, including:
[0006] Obtaining a first computing resource size required for the task to be processed;
[0007] Adjusting at least one computing resource block of a target computing resource node corresponding to the task to be processed according to the first computing resource size; the target computing resource node includes at least two computing resource blocks;
[0008] The task to be processed is processed based on the adjusted at least one computing resource block to obtain a processing result of the task to be processed.
[0009] The present application also provides a resource allocation device, comprising:
[0010] An acquiring unit, configured to acquire a first computing resource size required for the task to be processed;
[0011] An adjusting unit, configured to adjust at least one computing resource block of a target computing resource node corresponding to the task to be processed according to the size of the first computing resource; the target computing resource node includes at least two computing resource blocks;
[0012] The processing unit is configured to process the task to be processed based on the adjusted at least one computing resource block to obtain a processing result of the task to be processed.
[0013] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned resource allocation methods when executing the computer program.
[0014] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned resource allocation methods are implemented.
[0015] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned resource allocation methods when executed by a processor.
[0016] Through this application, by obtaining the first computing resource size required for the task to be processed, at least one computing resource block of the target computing resource node corresponding to the task to be processed is adjusted according to the first computing resource size, thereby achieving flexible allocation of computing resource blocks to match the resources required by the task. Then, based on the adjusted at least one computing resource block, the task to be processed is processed to obtain the processing result of the task to be processed, avoiding the mismatch between the fixed division of computing resource blocks and the task to be processed, and improving the utilization of computing resources. Therefore, the technical problem of low computing resource utilization can be solved, achieving the technical effect of improving the utilization of computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 A flowchart of a resource allocation method provided in an embodiment of the present application;
[0019] Figure 2 A flowchart of a method for adjusting a computing resource block provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of a process flow for video memory management provided in an embodiment of the present application;
[0021] Figure 4 This is a schematic diagram of the structure of an isolated computing unit disclosed in an embodiment of the present application;
[0022] Figure 5 A schematic diagram of the structure of a resource allocation device provided in an embodiment of the present application;
[0023] Figure 6 A schematic diagram of the structure of another resource allocation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0026] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0027] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the resource allocation method depends, the specific application environment architecture or specific hardware architecture is described herein.
[0028] An embodiment of the present application provides a method for resource allocation, and the method is described in detail in conjunction with the execution flow of the method for resource allocation.
[0029] Figure 1 A flowchart of a resource allocation method provided in an embodiment of the present application.
[0030] like Figure 1 As shown, the method comprises the following steps:
[0031] Step 101: Obtain the size of first computing resources required for the task to be processed.
[0032] A pending task is a computational task or workload to be executed, typically a task that requires computing resources to complete. For example, these tasks can be computationally intensive tasks, data processing tasks, or other tasks that require computing resources such as processors and memory. In the embodiment of the present application, the pending task can be a model execution task.
[0033] The first computing resource size refers to the amount of computing resources required to process the task, typically expressed in specific units of computing resources (such as the number of processor cores, memory capacity, and computational duration). The first computing resource size is determined by the nature and complexity of the task and represents the amount of computing resources required to execute the task.
[0034] When a task enters the system, it is first analyzed. For example, by analyzing the task's program code, algorithm complexity, data size, and other information, the system estimates the computational intensity required to complete the task. The system then reviews historical records of similar tasks to examine their completion times and resource utilization with different computing resources. For example, if a task of the same type and data size has previously been completed within a reasonable time using four central processing unit (CPU) cores and 8GB of memory, this can be used as a reference for the computational resource size of the task. Using a pre-trained machine learning or deep learning model, the model inputs relevant features of the task (such as task type and input data size), and outputs a predicted computational resource size. For example, a neural network model trained on a large amount of task sample data can output the required graphics processing unit (GPU) computing power based on the image resolution and processing algorithm type of the input image processing task.
[0035] By understanding the computing resource size required for each task, the system can allocate appropriate computing resources to each task, avoiding excessive or insufficient resources. Compared with traditional fixed resource allocation methods, this approach can significantly improve computing resource utilization.
[0036] Step 102: Adjust at least one computing resource block of a target computing resource node corresponding to the task to be processed according to the first computing resource size; the target computing resource node includes at least two computing resource blocks.
[0037] A target computing resource node refers to the computing resource node selected from multiple computing resource nodes to process the currently pending task. A computing resource node can be understood as a unit with a certain level of computing power, such as a server, a processor chip, or a computing unit in a computing cluster. A target computing resource node contains at least two computing resource blocks. A computing resource block is the basic unit of computing power that can be flexibly allocated within the target computing resource node. Each computing resource block has a specific computing resource configuration, such as the number of CPU cores, memory capacity, GPU computing power, and other quantitative indicators. A computing resource block is the basic computing unit that constitutes the target computing resource node. Each computing resource block has a clear computing resource size and can be allocated, adjusted, or used in combination according to task requirements to meet the resource requirements of different computing tasks.
[0038] In the target computing resource node, the system first determines which computing resource blocks can be used for the currently pending task. This involves checking the current status of each computing resource block (e.g., whether it is idle, currently processing tasks, etc.) and whether its computing resource size matches or is close to the first computing resource size required by the pending task. Based on a comparison of the first computing resource size of the pending task with the sizes of the existing computing resource blocks in the target computing resource node, the system selects an appropriate adjustment method. For example, if a computing resource block size exactly meets the task requirements, it is allocated directly. If a larger idle computing resource block exists, it can be split into smaller blocks to precisely match the task requirements. If no idle blocks are fully matched, but some non-idle blocks can be adjusted (e.g., if task priority allows preemption), this may involve stopping lower-priority tasks and freeing up the corresponding block resources to meet the current task requirements. After adjusting the computing resource blocks, the target computing resource node's resource pool information is promptly updated, including recording the allocation status of each computing resource block, the tasks to which it belongs, and changes in computing resource size. This helps in the subsequent management and allocation of resources, ensuring that the computing resources of the entire node are effectively utilized and reasonably allocated.
[0039] By adjusting the computing resource blocks in the target computing resource node based on the size of the first computing resource required by the task, refined allocation of computing resources can be achieved. This avoids the resource waste or shortage caused by traditional fixed division of computing resource blocks, improves computing resource utilization, and ensures that each task receives just the right amount of resource support, leading to better task completion.
[0040] Step 103: Process the task to be processed based on the adjusted at least one computing resource block to obtain a processing result of the task to be processed.
[0041] Adjusted computing resource blocks refer to one or more computing resource blocks that meet the computing resource requirements of a task after reasonable adjustments (such as splitting, merging, or releasing) are made to the computing resource blocks in the target computing resource node based on the first computing resource size required by the task to be processed. These blocks have clear computing resource configurations (such as the number of CPU cores, memory capacity, and computing power) and can provide precise resource support for the task. The processing result refers to the final output of the task after the task is completed using the adjusted computing resource blocks. It can be calculated data, generated files, completed operations, etc., depending on the type and goal of the task.
[0042] To-be-processed tasks are assigned to the adjusted computing resource blocks, and resource binding relationships are established between the tasks and these blocks. This ensures that during task execution, the tasks can use the allocated computing resource blocks exclusively or shared, ensuring sufficient resources for processing. Based on scheduling policies such as task priority and dependencies, tasks are placed in the corresponding task queues for execution. When a task begins execution, the computing resource blocks begin providing computing support, such as CPU execution of task code and memory storage of task data. Simultaneously, the task performs operations and processing on the allocated resources according to its predefined algorithms and logic. During task execution, the usage of computing resource blocks and the running status of the task, such as CPU utilization, memory usage, and task progress, are monitored in real time. If resources are insufficient or a task completes prematurely, the allocation of computing resource blocks can be dynamically adjusted to optimize task processing efficiency and resource utilization. After task processing is completed, the processing results, including output data and result status, are collected and fed back to the corresponding user or system. This can be used for subsequent analysis, decision-making, or further task processing. At the same time, the computing resource block occupied by the task is released and marked as idle so that it can be used by other subsequent tasks.
[0043] By allocating an adjusted and appropriate computing resource block to each task, we ensure that the task has sufficient resource support during operation, avoiding problems such as task waiting, delays or frequent switching due to insufficient resources, thereby improving the execution efficiency of the task and enabling it to be completed faster.
[0044] Through this application, by obtaining the first computing resource size required for the task to be processed, at least one computing resource block of the target computing resource node corresponding to the task to be processed is adjusted according to the first computing resource size, thereby achieving flexible allocation of computing resource blocks to match the resources required by the task. Then, based on the adjusted at least one computing resource block, the task to be processed is processed to obtain the processing result of the task to be processed, avoiding the mismatch between the fixed division of computing resource blocks and the task to be processed, and improving the utilization of computing resources. Therefore, the technical problem of low computing resource utilization can be solved, achieving the technical effect of improving the utilization of computing resources.
[0045] As a refinement of step 102, when adjusting at least one computing resource block of the target computing resource node corresponding to the task to be processed according to the first computing resource size, it can be implemented in the following manner but is not limited to: Figure 2 As shown, Figure 2 A flowchart of a method for adjusting a computing resource block provided in an embodiment of the present application includes:
[0046] Step 201: Determine whether a first computing resource block exists in a target computing resource node; the first computing resource block is the smallest idle computing resource block required to meet the first computing resource size.
[0047] The smallest free computing resource block is an unallocated or unoccupied computing resource block in the target computing resource node, and its size exactly matches the task's first computing resource size requirement. This block is the smallest block that can fully meet the task's resource requirements without wasting resources.
[0048] The system continuously maintains detailed information about each computing resource block within the target computing resource node, including each block's computing resource size and usage status (free or occupied). This information is typically stored in a resource management database or data structure and updated in real time to reflect the latest status changes of the computing resource blocks. For example, when a task is completed, a previously occupied block is marked as free. After obtaining the first computing resource size of the pending task, the target computing resource node is searched for each free computing resource block in ascending order of computing resource size to determine whether a computing resource block with a size equal to or greater than the first computing resource size is the smallest block that meets the requirements. For example, if the pending task requires 4GB of computing resources, and the target computing resource node has multiple free blocks with memory sizes of 2GB, 4GB, 8GB, etc., then the 4GB free block is the first computing resource block. To improve search efficiency, fast search algorithms, such as binary search, can be used. First, the free computing resource blocks in the target computing resource node are sorted by computing resource size to construct an index structure. During the search, based on the first computing resource size of the task to be processed, the binary search method is used to quickly locate the block position range that may meet the conditions, and then the smallest free block that meets the computing resource size requirements is accurately screened out to determine whether it exists.
[0049] It can accurately find the smallest free block that meets the computing resource requirements of the task, achieving efficient resource matching. This ensures that the task has sufficient computing resources to execute, while avoiding the idleness and waste of resources caused by allocating too much resources to the task, thereby improving the utilization rate of the entire computing resource system.
[0050] Step 202: If the target computing resource node has a first computing resource block, determine whether the second computing resource size of the first computing resource block is greater than the first computing resource size.
[0051] The second computing resource size refers to the actual physical resource size of the first computing resource block (such as CPU, memory, etc.), which is different from the initially allocated first computing resource size due to factors such as system optimization and scheduling.
[0052] After determining that the target computing resource node contains a first computing resource block, the specific value of the second computing resource size corresponding to the first computing resource block is directly read from a resource management database or data structure maintained by the system. This value is pre-recorded in the system, typically determined and stored when the computing resource block is created or initialized. The obtained second computing resource size is numerically compared with the first computing resource size required for the task to be processed. This can be implemented using simple arithmetic comparison instructions. For example, in a computer program, a comparison operator (such as ">") is used to determine whether the second computing resource size is greater than the first computing resource size. Based on the comparison result, a corresponding judgment flag or signal is output. If the relationship is greater than, a flag indicating that the second computing resource size is greater than the first computing resource size is output; otherwise, a negative flag is output. This flag serves as a basis for subsequent process control to determine whether operations such as splitting the first computing resource block are necessary.
[0053] By determining whether the second computing resource size of the first computing resource block is greater than the first computing resource size, the degree of match between the computing resource block and the task requirements can be further accurately determined. This facilitates subsequent reasonable adjustments to the computing resource block based on actual conditions, such as splitting, thereby achieving more accurate resource allocation and avoiding resource waste.
[0054] Step 203: If the second computing resource size of the first computing resource block is larger than the first computing resource size, the first computing resource block is divided into at least two second computing resource blocks; the at least two second computing resource blocks include at least one target second computing resource block of a third computing resource size equal to the first computing resource size; the at least one computing resource block after adjustment includes at least two second computing resource blocks.
[0055] Second computing resource blocks are new computing resource blocks obtained by splitting the first computing resource block. The size and configuration of these blocks are adjusted accordingly based on the split operation. At least one block (the target second computing resource block) has a third computing resource size equal to the first computing resource size required for the task. The remaining blocks, depending on the split, form new computing resource blocks that can be used for subsequent allocation to other tasks or continue to exist as divisible resources. The third computing resource size, which is the computing resource size of the target second computing resource block, is equal to the first computing resource size required for the task being processed. This size is obtained through precise segmentation and fully matches the computing resource size required by the task.
[0056] After confirming that the second computing resource size of the first computing resource block is larger than the first computing resource size, the first step is to determine whether the block is divisible. This primarily depends on whether the actual physical or logical architecture of the computing resource supports splitting. For example, for memory resource blocks, it's necessary to examine whether the memory management unit supports memory partitioning. For resources like processor cores, it's necessary to determine whether the operating system or hardware architecture allows for splitting multiple cores into smaller execution units. If splitting is supported, proceed with the subsequent splitting operation. If not, it may be necessary to explore alternative solutions, such as finding another suitable computing resource block or adjusting the task's resource requirements. A reasonable splitting strategy should be developed based on factors such as the difference between the second and first computing resource sizes of the first computing resource block and the usage of other computing resource blocks in the target computing resource node. The splitting strategy should ensure that, after splitting, the third computing resource size of at least one of the two second computing resource blocks is equal to the first computing resource size required by the task. Furthermore, the sizes of the other blocks should be as reasonable as possible to facilitate the allocation and use of subsequent tasks. For example, assuming the second computing resource size of a first computing resource block is 16GB of memory, and the first computing resource size required by a task is 8GB, the splitting strategy could be to split the 16GB of memory into one 8GB and one 8GB second computing resource block. This not only meets the needs of the current task, but also makes the remaining 8GB memory block easily available for other tasks with similar requirements. According to the established splitting strategy, the specific splitting operation is executed by calling the underlying resource management interface or related hardware instructions. During the splitting process, the integrity and consistency of the computing resources must be ensured to avoid data loss or resource anomalies caused by the splitting operation. For example, when splitting a memory block, the data in the original memory block must first be backed up or migrated. Then, the memory management unit must be reconfigured to divide the new memory blocks. Each new second computing resource block must be assigned corresponding identification and attribute information, such as the starting address and size, so that the system can correctly identify and manage these new blocks. After the splitting operation is completed, the resource information of the target computing resource node is promptly updated, including the number, size, and usage status of the computing resource blocks. This updated information is recorded in the resource management database or data structure for subsequent task allocation and resource management operations. For example, newly generated second computing resource blocks are marked as available, and detailed information such as their third computing resource sizes is recorded so that other tasks can quickly find suitable computing resource blocks when needed.
[0057] By splitting the first computing resource block into at least two second computing resource blocks, and ensuring that the third computing resource size of at least one of these blocks is equal to the first computing resource size required by the task, we achieve a precise match between computing resources and task requirements. This avoids resource waste caused by overly large computing resource blocks, while also ensuring that tasks receive just the right amount of resources, improving resource utilization efficiency.
[0058] As a refinement of step 103, when executing the processing of the task to be processed based on at least one adjusted computing resource block to obtain the processing result of the task to be processed, it can be implemented in but not limited to the following ways, including: using the target second computing resource block to process the task to be processed and obtain the processing result of the task to be processed.
[0059] The target second computing resource block refers to the specific block in the adjusted second computing resource block that is equal to the first computing resource required for the task to be processed. It can accurately meet the computing resource requirements of the task and is the computing resource unit actually used during the task execution.
[0060] Retrieve pending tasks from the task scheduling queue and assign them to the compute node with the target second computing resource block. This is typically accomplished by the task scheduling system based on factors such as resource allocation policies and task priority. Bind the pending task to the target second computing resource block, ensuring that the task has exclusive or shared access to the computing resources in that block during execution. This involves configuring the operating system or resource management software, such as setting memory allocation and CPU core binding. Load the data required by the pending task from storage devices (such as hard drives or network storage) into the memory of the compute node where the target second computing resource block resides, enabling the task to quickly access and process this data. Configure the corresponding runtime environment based on the task's requirements, including setting environment variables and loading required software libraries and dependencies, to ensure the task runs in a suitable working environment. Initiate execution of the pending task on the target second computing resource block, typically by calling the task's execution program or function. Monitor the target second computing resource block's resource usage in real time, such as CPU usage, memory usage, and network bandwidth, to ensure sufficient resource support for task execution and promptly identify and address potential resource bottlenecks or anomalies. After the task is completed, the processing results are collected from the computing node where the target second computing resource block is located. This may include operations such as reading output data from memory and generating result files. The collected processing results are fed back to the corresponding user or system so that the user can view and analyze the results, or the system can perform further processing and decision-making based on the results.
[0061] By using the targeted second computing resource block, we can ensure that tasks receive just the right amount of resources, avoiding over-allocation or under-allocation of resources. This improves computing resource utilization, allowing limited resources to serve more tasks, thereby improving resource utilization efficiency across the entire system.
[0062] In practical applications, after using the target second computing resource block to process the task to be processed and obtaining the processing result of the task to be processed, the target second computing resource block needs to be processed, which can be achieved by but not limited to the following methods, including: marking the target second computing resource block as an idle computing resource block; determining whether there is an idle computing resource block that is adjacent to the marked target second computing resource block; if there is an idle computing resource block that is adjacent to the marked target second computing resource block, merging the idle computing resource block that is adjacent to the marked target second computing resource block and the marked target second computing resource block to obtain a merged idle computing resource block.
[0063] An idle computing resource block refers to a computing resource block that is not currently occupied by any task and can be allocated to a new task at any time. These blocks are on standby, ready to provide support for new computing needs at any time. In this embodiment, proximity refers to the close physical or logical adjacency of computing resource blocks. Physical proximity means that the two blocks are continuous in hardware layout, such as the continuous address space on a memory stick; logical proximity means that in the scheduling and allocation logic of the resource management system, they are regarded as mergeable continuous resource units, even if they may not be continuous in physical location. Merging idle computing resource blocks refers to the operation of integrating two or more adjacent idle computing resource blocks into a larger idle computing resource block. The merged block has a larger computing resource size and can meet the needs of tasks that require more resources.
[0064] After task processing is complete, the resource management system's scheduling module sends a command to update the status of the target second computing resource block from "in use" to "free." This typically involves modifying the corresponding status field in the resource management database or data structure. The target second computing resource block is then unbound from the completed task, ensuring that it is no longer occupied by the task and can be accessed by other tasks. The resource management system maintains a spatial index of computing resource blocks, recording information such as the location, size, and status of each block. This index can be based on physical addresses or a logical resource allocation map. Based on the spatial index, blocks adjacent to the target second computing resource block are checked to determine if they exist and are free. For physical proximity, this is checked by checking for continuity in memory addresses or hardware resource locations; for logical proximity, it is checked by checking whether the scheduling and allocation logic in the resource management system considers them mergeable. If adjacent free computing resource blocks exist, the resource management system's merging module merges these free blocks with the target second computing resource block to form a larger free computing resource block. After the merger is completed, the resource management database or data structure is updated to record information such as the size, location, and status of the new block after the merger to ensure that the system can accurately identify and manage this new free block.
[0065] Merging adjacent idle computing resource blocks can reduce resource fragmentation and improve resource utilization. By integrating small blocks of idle resources into larger blocks, it can better meet the needs of tasks that require a large amount of resources and avoid the problem of inefficient utilization caused by scattered resources.
[0066] In actual applications, after determining whether the first computing resource block exists in the target computing resource node, other computing resource blocks can be used to process the pending task, which can be implemented in but not limited to the following ways, including: if the first computing resource block does not exist in the target computing resource node, then obtaining the first priority of the pending task, and obtaining the second priority of the processing task processed by the third computing resource block in the target computing resource node; the third computing resource block is the smallest non-idle computing resource block required to meet the first computing resource size; if the first priority is greater than the second priority, then stopping the third computing resource block from processing the processing task, and using the third computing resource block to process the pending task.
[0067] The first priority is the priority of the task to be processed, which reflects the importance and urgency of the task. The priority is usually set by the task initiator or the system based on the nature of the task (such as real-time nature, importance, etc.).
[0068] The second priority level refers to the priority level of the current task being processed by the third computing resource block in the target computing resource node. It is compared with the priority level of the pending task to determine whether to interrupt the current task to process the new higher-priority task.
[0069] The third computing resource block is the smallest non-idle computing resource block in the target computing resource node that meets the computing resource size required by the pending task. It is currently processing another task, but if the pending task has a higher priority, it will be reallocated to process the new task.
[0070] Analyze the computing resource requirements of the pending task and determine the required first computing resource size. This can be accomplished using task description files, historical data, or task estimation algorithms. Obtain the first priority of the pending task from task properties or system settings. Simultaneously, search for a third computing resource block within the target computing resource node that meets the first computing resource size and obtain the second priority of the task currently being processed there. Compare the first priority of the pending task with the second priority of the task currently being processed in the third computing resource block. This is typically accomplished by comparing priority values, with a higher value indicating a higher priority. If the priority of the pending task is higher than the priority of the current task, interrupt the current task and reassign the third computing resource block to the pending task. Before interrupting the current task, ensure that the task can be safely interrupted. This may involve checking the task's execution status, saving progress, and releasing locks to avoid data inconsistencies or task failures. Update the status of the third computing resource block to available and assign the pending task to it. This involves updating the resource management system's allocation records and task scheduling queues. Based on system policies, decide whether to suspend the current task and save its status for later resumption or terminate it directly. If it is suspended, the task state and data need to be saved to a suitable location, such as disk or a specific area in memory.
[0071] By dynamically adjusting resource allocation, it ensures that high-priority tasks can obtain the required computing resources in a timely manner, thereby improving resource utilization efficiency and overall system performance.
[0072] As a refinement of step 102, the target computing resource node is any computing resource node in the processor, and the processor includes at least two computing resource nodes; different computing resource nodes are physically isolated from each other.
[0073] The processor is the core component of a computer or computing system, responsible for executing computing tasks and processing data. In this embodiment, the processor includes multiple computing resource nodes, which can run independently and handle different tasks. In the embodiment of the present application, the processor can be a CPU or a GPU. Physical isolation means that the computing resource nodes are independent of each other at the physical hardware level, and each node has its own processor core, memory, and other hardware resources. This isolation ensures that the resources between nodes do not interfere with each other, providing good performance isolation and security.
[0074] In a processor with multiple computing resource nodes, the target computing resource node is one of the computing resource units. Each computing resource node typically includes multiple computing cores, independent cache, and memory resources, and these nodes can process different tasks in parallel. In this embodiment, the target computing resource node can be any computing resource node in the processor, as long as it can meet the computing requirements of the processing task. Physical isolation between the computing resource nodes in the processor ensures independent operation of each node. Specific implementation methods include: Independent memory and cache: Each computing resource node has an independent memory area and cache, ensuring that task execution is not interfered with by resources on other nodes. Independent execution units: The execution units (such as the arithmetic logic unit) within each computing resource node operate independently and do not share computing resources. This ensures parallel execution of tasks on each node and prevents resource conflicts during the computation process. Dedicated input and output interfaces: Each computing resource node has independent communication interfaces with external devices to avoid data transmission interference between nodes. Task scheduling and resource allocation: When a task is submitted to the processor, the system selects an appropriate computing resource node for task processing based on the task requirements and the computing capabilities of the target computing resource node. Due to the physical isolation between computing resource nodes, the system can ensure that the computing resources of a task are not affected by tasks on other nodes, avoiding competition or conflicts for computing resources. Communication between computing resource nodes: Although the computing resource nodes are physically isolated, they still require necessary data exchange and coordination. This can be achieved through cross-node communication mechanisms, such as using high-speed interconnects (network chip interconnects) to communicate between nodes and ensure data synchronization and collaboration.
[0075] By physically isolating multiple computing resource nodes within the processor, the system can process multiple tasks simultaneously, with each task executed on an independent computing resource node, avoiding resource conflicts and interference between tasks. This significantly improves the parallelism of computing resources and enhances overall computing efficiency.
[0076] In practical applications, resource allocation can also be implemented in the following ways, but is not limited to: obtaining the target weight of the task to be processed; determining the target computing resource block of the target weight based on the pre-established mapping relationship between the weight and the computing resource block; and using the target computing resource block to process the task to be processed.
[0077] The target weight is the weight of a pending task calculated based on its attributes, such as its delay threshold, reflecting its urgency and priority. The mapping between weights and computing resource blocks is a pre-established rule that maps different target weight ranges to specific computing resource blocks. This mapping can be adjusted based on the system's resource allocation strategy to meet the needs of different tasks. The target computing resource block is the computing resource block most suitable for processing a pending task, determined through this mapping based on its target weight.
[0078] Obtain the delay time threshold of the pending task from the task attributes. This threshold represents the maximum allowable delay that the task needs to complete within the specified time. The target weight is obtained by taking the inverse of the square of the delay time threshold. For example, if the delay time threshold is T, the target weight can be calculated as 1 / ( ). This formula can be adjusted according to actual needs to better reflect the urgency of the task. Define weight intervals: Divide the target weight into different intervals, such as the high weight interval (0.8-1.0), the medium weight interval (0.5-0.79), and the low weight interval (0-0.49). Allocate computing resource blocks: Allocate corresponding computing resource blocks to each weight interval. For example, the high weight interval is allocated with high-performance computing resource blocks (such as multi-core CPU and large-capacity memory), the medium weight interval is allocated with medium-performance computing resource blocks, and the low weight interval is allocated with basic performance computing resource blocks. Weight matching: Match the target weight of the task to be processed with the mapping relationship to determine its corresponding target computing resource block. Task scheduling: Assign the task to be processed to the target computing resource block, and start the task execution through the task scheduler. Task execution monitoring: During the execution of the task, monitor its resource usage and progress to ensure that the task is completed within the specified delay time.
[0079] Resource allocation is performed based on the target weight of each task, ensuring that high-priority tasks receive sufficient resources, improving overall system performance and task completion rates. For example, high-priority tasks (such as real-time video processing) can quickly obtain high-performance computing resources to ensure timely completion.
[0080] As a refinement of the above embodiment, when executing to obtain the target weight of the task to be processed, the following methods can be adopted but are not limited to: obtaining the delay time threshold of the task to be processed; squaring the delay time threshold to obtain the square result; and performing an inverse calculation on the square result to obtain the target weight.
[0081] The latency threshold is the maximum permissible delay within which a task must complete within a specified timeframe. It is an important parameter for measuring a task's time sensitivity and is typically measured in milliseconds (ms) or seconds (s).
[0082] Get the delay threshold from the task description file or properties. This value is usually set by the task initiator or the system according to the nature of the task. For example, in a real-time video processing task, the delay threshold may be set to 100 milliseconds to ensure smooth video playback. In some cases, the delay threshold may be stored in the system's configuration file or database. By reading these configurations, you can get the task's delay threshold. Square the obtained delay threshold. For example, if the delay threshold is T milliseconds, the square result is This step can be achieved through simple mathematical operations, such as using the power operator or corresponding mathematical function in the programming language. The result of the square operation is stored in the memory or cache for subsequent use. This ensures the continuity of the calculation process and the integrity of the data. The reciprocal operation of the square result is obtained to obtain the target weight. For example, the square result is , then the target weight is 1 / ( In programming languages, this step can be implemented using the reciprocal function in a math library or simple division. Verify the validity of the calculation results to ensure that the target weight is a reasonable value. If the delay threshold is zero or a negative number, special handling is required, such as setting a default value or returning an error message.
[0083] In one implementation of the disclosed embodiment, resource abstraction and virtualization: computing power segmentation: the GPU's streaming multiprocessor (SM) is divided into time slices (Time Slice), supporting millisecond-level computing power allocation (such as allocating 10ms computing time to each time slice); video memory management: using the video memory block bitmap marking method, the video memory is divided into 1MB granularity units, supporting dynamic merging and splitting, in order to facilitate a better understanding of video memory management, such as Figure 3 As shown, Figure 3This is a flow chart of video memory management provided by an embodiment of the present application. In this embodiment of the present application, video memory is a computing resource block. CUDA (Compute Unified Device Architecture) stream isolation: virtualization technology is used to create logically isolated CUDA to avoid resource contention between streams. Containerized deployment:
[0084] Use containerized development (Docker) + cluster management (Kubernetes) to encapsulate model instances, with each container bound to an independent multi-instance (MI) GPU instance or virtual memory partition; dynamically inject GPU resources through Kubernetes device plug-ins (such as allocating exclusive containers for real-time models and sharing containers for batch models).
[0085] Intelligent Scheduler: Real-time Monitoring and Decision-Making: Data Collection: Real-time collection of the following metrics: request queue depth, model service-level agreement (SLA) (e.g., P99 latency ≤ 50ms), GPU resource utilization (memory / power consumption). Dynamic Scheduling Algorithm: Priority Preemption: High-priority tasks can preempt resources from lower-priority tasks. Reinforcement Learning Optimization: Constructing a state space (resource utilization, request volume, SLA) and an action space (resource allocation strategy) to maximize long-term resource utilization through reinforcement learning algorithms. Fair Allocation: Resources are allocated based on model weights (e.g., weight = 1 / model latency requirement²).
[0086] Isolation and protection: Hardware-level isolation: The GPU is divided into multiple independent instances, each instance is allocated an independent computing unit (each instance occupies a group of SMs exclusively), independent video memory (video memory is divided into independent blocks), independent video memory bandwidth and task scheduling channels (each instance is allocated a dedicated video memory bandwidth channel), achieving physical isolation of hardware resources; a program crash in a MIG instance will not affect other instances. For example, if an instance has some errors or crashes, it will only cause the problem instance to fail, not the entire GPU. For performance isolation, the computing power, video memory, and bandwidth of each instance are strictly guaranteed. If other instances have sudden loads, they will not preempt the resources of this instance. In order to better understand the isolation of computing units, such as Figure 4 As shown, Figure 4This is a schematic diagram of the isolated computing unit structure disclosed in an embodiment of the present application. Software virtualization: Allocate an exclusive MPS server to each model to isolate the computing context; limit the SM occupancy of a single model (e.g., no more than 30% of the total SMs). Elastic scaling: Horizontal expansion: When a single GPU resource is insufficient, the model instance is migrated across nodes through the Kubernetes scheduler; Vertical expansion: Dynamically adjust the video memory and SM number of the MIG instance (e.g., from 5GB / 10SMs to 10GB / 20SMs);
[0087] Preheating mechanism: preloads the parameters of frequently used models into unified memory; memory compression: enables the Zlib compression algorithm for low-frequency models, with a compression ratio of 1.5:1 (latency increase ≤ 2ms).
[0088] Dynamic Resource Pooling: Abstracts GPU computing resources (such as computing power, video memory, and CUDA streams) into divisible units and allocates them to different model instances on demand. Intelligent Scheduler: Dynamically adjusts resource allocation strategies by monitoring request queues, model priorities, and resource occupancy in real time. Isolation and Security: Prevents performance fluctuations caused by resource preemption through hardware isolation or software virtualization. Elastic Scaling: Automatically expands and contracts model instances based on request volume, combining cold start warm-up mechanisms to reduce latency.
[0089] Implementation steps: Resource abstraction layer: Divide GPU resources (computing power, memory) into virtual units (e.g., through time slicing and memory partitioning). Use containerization technologies such as Docker and Kubernetes to encapsulate model instances and isolate resource allocation. Dynamic scheduling algorithm: Collect request volume, model SLA (e.g., maximum latency), and resource utilization in real time. Dynamically adjust resource allocation based on priority (high-priority models preempt resources) or fairness (proportional allocation). Use reinforcement learning (RL) or dynamic programming to optimize long-term resource utilization. Resource recycling mechanism: Release resources for idle model instances and return them to the resource pool for use by other models. Combined with memory compression technology to reduce fragmentation. Improved resource utilization: Dynamic allocation increases GPU utilization from 40-60% with static partitioning to over 80%. Low latency guarantee: Priority scheduling and preemption mechanisms reduce the latency of high-priority models by 30-50%. Flexible scalability: Supports mixed deployment of heterogeneous models without modifying the model structure. Anti-resource contention: Memory / computing power isolation technology prevents interference between models. Cross-node collaboration: Combined with the cluster scheduler to achieve load balancing among multi-GPU servers.
[0090] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0091] The embodiment of the present application also provides a resource allocation device, Figure 5 A schematic diagram of a resource allocation device provided in an embodiment of the present application is shown in FIG. Figure 5 Shown, including:
[0092] An acquiring unit 31 is configured to acquire a first computing resource size required for a task to be processed;
[0093] An adjusting unit 32 is configured to adjust at least one computing resource block of a target computing resource node corresponding to the task to be processed according to the first computing resource size; the target computing resource node includes at least two computing resource blocks;
[0094] The processing unit 33 is configured to process the task to be processed based on the adjusted at least one computing resource block to obtain a processing result of the task to be processed.
[0095] Through this application, by obtaining the first computing resource size required for the task to be processed, at least one computing resource block of the target computing resource node corresponding to the task to be processed is adjusted according to the first computing resource size, thereby achieving flexible allocation of computing resource blocks to match the resources required by the task. Then, based on the adjusted at least one computing resource block, the task to be processed is processed to obtain the processing result of the task to be processed, avoiding the mismatch between the fixed division of computing resource blocks and the task to be processed, and improving the utilization of computing resources. Therefore, the technical problem of low computing resource utilization can be solved, achieving the technical effect of improving the utilization of computing resources.
[0096] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the adjustment unit 32 includes:
[0097] The determination module 321 is configured to determine whether a first computing resource block exists in the target computing resource node; the first computing resource block is the minimum idle computing resource block required to meet the first computing resource size;
[0098] The determination module 321 is further configured to, when the target computing resource node has a first computing resource block, determine whether the second computing resource size of the first computing resource block is greater than the first computing resource size;
[0099] A splitting module 322 is used to split the first computing resource block into at least two second computing resource blocks when the second computing resource size of the first computing resource block is larger than the first computing resource size; the at least two second computing resource blocks include at least one target second computing resource block of a third computing resource size equal to the first computing resource size; and the adjusted at least one computing resource block includes at least two second computing resource blocks.
[0100] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the processing unit 33 is further configured to:
[0101] The target second computing resource block is used to process the task to be processed and obtain a processing result of the task to be processed.
[0102] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, after using the target second computing resource block to process the task to be processed and obtaining the processing result of the task to be processed, the device further includes:
[0103] a marking unit 34, configured to mark the target second computing resource block as an idle computing resource block;
[0104] A determining unit 35 is configured to determine whether there is an idle computing resource block adjacent to the marked target second computing resource block;
[0105] The merging unit 36 is used to merge the idle computing resource blocks adjacent to the marked target second computing resource block and the marked target second computing resource block when there are idle computing resource blocks adjacent to the marked target second computing resource block to obtain a merged idle computing resource block.
[0106] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, after determining whether the first computing resource block exists in the target computing resource node, the apparatus further includes:
[0107] The acquisition unit 31 is further configured to, when the first computing resource block does not exist in the target computing resource node, acquire the first priority of the task to be processed, and acquire the second priority of the task processed by the third computing resource block in the target computing resource node; the third computing resource block is the smallest non-idle computing resource block required to meet the first computing resource size;
[0108] The processing unit 33 is further configured to, when the first priority is greater than the second priority, stop the third computing resource block from processing the processing task, and use the third computing resource block to process the pending task.
[0109] Furthermore, in a possible implementation of this embodiment, the target computing resource node is any computing resource node in a processor, and the processor includes at least two computing resource nodes; different computing resource nodes are physically isolated from each other.
[0110] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the device also includes:
[0111] The acquisition unit 31 is further used to obtain the target weight of the task to be processed;
[0112] The determining unit 35 is further configured to determine a target computing resource block of a target weight according to a pre-established mapping relationship between weights and computing resource blocks;
[0113] The processing unit 33 is further configured to process the task to be processed using the target computing resource block.
[0114] Furthermore, in a possible implementation of this embodiment, as Figure 6 As shown, the acquisition unit 31 is further used for:
[0115] Get the delay time threshold of the pending task;
[0116] Square the delay time threshold to obtain the square result;
[0117] The target weight is obtained by performing the inverse calculation on the squared result.
[0118] For the description of the features in the embodiment corresponding to the resource allocation apparatus, reference can be made to the relevant description of the embodiment corresponding to the resource allocation method, which will not be repeated here.
[0119] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above-mentioned resource allocation method embodiments.
[0120] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned resource allocation method embodiments when running.
[0121] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0122] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned resource allocation method embodiments are implemented.
[0123] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned resource allocation method embodiments are implemented.
[0124] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0125] The above is a detailed introduction to a resource allocation method, device, and electronic device provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for resource allocation, characterized in that: include: Obtaining a first computing resource size required for the task to be processed; Adjusting at least one computing resource block of the target computing resource node corresponding to the task to be processed according to the first computing resource size; The target computing resource node includes at least two computing resource blocks; Processing the task to be processed based on the adjusted at least one computing resource block to obtain a processing result of the task to be processed; The adjusting, according to the first computing resource size, at least one computing resource block of the target computing resource node corresponding to the task to be processed includes: Determining whether a first computing resource block exists in the target computing resource node; the first computing resource block is a minimum idle computing resource block required to meet the first computing resource size; If the first computing resource block exists in the target computing resource node, determining whether the second computing resource size of the first computing resource block is greater than the first computing resource size; If the second computing resource size of the first computing resource block is larger than the first computing resource size, dividing the first computing resource block into at least two second computing resource blocks; the at least two second computing resource blocks include at least one target second computing resource block having a third computing resource size equal to the first computing resource size; The adjusted at least one computing resource block includes at least two second computing resource blocks.
2. The resource allocation method according to claim 1, characterized in that: The processing of the to-be-processed task based on the adjusted at least one computing resource block to obtain a processing result of the to-be-processed task includes: The target second computing resource block is used to process the task to be processed to obtain a processing result of the task to be processed.
3. The resource allocation method according to claim 2, characterized in that: After processing the task to be processed using the target second computing resource block to obtain a processing result of the task to be processed, the method further includes: Marking the target second computing resource block as an idle computing resource block; Determining whether there is an idle computing resource block adjacent to the marked target second computing resource block; If there is an idle computing resource block adjacent to the marked target second computing resource block, the idle computing resource block adjacent to the marked target second computing resource block and the marked target second computing resource block are merged to obtain a merged idle computing resource block.
4. The resource allocation method according to claim 1, characterized in that: After determining whether the first computing resource block exists in the target computing resource node, the method further includes: If the first computing resource block does not exist in the target computing resource node, obtaining the first priority of the task to be processed, and obtaining the second priority of the processing task processed by the third computing resource block in the target computing resource node; the third computing resource block is the smallest non-idle computing resource block required to meet the first computing resource size; If the first priority is greater than the second priority, the third computing resource block is stopped from processing the processing task, and the third computing resource block is used to process the pending task.
5. The resource allocation method according to claim 1, characterized in that: The target computing resource node is any computing resource node in a processor, and the processor includes at least two computing resource nodes; different computing resource nodes are physically isolated from each other.
6. The resource allocation method according to claim 1, characterized in that: The method comprises: Obtaining the target weight of the task to be processed; Determining a target computing resource block of the target weight according to a pre-established mapping relationship between the weight and the computing resource block; The target computing resource block is used to process the task to be processed.
7. The resource allocation method according to claim 6, characterized in that: The obtaining of the target weight of the task to be processed comprises: Obtaining a delay time threshold for the task to be processed; Performing square calculation on the delay time threshold to obtain a square result; The reciprocal calculation is performed on the square result to obtain the target weight.
8. A resource allocation device, characterized in that: include: An acquiring unit, configured to acquire a first computing resource size required for the task to be processed; an adjusting unit, configured to adjust at least one computing resource block of a target computing resource node corresponding to the task to be processed according to the size of the first computing resource; The target computing resource node includes at least two computing resource blocks; a processing unit, configured to process the task to be processed based on the adjusted at least one computing resource block, and obtain a processing result of the task to be processed; Wherein, the adjustment unit is further used to: Determining whether a first computing resource block exists in the target computing resource node; the first computing resource block is a minimum idle computing resource block required to meet the first computing resource size; When the first computing resource block exists in the target computing resource node, determining whether the second computing resource size of the first computing resource block is greater than the first computing resource size; When the second computing resource size of the first computing resource block is larger than the first computing resource size, dividing the first computing resource block into at least two second computing resource blocks; the at least two second computing resource blocks include at least one target second computing resource block having a third computing resource size equal to the first computing resource size; The adjusted at least one computing resource block includes at least two second computing resource blocks.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the resource allocation method according to any one of claims 1 to 7 when executing the computer program.
Citation Information
Patent Citations
Resource allocation method and device, task submission method and device, electronic equipment and medium
CN111694672A
Computing power directional scheduling method and device of intelligent computing center
CN119088569A