Task processing method and device
By binding worker threads to specific CPU cores in the database and using a blocking task detection unit to handle task blocking, the problem of multi-core switching overhead is solved, and task processing efficiency and continuity are improved.
Patent Information
- Application Number
- CN202510799008.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-10-28
AI Technical Summary
In existing technologies, database query performance is affected by the context switching overhead between multiple CPU cores, resulting in low task processing efficiency.
By binding worker threads to specific CPU cores and submitting them to the blocked task cache queue when a task is blocked, the blocked task detection unit can return the task to its original worker thread to continue execution after the task is unblocked, thus reducing CPU core switching.
It reduces the overhead of context switching between multiple CPU cores, improving the efficiency and continuity of task processing.
Smart Images

Figure CN120849033A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and in particular to a task processing method and apparatus. Background Technology
[0002] To improve the query performance of database systems, the execution engine is typically designed as a data-driven execution engine (Push-Based Pipeline). The efficiency of Push-Based Pipeline scheduling directly impacts database query performance. In related technologies, each worker thread in a worker thread pool can flexibly run on various central processing unit (CPU) cores, retrieving tasks from the ready queue and executing them. If a task being executed is blocked, the worker thread submits the blocked task to the blocking queue. A polling thread, upon determining that a task in the blocking queue is unblocked, puts it back into the ready queue, waiting for a worker thread in the pool to continue execution. Thus, a task may execute on multiple worker threads. Since each thread may run on multiple CPU cores, if multiple CPU cores share the same task, the overhead of context switching between CPU cores impacts task processing efficiency. Summary of the Invention
[0003] This application provides a task processing method and apparatus. Since a worker thread is bound to a CPU core, a pipeline task will only be processed on a worker thread even if it is blocked. Therefore, the context overhead between multiple CPU cores can be reduced and the task processing efficiency can be improved.
[0004] Firstly, a task processing method is provided, which can be applied to a task processing device, a worker thread pool, and a blocked task detection unit. The worker thread pool includes multiple worker threads, each of which is bound to a different central processing unit core on the data node. The method includes:
[0005] When the first worker thread among the plurality of worker threads is blocked while executing a pipeline task, it submits the pipeline task to a blocked task cache queue; when the blocked task detection unit detects that the pipeline task in the blocked task cache queue is unblocked, it submits the pipeline task to the first worker thread; the first worker thread continues to execute the pipeline task.
[0006] Based on the above technical solution, when a pipeline task is blocked, the first worker thread submits the pipeline task to the blocked task cache queue. The blocked task detection unit waits for the pipeline task to be unblocked and then submits the pipeline task back to the first worker thread. In other words, the pipeline task executed by the first worker thread will always be processed by the first worker thread. Since each worker thread is bound to a fixed CPU core, the pipeline task does not involve the context overhead of switching CPU cores during processing, which can improve the processing efficiency of the pipeline task.
[0007] Optionally, the blocking task cache queue is implemented as a background cache queue, which is used to cache tasks to be executed by the background thread pool, and the blocking task detection unit is implemented as a background thread pool. In this way, after a pipeline task is unblocked, the background thread pool can directly submit it to the first worker thread without polling to determine whether the pipeline task is unblocked. Thus, the first worker thread can promptly retrieve the unblocked pipeline task and continue execution.
[0008] In conjunction with the first aspect, in some implementations of the first aspect, multiple worker threads in the worker thread pool are configured with different work queues, the worker thread pool includes a first worker thread, and the method further includes: the first worker thread obtaining pipeline tasks from the corresponding work queue and executing the pipeline tasks.
[0009] Based on the above technical solution, the first worker thread obtains pipeline tasks from the corresponding work queue. The blocked task detection unit can submit the unblocked pipeline tasks to the work queue corresponding to the first worker thread to continue execution, thus simplifying the way to submit tasks to the first worker thread.
[0010] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes:
[0011] The first worker thread acquires the workload of each worker thread in the worker thread pool. If the first worker thread meets the migration conditions based on its workload, the target pipeline task in the work queue corresponding to the first worker thread is migrated to the work queue corresponding to the second worker thread in the worker thread pool. The workload is characterized by the number of pipeline tasks in the work queue corresponding to the worker thread and / or the predicted execution time.
[0012] Based on the above technical solution, tasks can be migrated among worker threads in the worker thread pool to adjust the task load of each worker thread, thereby improving load balancing among worker threads.
[0013] In conjunction with the first aspect, in some implementations of the first aspect, the migration condition includes that the workload in the work queue corresponding to the first worker thread is greater than the load balancing load. The method also includes:
[0014] The first worker thread determines the load balancer based on the workload of each worker thread.
[0015] Based on the above technical solution, the first worker thread determines the load balancing based on the workload of each worker thread. When the workload of the first worker thread is greater than the load balancing, the tasks in the corresponding work queue are migrated to the second worker thread, thereby achieving load balancing between the first worker thread and the second worker thread.
[0016] Optionally, the second worker thread is the worker thread whose workload is less than the balanced load among multiple worker threads.
[0017] Optionally, the second worker thread is the worker thread with the smallest workload among the multiple worker threads.
[0018] In conjunction with the first aspect, in some implementations of the first aspect, the task processing apparatus further includes a foreground thread, and the method further includes:
[0019] The foreground thread generates pipeline tasks and assigns these tasks to the work queue corresponding to the first worker thread.
[0020] Based on the above technical solution, the foreground thread distributes the generated pipeline tasks to multiple work queues in the worker thread pool, so that each work queue has pipeline tasks to be executed, thereby improving the efficiency of each worker thread in executing pipeline tasks.
[0021] Optionally, multiple work queues can be priority-based queues, with foreground threads assigning pipeline tasks to priority-matching work queues based on their priorities. This allows for full utilization of the resources of each worker thread, improving the processing efficiency of the pipeline tasks.
[0022] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes:
[0023] If a pipeline task is blocked, the first worker thread records the execution progress information of the pipeline task; and continues to execute the pipeline task based on the execution progress information.
[0024] Based on the above technical solution, the worker thread pool records the execution progress information of pipeline tasks, which facilitates the continued execution of pipeline tasks according to the execution progress information, thereby improving the continuity and accuracy of task execution.
[0025] Secondly, a task processing device is provided, which is applied to a data node in a database.
[0026] The task processing unit includes a worker thread pool and a blocked task detection unit. The worker thread pool includes multiple worker threads, each bound to a different CPU core on a data node.
[0027] The first worker thread among multiple worker threads is used to submit the pipeline task to the blocked task cache queue when the pipeline task being executed is blocked.
[0028] The blocked task detection unit is used to submit the pipeline task to the first worker thread when the pipeline task is unblocked.
[0029] The first worker thread is also used to continue executing pipeline tasks.
[0030] In conjunction with the second aspect, in some implementations of the second aspect, multiple worker threads in the worker thread pool are configured with different work queues, and the first worker thread is also used to obtain pipeline tasks from the corresponding work queue.
[0031] In conjunction with the second aspect, in some implementations of the second aspect, the first worker thread is also used to obtain the workload of each worker thread in the worker thread pool; when the workload of each worker thread meets the migration conditions, the target pipeline task in the work queue corresponding to the first worker thread is migrated to the second worker thread among the multiple worker threads.
[0032] In conjunction with the second aspect, in some implementations of the second aspect, the migration condition includes that the workload in the work queue corresponding to the first worker thread is greater than the load balancing load, and the first worker thread is also used to determine the load balancing load based on the workload of each worker thread.
[0033] In conjunction with the second aspect, in some implementations of the second aspect, the task processing device further includes a foreground thread, which is used to generate pipeline tasks and allocate pipeline tasks to the work queue corresponding to the first worker thread.
[0034] In conjunction with the second aspect, in some implementations of the second aspect, the first worker thread is also used to record the execution progress information of the pipeline task when the pipeline task is blocked; and to continue executing the pipeline task based on the execution progress information.
[0035] Thirdly, a computing device is provided, including a processor and a memory, the processor being configured to execute instructions stored in the memory such that the method described in the first aspect is implemented.
[0036] Fourthly, a computing device cluster is provided, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device to enable the method in the first aspect described above to be implemented.
[0037] Fifthly, a computer program product is provided that, when instructions are run by a cluster of computing devices, enables the method described in the first aspect to be implemented.
[0038] In a sixth aspect, a computer-readable storage medium is provided, including computer program instructions that, when executed by a cluster of computing devices, cause the method of the first aspect to be implemented.
[0039] The solutions provided in the second and sixth aspects above are used to implement or cooperate with the methods provided in the first aspect above, and therefore can achieve the same or corresponding beneficial effects as the first aspect, which will not be elaborated here. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the structure of a database provided in an embodiment of this application;
[0041] Figure 2 This is a schematic diagram of a task processing process in a related technology provided in an embodiment of this application;
[0042] Figure 3 This is a schematic diagram of an implementation scenario provided in an embodiment of this application;
[0043] Figure 4 This is a schematic diagram of a task processing procedure provided in an embodiment of this application;
[0044] Figure 5 This is a schematic diagram illustrating the state change process of a pipeline task provided in an embodiment of this application;
[0045] Figure 6 This is a schematic diagram of another task processing procedure provided in an embodiment of this application;
[0046] Figure 7 This is a schematic diagram illustrating a load balancing process between worker threads provided in an embodiment of this application;
[0047] Figure 8 This is a schematic diagram of another task processing procedure provided in an embodiment of this application;
[0048] Figure 9 This is a schematic diagram of the structure of a task processing device provided in an embodiment of this application;
[0049] Figure 10This is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0050] Figure 11 This is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;
[0051] Figure 12 This is a schematic diagram of another computing device cluster structure provided in an embodiment of this application. Detailed Implementation
[0052] 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 this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] The terms "first," "second," and similar terms used in this article do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, "one" or similar terms do not indicate a quantity limitation, but rather indicate the existence of at least one.
[0054] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0055] To facilitate understanding of the technical solution of this application, the background of the embodiments of this application will be further explained below.
[0056] The database includes at least one coordinating node and at least one data node. The coordinating node receives access requests (such as query requests) from clients, generates tasks to be processed based on these requests, schedules these tasks to at least one data node for execution, receives the execution results from the data nodes, determines the query results based on the execution results from at least one data node, and feeds the query results back to the client. The data node and coordinating node can be single physical nodes or virtual nodes. A virtual node can be a logical node composed of multiple physical machines or a virtual instance partitioned on a single physical machine. The resources that the coordinating node and data node can provide can include computing resources and storage resources. The storage resources of the data node include local storage resources and remote storage resources, such as external object storage services (OBS).
[0057] Figure 1 A database is illustrated, comprising a coordinating node 101 and three data nodes (102-1, 102-2, and 102-3). The coordinating node 101 receives a query request Q from a client, generates query tasks TK1-3, and schedules the three data nodes to process them. Each data node includes multiple central processing unit (CPU) cores, with one CPU core running one thread. Each data node processes a query task concurrently through multiple worker threads, and a query task comprises multiple pipelined tasks.
[0058] For example, the query task is to retrieve the 100 largest data values from 1000 data values (including data 1-1000) in the first storage location of the database. Data nodes 102-1, 102-2, and 102-30 need to retrieve the 100 largest data values from data 1-400, 401-700, and 701-1000 respectively as query results (TR1, TR2, and TR3 respectively) and then feed them back to the coordinating node 101. The coordinating node 101 then retrieves the 100 largest data values from the obtained 300 data values as the final result R.
[0059] Figure 2 The task processing procedure in related technologies is illustrated. For example... Figure 2As shown, the data node operates with foreground threads, a worker thread pool, a polling thread, and a background thread pool. After receiving a task assigned by the coordinating node, the foreground thread divides the task into multiple pipeline tasks and caches them in a ready queue. The three worker threads in the worker thread pool retrieve pipeline tasks from the ready queue and execute them. The process of a worker thread executing a pipeline task includes: the source operator pushes data to the next operator, the next operator pushes it to the operator after that, and so on, completing the pipeline task. Taking worker thread 1 as an example, if a pipeline task is blocked at a certain operator while worker thread 1 is executing a pipeline task, the blocked pipeline task is submitted to the blocking queue. If the pipeline task in the blocking queue is unblocked, the polling thread puts the pipeline task back into the ready queue, waiting for a worker thread in the worker thread pool to retrieve it and continue execution. When the pipeline task includes background tasks, the worker thread needs to submit the background tasks within the pipeline task to the background thread pool for execution. When a pipeline task is blocked, background tasks that have been submitted to the background thread pool will continue to be executed by the background thread pool.
[0060] Because each worker thread in the worker thread pool can switch between CPU cores in the data node when switching between executing pipelined tasks, and a pipelined task is submitted to a worker thread after being blocked, different CPU cores may be needed to run the pipelined task together. For example, worker thread 1 is executing pipelined task 1 on CPU core 1. When pipelined task 1 is blocked, it is submitted to the blocked task cache queue. At this time, worker thread 1 switches to pipelined task 2 and runs on CPU core 2. After pipelined task 1 is submitted to the ready queue, worker thread 2 retrieves pipelined task 1 from the ready queue and executes it, while worker thread 2 runs on CPU core 3. Thus, pipelined task 1 needs to be executed by both CPU core 1 and CPU core 3. Some data cached by CPU core 1 when executing pipelined task 1 needs to be re-cached when CPU core 3 executes pipelined task 1, causing context switching overhead. This affects the execution efficiency of pipelined task 1 on CPU core 3, thereby affecting the overall execution efficiency of pipelined task 1.
[0061] To address the aforementioned technical issues, this application provides a task processing method and apparatus. The task processing apparatus is a database execution engine configured on data nodes within the database. Since each CPU core in the data node is bound to a different worker thread in the task processing apparatus's worker thread pool, and after any worker thread submits a blocked pipeline task to the blocked task cache queue, the blocked task detection unit can, upon detecting that the pipeline task has been unblocked, submit it back to the worker thread that originally executed the pipeline task. This is equivalent to one pipeline task being executed on one CPU core; thus, the overhead of switching CPU cores during pipeline task execution can be reduced, thereby improving the execution efficiency of the pipeline task.
[0062] Figure 3 An implementation scenario involving a task processing method is illustrated. For example... Figure 3 As shown, the implementation scenario includes: data center 1 and client 2. The database is deployed on data center 1, and data center 1 and client 2 can establish a communication connection via a network. Optionally, this network can be the Internet or other networks; this embodiment does not limit the specific network used. Tenants can interact with data center 1 through client 2. For example, a tenant can send cloud service requests, including query requests, to data center 1 through client 2. Data center 1 responds based on the information sent by client 2.
[0063] Data Center 1 houses a large amount of infrastructure owned by the cloud service provider, such as computing resources, storage resources, and network resources. For example, computing resources can be computing devices (such as servers) capable of providing computing power. Figure 2 As shown, data center 1 includes a cloud management platform and infrastructure ( Figure 2 (Not shown in the image). The cloud management platform and infrastructure are connected via an internal data center network. The cloud management platform is used to manage the infrastructure. The infrastructure is used to provide public cloud services.
[0064] Tenants can send instructions to the cloud management platform through their client 2 to create, manage, log in to, and operate virtual instances on the server, and use the cloud services provided by these virtual instances. For example, the cloud management platform can provide an access interface. This interface can be provided either as a user interface or an API. Tenants can operate their client to remotely access the access interface to register a cloud account and password on the cloud management platform, and then log in using these accounts and passwords. The cloud management platform can also authenticate the cloud account and password. After successful authentication, the tenant can further select and purchase a virtual instance with specific specifications (processor, memory, disk) on the cloud management platform. After the tenant successfully purchases the virtual instance, the cloud management platform provides the tenant with a remote login account and password for the purchased virtual instance. The tenant can use the remote login account and password to remotely log in to the virtual instance on their client, install and run their application within the virtual instance, and use the application to implement their business operations.
[0065] Client 2 can be selected from computers, personal computers, laptops, mobile phones, smartphones, tablets, cloud servers, portable mobile terminals, multimedia players, e-book readers, wearable devices, smart home appliances, artificial intelligence devices, smart wearable devices, smart in-vehicle devices, or Internet of Things devices, etc.
[0066] In one implementation, the task processing method provided in this application embodiment can be implemented by running an executable program on a computing device in data center 1. Optionally, the task processing method provided in this application embodiment can be applied to a task processing device. This task processing device can implement the task processing method provided in this application embodiment by running the executable program of the task processing method provided in this application embodiment. Furthermore, the executable program implementing the task processing method can optionally be presented in the form of an application installation package. After the data node installs the application installation package, it can implement the task processing method provided in this application embodiment by running the executable program therein.
[0067] It should be understood that the above content is an exemplary description of the implementation scenarios of the task processing method provided in the embodiments of this application, and does not constitute a limitation on the implementation scenarios of the task processing method. As those skilled in the art know, as business needs change, the implementation scenarios can be adjusted according to application requirements, and the embodiments of this application do not specifically limit them.
[0068] Figure 4 This application provides a task processing method applied to a task processing device. The task processing device includes a worker thread pool and a blocked task detection unit. The multiple worker threads are respectively bound to different central processing unit cores on the data node, such as... Figure 4 As shown, the method includes: S110-S130.
[0069] S110: If the first worker thread among multiple worker threads is blocked while executing a pipeline task, it submits the pipeline task to the blocked task cache queue.
[0070] In this embodiment, the data node is configured with a task processing device, which includes a worker thread pool. The worker thread pool can create multiple worker threads, each bound to a different CPU core. Each worker thread runs on a specific CPU core, and multiple worker threads concurrently process pipeline tasks. When a pipeline task is executed by a worker thread, blocking may occur due to at least one of the following reasons: 1. Software resource conflicts, such as lock contention; 2. Data anomalies, such as invalid data that cannot be processed; 3. Other unmet dependencies, such as the current pipeline task depending on the output of a preceding pipeline task, or the first task in the pipeline depending on the output of a second task. The second task typically includes I / O-intensive tasks that need to be submitted to a background thread pool for execution. The task processing device includes a background thread pool. The worker thread needs to execute the first task based on the result of the background thread pool's execution, such as read data. For example, the first task is initiated by a sorting operator, and the second task includes reading data. When the worker thread executes the first task, the background thread needs to execute the data read by the second task and sort the read data.
[0071] In this context, the first worker thread is any one of the multiple worker threads in the worker thread pool. If the pipeline task being executed by the first worker thread becomes blocked, the pipeline task is submitted to the blocked task cache queue. This releases the first worker thread, allowing it to continue executing other pipeline tasks and reducing the probability of its resources being idle. The blocked task detection unit detects whether the blocking status of pipeline tasks in the blocked cache queue has been cleared. If the blocking status is cleared, the pipeline task is submitted back to the first worker thread.
[0072] It should be noted that if the blocked pipeline task includes a first task and a second task, after the blocked pipeline task is submitted to the blocked task cache queue, the background thread pool will continue to process the subtasks of the already submitted second task.
[0073] For example, when worker thread 1 executes pipeline task 1, it submits subtasks 1-8 of the second task to the background thread pool and then gets blocked. After worker thread 1 submits pipeline task 1 to the blocked task cache queue, the background thread pool is not affected by pipeline task 1 being submitted from worker thread 1 to the blocked task cache queue, and will continue to execute subtasks 1-8 of the second task.
[0074] In one possible implementation, the blocking buffer queue includes one, and the blocked pipeline task includes an identifier of a first worker thread, so that the blocking detection unit can determine the first worker thread based on the identifier of the worker thread.
[0075] For example, worker thread 1 submits pipeline task 1, identified as worker thread 1, to the blocking task cache queue, and worker thread 2 submits pipeline task 2, identified as worker thread 2, to the blocking task cache queue. The blocking detection unit can determine that the first worker thread of pipeline task 1 is worker thread 1 based on the identifier of worker thread 1 on pipeline task 1; and determine that the first worker thread of pipeline task 2 is worker thread 2 based on the identifier of worker thread 2 on pipeline task 2.
[0076] In one possible implementation, the blocking task cache queue includes multiple queues, with different worker threads corresponding to different blocking task cache queues. The first worker thread submits the blocked pipeline task to the corresponding blocking task cache queue, and the background thread pool can determine the first worker thread based on the blocking task cache queue where the pipeline task is located.
[0077] In one possible implementation, the blocking task cache queue is implemented as a background cache queue, which is used to cache tasks to be executed by the background thread pool.
[0078] For example, worker thread 1 corresponds to background cache queues 1-2, and worker thread 2 corresponds to background cache queue 3. When pipeline task 1 is blocked, worker thread 1 submits pipeline task 1 to background cache queue 1; when pipeline task 2 is blocked, worker thread 2 submits pipeline task 2 to background cache queue 3. When the background thread pool detects that pipeline task 1 in background cache queue 1 has been unblocked, it determines that the first worker thread of pipeline task 1 is worker thread 1.
[0079] In one possible implementation, the pipelined task executed by the first worker thread includes a blocking operator. The first worker thread determines that the pipelined task is blocked when the task queue corresponding to the blocking operator meets the blocking condition. The task queue corresponding to the blocking operator includes at least one of the following: a receive queue, a send queue, and a buffer queue. The receive queue is used by the first worker thread to retrieve data, the send queue is used by the first worker thread to send processed data, and the buffer queue includes a write buffer queue or a read buffer queue. The write buffer queue is used to buffer data that the first worker thread needs to write, and the read buffer queue is used to buffer data that the first worker thread needs to read. Different blocking operators require different blocking conditions from their corresponding task queues, which can be set as needed; this embodiment does not impose any limitations.
[0080] In one possible implementation, the task queue corresponding to the blocking operator includes a receive queue, and the blocking condition includes the number of tasks in the receive queue being less than or equal to a receive threshold. The task queue corresponding to the blocking operator also includes a send queue, and the blocking condition includes the number of tasks in the send queue being greater than or equal to a send threshold. Furthermore, the task queue corresponding to the blocking operator includes a read cache queue, and the blocking condition includes the remaining cache space in the read cache queue being less than or equal to a first cache threshold. Finally, the task queue corresponding to the blocking operator includes a write cache queue, and the blocking condition includes the occupied cache space in the write cache queue being greater than or equal to a second cache threshold. The receive threshold, send threshold, first cache threshold, and second cache threshold can be set according to actual needs, and this embodiment does not impose any limitations.
[0081] For example, if the blocking operator is the `exchange / stream` operator, the corresponding task queue includes a receive queue and a send queue. If the receive threshold is 0 and the send threshold is the total number of tasks the send queue can hold, then the pipeline task will be blocked when the receive queue is empty or the send queue is full. Another example is the materialization operator. When the first worker thread writes data using `spill`, it generates a background task with the data and write buffer, which is then executed by the background thread. The write buffer is equivalent to the send queue. If the write buffer is full, the background task cannot be submitted, and the first worker thread determines that the pipeline task is blocked. Yet another example is the `scan` operator. When reading data, the `scan` operator performs vector batch processing on the read data, organizing the data into `vectorbatch` blocks and caching them in a buffer queue. If the first worker thread does not retrieve a `vectorbatch` from the buffer queue, it determines that the pipeline task is blocked.
[0082] S120, when the blocking task detection unit detects that the pipeline task in the blocking task cache queue has been unblocked, it submits the pipeline task to the first worker thread.
[0083] In this embodiment, the blocking status of pipelined tasks submitted to the blocking task cache queue is detected by the blocking task detection unit. After the pipelined task is unblocked, the blocking task detection unit submits the pipelined task back to the first worker thread. All worker threads in the worker thread pool need to retrieve pipelined tasks from the work queue and execute them. The work queue is used to cache pipelined tasks to be executed from multiple worker threads in the worker thread pool.
[0084] In one possible implementation, the work queue includes one queue from which each worker thread retrieves pipeline tasks to be executed and performs them. The pipeline tasks executed by the first worker thread bear the identifier of the first worker thread. The first worker thread submits blocked pipeline tasks to a blocked task cache queue, and then the blocked task detection unit submits them back to the work queue. After that, the first worker thread can retrieve previously blocked pipeline tasks from the work queue again and continue execution.
[0085] For example, the blocking task detection unit is implemented as a polling thread, and the blocking cache queue is implemented as a blocking queue. The first worker thread submits the blocked pipeline task with the first worker thread identifier to the blocking queue. After the polling thread detects that the pipeline task in the blocking queue has been unblocked, it submits the pipeline task back to the first worker thread.
[0086] In one possible implementation, the task configuration device further includes a foreground thread that generates pipeline tasks and pushes each pipeline task into a work queue. When a first worker thread obtains a pipeline task and executes it, it adds an identifier for the first worker thread.
[0087] Optionally, there are multiple work queues, with different work queues corresponding to different work threads. After a pipeline task is unblocked, the blocking task detection unit needs to submit it to the work queue corresponding to the first work thread. In this way, the first work queue can retrieve the pipeline task again and execute it.
[0088] For example, the blocking task detection unit is implemented as a background thread pool, and the blocking cache queue is implemented as a background cache queue. Different work queues correspond to different background cache queues. The first worker thread submits the blocked pipeline task to the corresponding first background cache queue. After the background thread pool detects that the blocked pipeline task in the first background cache queue has been unblocked, it submits the pipeline task to the work queue corresponding to the first worker thread.
[0089] In one possible implementation, the task configuration device further includes a foreground thread that generates pipeline tasks and assigns each pipeline task to a work queue corresponding to a specified worker thread.
[0090] In one possible implementation, the multiple work queues corresponding to multiple worker threads are priority-based multilevel feedback queues (MLFQ). The foreground thread allocates the pipeline tasks to be executed to each work queue according to their priority; for example, high-priority queues are allocated to pipeline tasks with shorter time slices, and low-priority queues are allocated to pipeline tasks with longer time slices.
[0091] For example, priority level 1 is high priority, and priority level 2 is low priority. Pipeline tasks with priority level 1 are assigned to the work queues of worker thread 1 and worker thread 2, while pipeline tasks with priority level 2 are cached in the work queue of worker thread 3. In other words, worker thread 1 and worker thread 2 are used to execute high-priority pipeline tasks, and worker thread 3 is used to execute low-priority pipeline tasks.
[0092] In one possible implementation, the worker thread pool can also adjust the priority of pipelined tasks based on their execution status. For example, if a pipelined task's execution duration exceeds the current time slice, it is downgraded to a low priority. Conversely, if the pipelined tasks include I / O-intensive tasks (requiring frequent waiting for I / O to release CPU resources), they are upgraded to a high priority.
[0093] In one possible implementation, the first worker thread can add its own identifier to the pipeline tasks that have been acquired and executed. In another possible implementation, the first worker thread can add its own identifier to the pipeline tasks in the corresponding work queue; after a pipeline task is moved to the work queue of the second worker thread, the second worker thread modifies the identifier of the first worker thread to its own identifier.
[0094] In this embodiment, the background thread pool includes multiple background threads that concurrently process the second task submitted by the worker thread pool. The background thread pool can adjust the number of background threads based on their working status, specifically by increasing or decreasing the number of background threads. In one possible implementation, if the number of background threads is less than or equal to a preset total number of background threads, and these threads cannot meet the needs of the background task, the background thread pool can create a new background thread. The preset total number of background threads is the maximum number of background threads the pool can create. For example, if the preset total number of background threads is 10, and the first number is 8, it means the background thread pool has already created 8 background threads to execute background tasks. If all 8 background threads are assigned to execute background tasks and a new background task is received, the background thread pool creates a new background thread to handle the new task, and the first number is adjusted to 9. In one possible implementation, if an idle thread appears among the background threads, the background thread pool closes the idle thread.
[0095] In one possible implementation, the first worker thread submits the blocked pipeline task to the blocked task cache queue while informing the blocked task detection unit of the reason for the pipeline task's blockage. The blocked task detection unit determines that the pipeline task is unblocked once the reason for the pipeline task's blockage disappears. For example, if the pipeline task is blocked because other dependent conditions are not met, the blocked task detection unit checks whether the other dependent conditions have been met; if so, it determines that the pipeline task is unblocked once the other dependent conditions are met.
[0096] For example, the blocking task detection unit is a background thread pool. Other dependent conditions are not met, including the remaining capacity of the cache queue for subtasks of the second task submitted by the first worker thread to the background thread pool being less than or equal to the first capacity. This causes the first worker thread to be unable to continue submitting other subtasks of the second task, pausing the first task in the pipeline and causing the pipeline task to block. Since the background thread pool continues to execute the second task in the cache queue after the pipeline task is submitted, the remaining capacity in the cache queue increases as the second task is processed until it exceeds the second capacity. At this point, the background thread pool determines that the blocking cause has disappeared, and the pipeline is unblocked. The second capacity is greater than or equal to the first capacity; however, this application embodiment does not limit the scope of the first and second capacities. In one possible implementation, the second capacity is the total capacity of the cache queue.
[0097] S130, the first worker thread continues to execute the pipeline task.
[0098] In this embodiment of the application, after the first worker thread retrieves the unblocked pipeline task from the work queue again, it will continue to execute the pipeline task.
[0099] In one possible implementation, when a pipeline task is blocked, the first worker thread also needs to record the execution progress information of the pipeline task. The execution progress information includes the state of the pipeline task when it is blocked; for example, it may include the data processing status, task identifier, and context of the pipeline task. In one possible implementation, the execution progress information is implemented through an execution progress table, whose fields include: task identifier, current execution step, context, blocking reason, and blocking time. This can be set according to actual needs, and this application does not impose any restrictions. After the first worker thread retrieves the unblocked pipeline task from the work queue, it continues to execute the pipeline task according to the execution progress information.
[0100] In one possible implementation, the states of a pipelined task include a working state, a ready state, and a blocked state. For example... Figure 5As shown, pipeline tasks in the work queue are in a ready state, meaning they await execution by worker threads. When the first worker thread retrieves a pipeline task from the work queue and executes it, the pipeline task's state switches from ready to working. If the pipeline task is blocked, the first worker thread sets it to a blocked state and submits the blocked pipeline task to the blocked task cache queue. When the pipeline task is unblocked, the blocked task detection unit sets the pipeline task back to the ready state and submits it to the work queue, awaiting execution by worker threads.
[0101] In one possible implementation, the worker thread pool includes multiple work queues. After the foreground thread assigns the pipeline tasks to be executed to the multiple work queues, the remaining pipeline tasks to be executed in each work queue will differ due to the differences between the different pipeline tasks and the different task execution capabilities of each worker thread. Figure 6 This demonstrates a task processing method that can improve load balancing across multiple worker threads. For example... Figure 6 As shown, the method includes: S210-S220.
[0102] S210, the first worker thread obtains the workload of each worker thread in the worker thread pool.
[0103] In this embodiment, each worker thread in the worker thread pool can determine its own workload. After obtaining the workloads of other worker threads, the first worker thread obtains the workload of each worker thread in the worker thread pool. The worker threads in the worker thread pool can communicate with each other, sending task load information to other worker threads so that they can know each other's workloads. Communication between worker threads can be based on mailboxes, for example, mailbox communication of a single producer single consumer queue (SPSC) matrix or a multiple producer single consumer queue (SPSC) matrix.
[0104] In this embodiment, each worker thread can periodically send task load information to other worker threads. For example, it can send task load information to the mailboxes of other worker threads at a first preset time interval. Each worker thread periodically retrieves task load information from the mailboxes of other worker threads to determine the workload of other worker threads. For example, it can retrieve task load information from the mailboxes at a second preset time interval. The first and second preset time intervals can be set according to actual needs, and this embodiment does not impose any limitations. In one possible implementation, the second preset time interval is greater than or equal to the first preset time interval to reduce communication resource consumption caused by the same task load being retrieved twice consecutively. It should be noted that when the number of task load information messages in the mailbox is greater than 1, it indicates that each worker thread has sent task load information to other worker threads more than once. In this case, the worker thread retrieves the latest task load information and then retrieves the workload of other worker threads from the latest task load information.
[0105] The workload can be characterized by the number of pipeline tasks in the work queue corresponding to the worker thread and / or the predicted execution time, where the predicted execution time is the predicted time required to execute the pipeline task; the embodiments of this application do not limit the representation method of the workload.
[0106] S220, if the first worker thread meets the migration conditions based on the workload of each worker thread, then the target pipeline task in the work queue corresponding to the first worker thread is migrated to the work queue corresponding to the second worker thread in the worker thread pool.
[0107] After obtaining the workload of all worker threads, the first worker thread determines whether it meets the migration conditions based on the workload of each worker thread in the worker thread pool. If it does, it determines the target pipeline task from the work queue corresponding to the first worker thread, determines the second worker thread from the worker thread pool, and submits the target pipeline task to the work queue corresponding to the second worker thread; otherwise, it determines that there is no target pipeline task in the work queue corresponding to the first worker thread.
[0108] In one possible implementation, if there are other worker threads in the worker thread pool with a workload greater than that of the first worker thread, and the absolute value of the difference between their workloads is greater than a threshold, then the first worker thread is determined to meet the migration condition. The first worker thread is first selected as the second worker thread from among those worker threads with a workload greater than that of the first worker thread and an absolute value of the difference between their workloads and that of the first worker thread that is greater than a threshold; the threshold is set as needed, and this embodiment does not impose any limitations. Then, the target pipeline task is determined based on half of the difference between the workloads of the first and second worker threads.
[0109] In one possible implementation, the workload is represented by the number of pipeline tasks in the work queue corresponding to the worker thread. The first worker thread takes half of the difference between the workload of the first worker thread and the workload of the second worker thread and rounds it down to obtain the target number of pipeline tasks. Then, the target pipeline tasks are determined from the corresponding work queue based on the number of target pipeline tasks.
[0110] For example, if the workload of the first worker thread is 8 and the workload of the second worker thread is 6, then the first worker thread determines the number of target pipeline tasks to be 1; if the workload of the first worker thread is 6 and the workload of the second worker thread is 3, then the first worker thread determines the number of target pipeline tasks to be 1.
[0111] Optionally, the first worker thread determines a load balancer based on the workload of each worker thread. If the workload of the first worker thread is greater than the load balancer, the first worker thread is deemed to meet the migration condition. The load balancer is determined based on the average workload of all worker threads, and the load balancer is greater than or equal to the average workload of all worker threads. The first worker thread then determines the second worker thread and the target pipeline task based on its workload.
[0112] In one possible implementation, the first worker thread determines the second worker thread from among worker threads whose workload is less than the balanced load. In another possible implementation, the first worker thread determines the worker thread with the smallest workload as the second worker thread.
[0113] In one possible implementation, the workload is represented by the number of pipeline tasks in the work queue corresponding to the worker thread. The first worker thread takes half of the difference between its workload and the balanced load and rounds down to obtain the target number of pipeline tasks. Then, the target pipeline tasks are determined from the corresponding work queue based on the number of target pipeline tasks.
[0114] In one possible implementation, the first worker thread sums the workloads of all worker threads to obtain the total workload; then the total workload is divided by the number of all worker threads to obtain the average workload; finally, the average workload is rounded up to obtain the balanced load.
[0115] In one possible implementation, the first worker thread can determine any number of target pipeline tasks from the corresponding work queue as target pipeline tasks. For example, the work queue corresponding to the first worker thread includes 4 pipeline tasks, namely tasks 1-4, and the number of target pipeline tasks is 2; the first worker thread can determine any 2 of pipeline tasks 1-4 as target pipeline tasks.
[0116] For example, Figure 7 This diagram illustrates the load balancing process among worker threads. (For example...) Figure 7 As shown, the worker thread pool includes worker threads 1-3. Work queue 1 corresponding to worker thread 1 has 4 pipeline tasks, namely T1, T3, T4, and T6. Work queue 2 corresponding to worker thread 2 has 0 pipeline tasks, and work queue 3 corresponding to worker thread 3 has 3 pipeline tasks, namely T2, T5, and T7. Worker thread 1 obtains the workload of worker threads 2 and 3 to get the total workload; worker thread 2 obtains the workload of worker threads 1 and 3 through the mailbox to get the total workload; worker thread 3 obtains the workload of worker threads 1 and 3 through the mailbox to get the total workload; the total workload is 7, and the load balancing is... Worker thread 1 has a workload greater than the load balancer, so the migration count is 1. Since worker thread 2 has the smallest workload, worker thread 1 selects a pipeline task (such as T6) from work queue 1 and pushes it to work queue 2.
[0117] In one possible implementation, the first worker thread selects a number of pipeline tasks from its corresponding work queue that are executed later in the target pipeline task order as the target pipeline task. For example, if the first worker thread determines that the number of target pipeline tasks is 2, and its corresponding work queue contains 4 pipeline tasks with the execution order of task 1, task 2, task 3, and task 4, the first worker thread can designate task 3 and task 4 as the target pipeline task; alternatively, the first worker thread can designate task 4 as the target pipeline task first. In another possible implementation, the first worker thread can first designate task 4 as the target pipeline task, issue task 4, then update the load balancer, and re-determine whether the migration conditions are met based on the updated load balancer.
[0118] In one possible implementation, the number of worker threads in the pool can be dynamically adjusted. For example, if the workload of three worker threads is continuously greater than a first load for a duration greater than a first duration, the worker thread pool can create a fourth worker thread. Worker thread 4 retrieves pipeline tasks from work queue 4 and executes them. Load balancing is performed among worker threads 1-4 to reduce the workload of each worker thread in the pool. The first load and the first duration can be set as needed, and this embodiment does not impose any limitations.
[0119] Figure 8 This illustrates a task processing procedure. For example... Figure 8 As shown, the blocking task detection unit is implemented as a background thread pool. Data node 8 is configured with a task processing device 80, which includes a foreground thread 81, a worker thread pool 82, and a background thread pool 83. After receiving a task distributed by the coordinating node, the foreground thread 81 generates pipelined tasks and distributes them to multiple worker threads in the worker thread pool 82 (exemplarily shown are worker thread 1, worker thread 2, and worker thread n, where n is a positive integer greater than 2). Each worker thread is bound to a CPU core CPUi (where i is a positive integer). The worker thread pool 82 creates n worker threads based on the pipelined tasks, where n is less than or equal to the number of CPU cores. Specifically, the foreground thread 81 distributes the pipelined tasks to multiple work queues (exemplarily shown are work queue 1 for worker thread 1, work queue 2 for worker thread 2, and work queue n for worker thread n). Each worker thread executes a pipelined task in a corresponding work queue. When executing a pipelined task, the worker thread pushes data from the source operator to the next operator, and the next operator continues to push data to the operator after that, completing the calculation of each operator in sequence. In this process, after worker thread 1 pushes the source operator to the next operator, the pipeline task is blocked. Worker thread 1 records the execution progress information and submits the pipeline task to the background thread pool 73 (background thread 1 and background thread m are shown as an example, where m is a positive integer greater than 1). After the pipeline task is unblocked, the background thread pool 73 submits the pipeline task to the work queue 1, waiting for worker thread 1 to continue execution according to the execution progress information.
[0120] In one possible implementation, after the pipeline task is unblocked, the background thread pool submits the pipeline task to the work queue n; after the worker thread n obtains the pipeline task, it obtains the execution progress information from the worker thread 1 and continues to execute the pipeline task according to the execution progress information.
[0121] Each worker thread retrieves the workload of other worker threads from the mailbox at a first preset time interval. The third worker thread in the worker thread pool sends the target pipeline task to the fourth worker thread based on the workload of all worker threads.
[0122] Performance tests were conducted using the Transaction Processing Performance Council (TPC)-H benchmark in a test scenario with a data volume of 300 times the standard unit (SF). Employing the task processing method provided in the embodiments of this application, in multi-concurrency performance tests, the latency of query statements was reduced compared to the prior art, and the throughput increased from 10,000-15,000 to 20,000-25,000, resulting in an overall performance improvement of approximately 50%.
[0123] Based on the above embodiments, Figure 9 A schematic diagram of a task processing device is shown. Figure 9 As shown, the task processing device 900 is applied to a data node in the database. The task processing device 900 includes a worker thread pool 901 and a blocked task detection unit 902. The worker thread pool 901 includes multiple worker threads, each of which is bound to a different central processing unit core on the data node.
[0124] The first worker thread among the plurality of worker threads is used to submit the pipeline task to the blocked task cache queue when the pipeline task being executed is blocked.
[0125] The blocking task detection unit 902 is used to submit the pipeline task to the first worker thread when it detects that the pipeline task in the blocking task cache queue has been unblocked.
[0126] The first worker thread is also used to continue executing the pipeline task.
[0127] In one possible implementation, the multiple worker threads in the worker thread pool 901 are configured with different work queues, and the first worker thread is also used to obtain the pipeline task from the corresponding work queue.
[0128] In one possible implementation, the first worker thread is further configured to obtain the workload of each worker thread in the worker thread pool; if the first worker thread is determined to meet the migration conditions based on the workload of each worker thread, the target pipeline task in the work queue corresponding to the first worker thread is migrated to the work queue corresponding to the second worker thread in the worker thread pool.
[0129] In one possible implementation, the migration condition includes the workload in the work queue corresponding to the first worker thread being greater than the load balancing load, and the first worker thread is further configured to determine the load balancing load based on the workload of each worker thread.
[0130] In one possible implementation, the task processing device further includes a foreground thread, which is used to generate the pipeline task and allocate the pipeline task to the work queue corresponding to the first worker thread.
[0131] In one possible implementation, the first worker thread is further configured to record the execution progress information of the pipeline task when the pipeline task is blocked, and continue to execute the pipeline task according to the execution progress information.
[0132] This application also provides a computing device 100. For example... Figure 10 As shown, the computing device 100 includes a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other via the bus 102. The computing device 100 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 100.
[0133] Bus 102 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 10 The bus 102 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 102 may include a path for transmitting information between various components of the computing device 100 (e.g., memory 106, processor 104, communication interface 108).
[0134] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0135] Memory 106 may include volatile memory, such as random access memory (RAM). Memory 106 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0136] The memory 106 stores executable program code, which the processor 104 executes to implement the functions of the aforementioned request processing module and repair processing module, thereby realizing the task processing method. That is, the memory 106 stores instructions for executing the task processing method.
[0137] The communication interface 108 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 100 and other devices or communication networks.
[0138] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0139] like Figure 11 As shown, the computing device cluster includes at least one computing device 100. The memory 106 of one or more computing devices 100 in the computing device cluster may store the same instructions for executing task processing methods. For example, a database includes at least one computing device 100, and a data node is implemented as one computing device 100.
[0140] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions for executing task processing methods. In other words, a combination of one or more computing devices 100 can jointly execute instructions for executing task processing methods. For example, a database includes at least one computing device 100, and a data node is implemented as one or more computing devices 100.
[0141] It should be noted that the memory 106 in different computing devices 100 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the task processing device. That is, the instructions stored in the memory 106 of different computing devices 100 can implement the functions of a foreground thread, the first worker thread in the worker thread pool, or a blocked task detection unit.
[0142] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 12 One possible implementation is shown. For example... Figure 12 As shown, the two computing devices 100A and 100B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this possible implementation, the memory 106 in computing device 100A stores instructions for executing the function of the first worker thread in the worker thread pool. Simultaneously, the memory 106 in computing device 100B stores instructions for executing the function of the blocking task detection unit.
[0143] It should be understood that Figure 12 The functions of the computing device 100A shown can also be performed by multiple computing devices 100. Similarly, the functions of the computing device 100B can also be performed by multiple computing devices 100.
[0144] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform the above-described task processing method.
[0145] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center that includes one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform a task processing method.
[0146] The term "and / or" in this article is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0147] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.
[0148] Furthermore, the term "and / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship. The term "at least one" in this application can represent "one" and "two or more." For example, A, B, and C can represent: A existing alone, B existing alone, C existing alone, A and B existing simultaneously, A and C existing simultaneously, C and B existing simultaneously, and A, B, and C existing simultaneously.
[0149] In this embodiment of the application, expressions such as "A includes B" are used to indicate that A may or may not include other items besides B. When other items are not included, it can be understood as "A is B", in which case "A" can be replaced with "B".
[0150] In this application, unless otherwise specified, the same or similar parts between the various embodiments can be referred to each other. In the various embodiments of this application, and in the various implementation methods / methods / implementations within each embodiment, unless otherwise specified or logically conflicting, the terminology and / or descriptions between different embodiments and between the various implementation methods / methods / implementations within each embodiment are consistent and can be mutually referenced. The technical features in different embodiments and the various implementation methods / methods / implementations within each embodiment can be combined according to their inherent logical relationships to form new embodiments, implementation methods, methods, or implementation approaches. The embodiments described below do not constitute a limitation on the scope of protection of this application.
[0151] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A task processing method, characterized in that, The method, applied to a task processing device configured on a data node of a database, includes a worker thread pool and a blocked task detection unit. The worker thread pool includes multiple worker threads, each bound to a different central processing unit core on the data node. If the pipeline task being executed is blocked, the first worker thread among the plurality of worker threads submits the pipeline task to the blocked task cache queue. When the blocking task detection unit detects that the pipeline task in the blocking task cache queue has been unblocked, it submits the pipeline task to the first worker thread. The first worker thread continues to execute the pipeline task.
2. The method according to claim 1, characterized in that, The worker threads in the worker thread pool are configured with different work queues, and the method further includes: The first worker thread retrieves the pipeline task from the corresponding work queue and executes the pipeline task.
3. The method according to claim 1 or 2, characterized in that, The method further includes: The first worker thread obtains the workload of each worker thread in the worker thread pool; If the first worker thread is determined to meet the migration conditions based on the workload of each worker thread, then the target pipeline task in the work queue corresponding to the first worker thread is migrated to the work queue corresponding to the second worker thread in the worker thread pool.
4. The method according to claim 3, characterized in that, The migration condition includes that the workload in the work queue corresponding to the first worker thread is greater than the load balancing load, and the method further includes: The first worker thread determines the load balancing based on the workload of each worker thread.
5. The method according to any one of claims 1-4, characterized in that, The task processing device further includes a foreground thread, and the method further includes: The foreground thread generates the pipeline tasks and assigns the pipeline tasks to the work queue corresponding to the first worker thread.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: When the pipeline task is blocked, the first worker thread records the execution progress information of the pipeline task. The first worker thread continues to execute the pipeline task, including: The pipeline task continues to be executed based on the execution progress information.
7. A task processing device, characterized in that, The task processing device, applied to a data node in a database, includes a worker thread pool and a blocked task detection unit. The worker thread pool includes multiple worker threads, each bound to a different central processing unit core on the data node. The first worker thread among the plurality of worker threads is used to submit the pipeline task to the blocked task cache queue when the pipeline task being executed is blocked. The blocking task detection unit is used to submit the pipeline task to the first worker thread when it detects that the pipeline task in the blocking task cache queue has been unblocked. The first worker thread is also used to continue executing the pipeline task.
8. The apparatus according to claim 7, characterized in that, The worker threads in the worker thread pool are configured with different work queues, and the first worker thread is also used to obtain the pipeline task from the corresponding work queue.
9. The apparatus according to claim 7 or 8, characterized in that, The first worker thread is also used to obtain the workload of each worker thread in the worker thread pool; if it is determined that the first worker thread meets the migration conditions based on the workload of each worker thread, then the target pipeline task in the work queue corresponding to the first worker thread is migrated to the work queue corresponding to the second worker thread in the worker thread pool.
10. The apparatus according to claim 9, characterized in that, The migration condition includes that the workload in the work queue corresponding to the first worker thread is greater than the load balancing, and the first worker thread is also used to determine the load balancing based on the workload of each worker thread.
11. The apparatus according to any one of claims 7-10, characterized in that, The task processing device also includes a foreground thread. The foreground thread is used to generate the pipeline tasks and allocate the pipeline tasks to the work queue corresponding to the first worker thread.
12. The apparatus according to any one of claims 7-11, characterized in that, The first worker thread is also used to record the execution progress information of the pipeline task when the pipeline task is blocked, and to continue executing the pipeline task according to the execution progress information.
13. A computing device, characterized in that, The computing device includes a processor and a memory; the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to cause the computing device to perform the method as described in any one of claims 1-6.
14. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1-6.
15. A computer program product, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster performs the method of any one of claims 1-6.
16. A computer-readable storage medium, characterized in that, It includes computer program instructions, which, when executed by a cluster of computing devices, enable the cluster of computing devices to perform any one of 1-6.