System cache processing method and device, electronic equipment and storage medium
By reassigning system cache tasks to less busy processing cores and dividing background tasks, the performance degradation problem of system cache processing tasks is solved, and the overall computer performance and processing efficiency are improved.
Patent Information
- Application Number
- CN202411282609.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-12-20
AI Technical Summary
When the system caches the foreground and background tasks, the task superposition causes the queue to wait for scheduling to increase, reducing the processing speed of the system cache.
By judging the task scheduling queue tasks of the processing core that is bound to the storage volume, if the threshold is reached, the task will be reassigned to the less busy processing core, and the background task will be divided into subtasks to improve processing efficiency and advance the front-end task in task scheduling in advance Execute in the queue.
It effectively improves the performance of system cache, avoids slowing processing speed caused by task accumulation, and improves the overall performance of the computer and the utilization of processing core.
Smart Images

Figure CN119166351A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a system cache processing method, device, electronic equipment and storage medium. Background Art
[0002] With the continuous development of the computer field, users have higher and higher performance requirements for computer products. Among them, the performance improvement of the system cache is an important aspect of improving the performance of the whole machine. When the computer has received and used data before, it can directly obtain the data through the system cache, without having to obtain the data again from the remote server, which greatly speeds up the computer's data processing speed. During the data processing process, the system cache not only needs to receive the foreground data to perform the corresponding foreground tasks, but also needs to perform background tasks such as data flushing. These foreground tasks and background tasks will always run on the CPU (Central Processing Unit) core bound to the storage volume. If the storage volume has foreground tasks and background tasks to be processed at the same time, the superposition of multiple tasks will lead to an increase in the queue waiting time for scheduling, which greatly reduces the processing speed of the system cache.
[0003] It can be seen that how to improve the performance of the system cache is a problem that technical personnel in this field need to solve. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a system cache processing method, device, electronic device and storage medium, which can solve the problem of how to improve the performance of the system cache.
[0005] To solve the above technical problems, an embodiment of the present invention provides a system cache processing method, including:
[0006] When a storage volume in the computer receives a system cache task to be processed, determining whether the amount of tasks in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold;
[0007] If not, adding the system cache task to the task scheduling queue of the current processing core;
[0008] If so, traverse all processing cores in the computer to determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; the second preset threshold is less than the first preset threshold;
[0009] The system cache task is added to the task scheduling queue of the target processing core.
[0010] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing method further includes:
[0011] If the system cache task is a background task, determining whether the processing time of the background task is greater than a preset duration;
[0012] If yes, the background task is divided into a plurality of system cache subtasks according to the time sequence, and the plurality of system cache subtasks are sequentially allocated to the storage volume.
[0013] In some embodiments, it also includes:
[0014] Build the computer's storage space into a preset number of storage volumes;
[0015] Selecting a preset number of processing cores from among all processing cores of the computer;
[0016] Allocating the preset number of processing cores to the preset number of storage volumes in a one-to-one correspondence;
[0017] Recording the allocated one-to-one corresponding core number of the processing core and the volume number of the storage volume to a preset location to complete the binding of the storage volume and the processing core;
[0018] The step of adding the system cache task to the task scheduling queue of the target processing core includes:
[0019] Determining a core number of the target processing core;
[0020] Modify the core number of the processing core corresponding to the volume number of the storage volume in the preset position from the core number of the current processing core to the core number of the target processing core, so as to complete the binding of the storage volume with the target processing core;
[0021] The system cache task received by the storage volume is added to the task scheduling queue of the target processing core based on the bound storage volume and the target processing core.
[0022] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing method further includes:
[0023] If the system cache task is a foreground task, determining whether all the task scheduling queues of the processing core to which the system cache task is added are background tasks;
[0024] If so, the system cache task is advanced to the front of the task scheduling queue.
[0025] In some embodiments, before the system cache task is advanced to the front of the task scheduling queue, the method further includes:
[0026] Determining whether the remaining capacity of the system cache in the storage volume meets the reservation condition;
[0027] If yes, jump to the step of advancing the system cache task to the front of the task scheduling queue;
[0028] If not, then select a number of background tasks in the task scheduling queue of the processing core to which the system cache task is added, and advance the selected number of background tasks to the front of the task scheduling queue in a preset order.
[0029] In some embodiments, determining whether the remaining capacity of the system cache in the storage volume meets the reservation condition includes:
[0030] Calculating whether the ratio of background tasks to foreground tasks in the task scheduling queue of the processing core currently bound to the storage volume is greater than a third preset threshold;
[0031] If so, determining that the remaining capacity of the system cache in the storage volume does not meet the reservation condition;
[0032] If not, it is determined that the remaining capacity of the system cache in the storage volume meets the reservation condition.
[0033] In some embodiments, before the system cache task is advanced to the front of the task scheduling queue, the method further includes:
[0034] Determine whether the number of system cache tasks that have been advanced in the task scheduling queue within a preset time period is greater than a preset value;
[0035] If yes, keep the system cache task at the end of the task scheduling queue;
[0036] If not, jump to the step of advancing the system cache task to the front of the task scheduling queue.
[0037] To solve the above technical problems, an embodiment of the present invention further provides a system cache processing device, including:
[0038] a task volume determination unit, configured to determine, when a storage volume in a computer receives a system cache task to be processed, whether the task volume in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold; if not, trigger the first queuing unit; if yes, trigger the traversal unit;
[0039] The first queuing unit is used to add the system cache task to the task scheduling queue of the current processing core;
[0040] The traversal unit is used to traverse all processing cores in the computer and determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; the second preset threshold is less than the first preset threshold;
[0041] The second queuing unit is used to add the system cache task to the task scheduling queue of the target processing core.
[0042] To solve the above technical problems, an embodiment of the present invention further provides an electronic device, including:
[0043] Memory for storing computer programs;
[0044] A processor is used to execute the computer program to implement the steps of the system cache processing method as described above.
[0045] To solve the above technical problem, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the system cache processing method as described above are implemented.
[0046] It can be seen from the above technical solution that when the storage volume receives a system cache task that needs to be processed, the task scheduling status of the processing core bound to it is first determined. When the processing core is not too busy, the processing core currently bound to the storage volume is directly used to execute the system cache task; when the processing core is relatively busy, a relatively less busy processing core can be re-determined to complete the system cache task. The beneficial effect of the present invention is that each time a system cache task is received, a less busy processing core is found to execute the task, avoiding the slow processing speed caused by task accumulation and the degradation of system cache performance, effectively improving the performance of the system cache, and at the same time improving the utilization rate of the processing core in the computer, thereby greatly improving the performance of the entire computer. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 A schematic diagram of a flow chart of a system cache processing method provided by an embodiment of the present invention;
[0049] Figure 2 A schematic flow chart of another system cache processing method provided by an embodiment of the present invention;
[0050] Figure 3 A flowchart of a system cache processing method when the system cache task is a background task provided by an embodiment of the present invention;
[0051] Figure 4 A schematic diagram of the structure of a system cache processing device provided by an embodiment of the present invention;
[0052] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] The terms "including" and "having" in the specification of the present invention and the above-mentioned drawings, as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0055] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0056] Next, a system cache processing method provided by an embodiment of the present invention is described in detail. Figure 1 As shown, Figure 1 A schematic flow chart of a system cache processing method provided by an embodiment of the present invention, the system cache processing method comprising:
[0057] S11: when a storage volume in the computer receives a system cache task to be processed, determining whether the amount of tasks in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold;
[0058] It should be noted that the storage volume in the computer will perform the task of system cache. After the data is written to the system cache, it can respond to the host to complete the corresponding function; at the same time, the system cache will flush part of the stored data and finally write it to the backend disk; thus, system cache tasks such as responding to the host and flushing data according to the data in the system cache are generated. These system cache tasks will be assigned to the corresponding storage volume according to the storage situation of the corresponding data. For example, when the user needs to obtain a certain data, the task of obtaining the data will be assigned to the storage volume storing the data. The storage volume itself is only used as a storage space, so the system cache task assigned to the storage volume needs to be completed with the help of the computer's own processing core. When the computer is actually used, the internal storage space will be allocated to several storage volumes. In order to facilitate each storage volume to complete the system cache task, the computer will allocate several processing cores of its own processor to each storage volume one by one, and the processing core and storage volume will be bound one by one to perform the system cache task.
[0059] It is understandable that when too many tasks are assigned to a storage volume, there are already many pending system cache tasks in the task scheduling queue of the processing core to which it is currently bound. At this time, if the storage volume still schedules the assigned tasks to the processing core for processing, it will need to wait until all other system cache tasks in the current task scheduling queue are processed before it can be processed. This greatly prolongs the processing time of the system cache tasks and reduces the processing efficiency. Therefore, when the storage receives pending system cache tasks, it will first determine and judge the amount of tasks in the task scheduling queue of the current processing core to which the storage volume is currently bound.
[0060] Specifically, the present application does not make any special restrictions on the specific implementation method of determining the amount of tasks in the task scheduling queue of the processing core. Taking the CPU core as an example, the occupancy of the CPU core can be directly obtained through the task manager and other methods, and when each system cache task is added to the task scheduling queue of the processing core, the processing core itself will record the task status in its own task scheduling queue, and the queue record can be directly viewed to determine the amount of tasks in the task scheduling queue. The present application does not make any special restrictions on the specific value and implementation method of the first preset threshold, which can be implemented in percentage or by directly defining the data volume threshold in the task scheduling queue.
[0061] S12: If not, adding the system cache task to the task scheduling queue of the current processing core;
[0062] It is not difficult to understand that if the amount of tasks in the task scheduling queue of the current processing core bound to the storage volume does not reach the first preset threshold, it means that the amount of tasks of the current processing core currently bound to the storage volume itself is not large, and there are fewer tasks to be processed in the task scheduling queue. At this time, the system cache tasks assigned to itself can continue to be added to the task scheduling queue of the current processing core.
[0063] See also Figure 2 As shown, Figure 2 A flowchart of another system cache processing method provided by an embodiment of the present invention; the first preset threshold is set to 50%. When the storage volume receives host data and needs to respond to the host data to execute the corresponding system cache task, the task percentage of the current CPU core bound to the storage volume is first obtained to determine whether the task percentage is greater than 50%. Generally, there is a fixed length limit on the task scheduling queue of the processing core, and the task percentage can specifically be the occupancy percentage of the task scheduling queue of the processing core. If the task percentage is not greater than 50%, the task can be directly added to the task scheduling queue of the current processing core; if the task percentage is greater than 50%, subsequent operations of traversing all processing cores are required.
[0064] S13: If yes, traverse all processing cores in the computer to determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; the second preset threshold is less than the first preset threshold;
[0065] It is understandable that in order to avoid the situation where the core task assigned to the system cache task is always busy and the unassigned core is always idle, causing the waste of CPU computing power, this application will traverse all the processing cores in the computer when the amount of tasks in the task scheduling queue of the current processing core bound to the storage volume reaches or exceeds the first preset threshold, and select a processing core with less tasks as the target processing core. As a preferred embodiment, the processing core with the least amount of tasks can be selected as the target processing core, which can effectively reduce the number of times the CPU core is switched. The specific value and implementation method of the second preset threshold are not particularly limited in this application, and it only needs to be less than the first preset threshold, and the implementation method can be consistent with the first preset threshold.
[0066] S14: Add the system cache task to the task scheduling queue of the target processing core.
[0067] It is not difficult to understand that after determining the target processing core, the storage volume can be added to the task scheduling queue of the target processing core, and the target processing core can be used to process the system cache task. The number of processing cores in a computer is generally greater than the number of divided storage volumes. Therefore, after traversing all processing cores, the target processing core determined is generally a processing core that is not bound to a storage volume. These processing cores are in an idle state. After the system cache task received by the storage volume is added to its task scheduling queue, it can be quickly processed in a short time.
[0068] As a specific implementation example, the system cache module receives the foreground host IO data and first obtains the task volume of the CPU core currently bound to the storage volume. If the task volume of the CPU core exceeds a certain number, it reselects the CPU core with the least task volume among all the CPU cores of the current operating system and adds the host IO processing task to the task scheduling queue of the CPU core.
[0069] It is understandable that after the data is written to the system cache, it can directly respond to the host and complete, and the computer does not need to perform remote data acquisition and other operations. Therefore, the improvement of the system cache performance can greatly improve the performance of the entire computer. The present invention can solve the problem of increased latency of storage products caused by the system cache data processing flow sharing the CPU core and the CPU core task scheduling not distinguishing between the foreground host IO and the background task IO. Before each task scheduling, first determine the percentage of the number of tasks of the current CPU core. After exceeding the percentage of the number of tasks, traverse the current CPU core to find a relatively unbusy CPU core, thereby effectively improving the utilization of the CPU core; by improving the utilization of the CPU core, the performance of the entire system cache is effectively improved.
[0070] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing method further includes:
[0071] If the system cache task is a background task, determine whether the processing time of the background task is greater than the preset duration;
[0072] If so, the background task is divided into a plurality of system cache subtasks according to the time sequence, and the plurality of system cache subtasks are sequentially allocated to the storage volume.
[0073] It is understandable that, since the processing time of background tasks is relatively long, in order to ensure that all pending system cache tasks can be processed in a timely manner, for background tasks with poor processing time, the task scheduling process of a processing core is generally not used to complete the entire background task, but a background task will be divided into several subtasks. When the background task is assigned to a storage volume, the storage volume will select a processing core to process the background task, and during the processing process, the processing core will first process the first subtask after the division, and then the background task will exit, and reselect the processing core according to the task volume of the current processing core, and then continue to queue and execute the next subtask until all subtasks are processed in order, that is, the processing process of a background task is divided into the processing process of several subtasks. At the same time, considering that the data in the background task may have continuity, the time sequence will be retained during the division, and it will be processed in sequence according to the time sequence to avoid data discontinuity or lack of basis.
[0074] It should be noted that the present application does not make any special restrictions on the specific value of the preset duration and the implementation method, and can also judge whether the background task needs to be divided according to parameters such as workload, and is not limited to the implementation method of judging according to the processing time in this embodiment. The present application does not make any special restrictions on the specific method of dividing the background task, and can divide it into several subtasks with shorter processing time according to the processing time, or divide it into several subtasks with a certain amount of task to be processed each time according to the task amount. When the background task exits and reselects the CPU core, the task amount of the CPU core bound to the storage volume is also obtained first. If the CPU core has a small amount of tasks, the task can continue to be added to the core to wait for queuing processing. If the task amount is large, traverse all CPU cores to find the CPU with the least amount of tasks, and add the task to the CPU core to wait for task scheduling. That is, each execution process is regarded as a processing process for receiving a system cache task, and steps S11-S14 are repeatedly executed.
[0075] See also Figure 3 As shown, Figure 3A flowchart of a system cache processing method provided by an embodiment of the present invention when the system cache task is a background task; when a background task initiated by the cache system is just received, steps S11-S14 are executed, a processing core is determined by traversing all CPU cores, and the background task is added to the task scheduling queue of the processing core, and then this task scheduling only processes a subtask of the background task, and the entire background task will not be executed; then the background task exits the current processing core, and steps S11-S14 are re-executed to determine whether the number of tasks of the current processing core exceeds 50%, if not, the background task is continued to be added to the task scheduling queue of the current processing core to process the second subtask; if the number of tasks exceeds 50%, all processing cores are re-traversed to re-determine a processing core as the current processing core of the storage volume. Repeat the above process until all subtasks of the background task are processed.
[0076] As a specific embodiment, after the system cache capacity reaches a certain percentage, the timer will start a background task that releases space regularly. When the background task is started, since the background task processing time is relatively long, all CPU cores are first traversed to find the CPU core with the least number of tasks, and the CPU core is recorded in the CPU core field of the background task of the volume, and the background task is added to the task scheduling queue of the CPU core. If the background task is not completed in one scheduling, it is necessary to add it back to the CPU core task scheduling queue, and re-determine the percentage of the number of tasks of the currently bound CPU core. If it exceeds 50%, all CPU cores are traversed again to find the core with the smallest number of tasks, and the background task is added to the task scheduling queue. If it does not exceed, continue to queue on the CPU core and wait for the task to be scheduled.
[0077] Specifically, in order to avoid the situation where the processing core takes too long to process a single background task, resulting in too many subsequent queued tasks, thereby affecting the system cache situation, when processing background tasks, background tasks that require a long time to process or whose workload exceeds a certain value will be divided into several subtasks for processing. After completing a subtask, the background task will be re-queued as a new system cache task and the processing core will be reselected, so that the current processing core can process subsequent queued tasks in a timely manner, avoiding the processing core being occupied for a long time, thereby speeding up the processing efficiency of the entire system cache and improving the system cache performance.
[0078] In some embodiments, it also includes:
[0079] Build the computer's storage space into a preset number of storage volumes;
[0080] Selecting a preset number of processing cores from among all processing cores of the computer;
[0081] Allocate a preset number of processing cores to a preset number of storage volumes one by one;
[0082] Recording the allocated one-to-one corresponding core number of the processing core and the volume number of the storage volume to a preset location to complete the binding of the storage volume and the processing core;
[0083] Add the system cache task to the task scheduling queue of the target processing core, including:
[0084] Determine the core number of the target processing core;
[0085] Modify the core number of the processing core corresponding to the volume number of the storage volume in the preset position from the core number of the current processing core to the core number of the target processing core, so as to complete the binding of the storage volume and the target processing core;
[0086] Based on the bound storage volume and the target processing core, the system cache task received by the storage volume is added to the task scheduling queue of the target processing core.
[0087] It is not difficult to understand that when a computer creates a storage volume, the storage volume will be bound to the processing core. When the volume is created, the system cache assigns a CPU core to the volume and records it. The process of one-to-one binding between the storage volume and the processing core is realized by correspondingly recording the core number of the processing core and the serial number of the storage volume. The specific type and implementation method of the preset position are not particularly limited in this application, and generally recorded at a specific location of the storage volume. Therefore, when the system cache task such as host data reaches the system cache module, the CPU core number recorded in the corresponding volume will be obtained, and then the number of tasks of the current CPU core bound to the storage volume will be obtained according to the CPU core number. If the number of tasks exceeds 50% of the maximum processing capacity of the CPU core task, all the cores of the CPU are traversed to find the CPU core with the smallest number of tasks, and the re-searched CPU core will be re-bound to the storage volume. The subsequent system cache tasks such as the foreground host IO tasks of the system cache will be processed on the re-bound CPU core until the system cache read and write IO tasks are processed and responded to the host.
[0088] It should be noted that the storage volume will add the received system cache tasks to the task scheduling queue of the processing core bound to itself by default, and the processing core bound to itself will process them. Therefore, when the current processing core bound to the storage volume has a large amount of tasks, it is necessary to unbind the storage volume from the current processing core and rebind it to the selected target processing core, that is, to change the core number of the processing core corresponding to the volume number of the storage volume from the core number of the current processing core to the core number of the target processing core. After rebinding, the storage volume can add the system cache tasks to the task scheduling queue of the target processing core based on the binding relationship between itself and the target processing core, and the target processing core will process them. There are many options for the specific implementation of binding and unbinding, which are not limited to the method of using serial number allocation in this application.
[0089] It is understandable that for the convenience of management, the storage volume will also record the core number of the CPU core corresponding to each task assigned to it. For example, for several system cache tasks in the same storage volume, some tasks may be completed by the processing core that was first bound to the storage volume, and other tasks may be completed by the rebound processing core. At this time, the storage volume will record the core number of the processing core that completed the task in each task or in a specific location of the data storage location corresponding to each task for the convenience of management.
[0090] Specifically, the binding and unbinding process between the processing core and the storage volume can be achieved by allocating and recording the core number of the processing core and the serial number of the storage volume, and the rebinding process can be achieved by modifying the corresponding relationship of the records. It is simple, effective, easy to implement, and convenient for operators or users to view.
[0091] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing method further includes:
[0092] If the system cache task is a foreground task, determine whether all the task scheduling queues of the processing core to which the system cache task is added are background tasks;
[0093] If so, the system cache task is advanced to the front of the task scheduling queue.
[0094] It is not difficult to understand that for data processing, more attention should be paid to the priority issue. The foreground IO priority is higher. If it is scheduled late, the storage delay will definitely increase. In the development of storage products, the priority of tasks needs to be considered. Therefore, in order to further improve the processing efficiency of the processing core for tasks to be processed in the task scheduling queue, the foreground tasks and background tasks in the tasks to be processed can also be distinguished from each other, and whether they need to be processed in advance can be determined according to the specific circumstances of the foreground and background tasks in the task scheduling queue. In general, considering that the processing time of foreground tasks is shorter than that of background tasks, and the response speed requirements of foreground tasks are relatively high, foreground tasks are generally executed first. Therefore, if the latest system cache task received is a foreground task, and the task scheduling queue it joins is all background tasks, the foreground task will be advanced to the front queue of the task scheduling queue for processing. You can choose to advance it to the front of the task scheduling queue, or you can choose to move it to the front half of the task scheduling queue for processing.
[0095] It should be noted that there are many ways to identify and distinguish between foreground tasks and background tasks, and this application does not make any special limitations here. The foreground refers to the interface that directly interacts with the user, and the background refers to the management system, configuration system, etc. for internal administrators. Therefore, the initiators of foreground tasks and background tasks are different. Therefore, the foreground tasks and background tasks can be distinguished based on the initiator when the storage volume receives the system cache task. The storage volume will receive the system cache task in real time and determine from which initiation location the system cache task is received. If the initiation location belongs to the foreground, the system cache task is marked with a first identifier representing the foreground task. If the initiation location belongs to the background, the system cache task is marked with a second identifier representing the background task; so that the task type in the task scheduling queue can be judged based on the identifier of each task later.
[0096] It is understandable that different target processing cores can also be determined according to the different types of system cache tasks received. Each time a foreground task is executed, a relatively unbusy CPU core is searched for to perform task scheduling when traversing all processing cores; when processing background tasks, since the background tasks take a long time to process, the least busy CPU core will be searched for to process the background tasks, and after the background tasks have been executed for a certain period of time and exited, a new CPU core task will be selected to queue and wait for scheduling.
[0097] Specifically, the present application can solve the problem of long waiting time for foreground tasks and increased host latency caused by the system cache module not distinguishing between foreground tasks and background tasks. In the process of processing system cache tasks, a certain priority is set for foreground tasks to ensure timely processing of foreground tasks, and by increasing the priority of foreground host IO processing in the system cache, excessive latency is avoided.
[0098] In some embodiments, before the system cache task is advanced to the front of the task scheduling queue, the method further includes:
[0099] Determine whether the remaining capacity of the system cache in the storage volume meets the reservation condition;
[0100] If yes, jump to the step of advancing the system cache task to the front of the task scheduling queue;
[0101] If not, then select several background tasks in the task scheduling queue of the processing core to which the system cache task is added, and advance the selected several background tasks to the front of the task scheduling queue in a preset order.
[0102] It is understandable that, because most of the background tasks involve related tasks such as space recovery of the system cache, the processing core cannot blindly advance the foreground tasks when scheduling tasks, but also needs to judge and determine according to the actual storage space of the system cache. If the remaining capacity of the storage space of the system cache is greater than the preset capacity value, the foreground tasks can be processed in advance; if the remaining capacity of the storage space of the system cache has not reached the preset capacity value, it means that background tasks need to be executed to free up space at this time, and then the background tasks need to be processed in advance. The specific basis for selecting background tasks and the number of selections can be adjusted according to the specific situation of the remaining capacity of the system cache, and this application does not make special restrictions here; the background tasks selected at this time can be selected according to the specific type of background tasks, etc. The background tasks that can release storage space specifically include timed data post-flush tasks set by timers and actively initiated data post-flush tasks. Generally, actively initiated data post-flush tasks can be processed first, so data post-flush tasks actively initiated by the system cache can be selected as priority background tasks. The execution priority in the queue can also be adjusted according to the specific ratio of foreground tasks to background tasks in the task scheduling queue. For example, when the ratio of foreground tasks to background tasks is n / m, m background tasks can be processed first, and then n foreground tasks can be processed. In this way, the task scheduling queue can be adjusted. n and m are both positive integers.
[0103] As a specific embodiment, the remaining capacity of the system cache can be determined by determining the number of background tasks in the task scheduling queue of the current processing core. If the number of background tasks is large, it indicates that the system cache capacity is used more and space needs to be released to ensure that the foreground host IO writes. Therefore, in order for the foreground host IO not to wait for the system cache space capacity, the background tasks also need to be executed quickly. At this time, it is necessary to determine the ratio of the number of current background tasks to the number of foreground tasks. If the ratio exceeds a certain value, it is necessary to ensure the processing of background tasks first and release the system cache space capacity.
[0104] Specifically, although the processing priority of the foreground task is higher, the data in the foreground task can only be received normally when there is sufficient storage space in the system cache. Therefore, it is also necessary to adjust the priority execution tasks according to the remaining capacity of the system cache. When the remaining capacity of the system cache is small, the execution of some background tasks is prioritized to release the cache and ensure normal reception of data.
[0105] In some embodiments, determining whether the remaining capacity of the system cache in the storage volume meets the reservation condition includes:
[0106] Calculate whether the ratio of background tasks to foreground tasks in the task scheduling queue of the processing core currently bound to the storage volume is greater than a third preset threshold;
[0107] If so, it is determined that the remaining capacity of the system cache in the storage volume does not meet the reservation condition;
[0108] If not, it is determined that the remaining capacity of the system cache in the storage volume meets the reservation condition.
[0109] It is not difficult to understand that the remaining capacity of the current system cache can be determined by processing the ratio of background tasks to foreground tasks in the task scheduling queue of the core. If the number of background tasks is large, it indicates that the system cache capacity is used more and space needs to be released. Therefore, when the ratio of background tasks to foreground tasks is greater than the third preset threshold, it can be determined that the remaining capacity of the system cache does not meet the reservation condition. The specific value and implementation method of the third preset threshold are not particularly limited in this application, and can be adjusted according to the actual capacity of the system cache and other conditions.
[0110] Specifically, the ratio of background tasks to foreground tasks in the task scheduling queue can be used to determine the remaining capacity of the system cache in the corresponding storage volume, which is simple, effective and easy to implement, so that the priority of task execution can be adjusted according to the remaining capacity of the system cache.
[0111] In some embodiments, before the system cache task is advanced to the front of the task scheduling queue, the method further includes:
[0112] Determine whether the number of system cache tasks that have been advanced in the task scheduling queue within a preset time period is greater than a preset value;
[0113] If so, keep the system cache task at the end of the task scheduling queue;
[0114] If not, jump to the step of advancing the system cache task to the front of the task scheduling queue.
[0115] It is understandable that the requirements of improving the response speed of foreground tasks and ensuring the remaining capacity of the system cache can also be taken into account by increasing the execution priority of foreground tasks within a certain time period. That is, within a certain preset time period, only a certain number of foreground tasks are allowed to be processed in advance. If the foreground tasks processed in advance have reached the preset value, the foreground tasks will no longer be processed in advance, and will be processed normally according to the task scheduling queue, so that the background tasks in the task scheduling queue can also be processed to release the cache. The specific values and implementation methods of the preset time period and preset values are not particularly limited in this application, and can be set and adjusted according to the capacity of the system cache and the frequency of foreground task initiation in actual applications.
[0116] As a specific embodiment, if the ratio of background tasks to foreground host IO processing tasks on the same CPU core exceeds 2, it means that there are many background tasks and the system cache needs to recycle space capacity faster. At this time, the foreground task cannot be unconditionally added to the head of the queue for processing. You can first process two background tasks of the system cache, and then process one foreground host IO task of the system cache. If the ratio of the number of background tasks to foreground host IO tasks is less than 2, you can execute the foreground host IO task first, and then process the background task. However, you cannot immediately bring the task to the head of the queue as soon as the foreground task comes to the queue. You need to set a certain number of foreground host IO priority within a certain time period. Foreground IO tasks that exceed this number or time period cannot be advanced to the head of the queue. The purpose of this is to ensure that background tasks can also be scheduled within a certain time period, rather than blindly increasing the priority of the foreground host IO.
[0117] Specifically, in actual operation, it is necessary to consider not only the priority of the foreground task, but also the impact of background task processing on the system cache. Therefore, both aspects can be taken into account by limiting the priority of the foreground task, so that the processing core can ensure the storage capacity of the system cache while completing the foreground task as quickly as possible.
[0118] See also Figure 4 As shown, Figure 4 A schematic diagram of the structure of a system cache processing device provided by an embodiment of the present invention; To solve the above technical problems, an embodiment of the present invention further provides a system cache processing device, including:
[0119] The task volume determination unit 11 is used to determine whether the task volume in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold when the storage volume in the computer receives a system cache task to be processed; if not, trigger the first queuing unit 12; if yes, trigger the traversal unit 13;
[0120] The first queuing unit 12 is used to add the system cache task to the task scheduling queue of the current processing core;
[0121] The traversal unit 13 is used to traverse all processing cores in the computer and determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; the second preset threshold is less than the first preset threshold;
[0122] The second queuing unit 14 is used to add the system cache task to the task scheduling queue of the target processing core.
[0123] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing device further includes:
[0124] A background task processing duration judgment unit, used to judge whether the processing time of the background task is greater than a preset duration if the system cache task is a background task; if so, triggering a task division unit;
[0125] The task division unit is used to divide the background task into a plurality of system cache subtasks according to the time sequence, and allocate the plurality of system cache subtasks to the storage volume in sequence.
[0126] In some embodiments, the system cache processing device further includes:
[0127] A volume construction unit is used to construct the storage space of the computer into a preset number of storage volumes;
[0128] A core selection unit, configured to select a preset number of processing cores from among all processing cores of the computer;
[0129] A core allocation unit, configured to allocate the preset number of processing cores to the preset number of storage volumes in a one-to-one correspondence;
[0130] A binding unit, used for recording the allocated one-to-one corresponding core number of the processing core and the volume number of the storage volume to a preset location, so as to complete the binding of the storage volume and the processing core;
[0131] The second queuing unit 14 comprises:
[0132] a target sequence number determination unit, configured to determine a core number of the target processing core;
[0133] A modification binding unit, used to modify the core number of the processing core corresponding to the volume number of the storage volume in the preset position from the core number of the current processing core to the core number of the target processing core, so as to complete the binding of the storage volume with the target processing core;
[0134] The second queuing sub-unit is configured to add the system cache task received by the storage volume to the task scheduling queue of the target processing core based on the bound storage volume and the target processing core.
[0135] In some embodiments, the system cache task includes a foreground task and a background task, and the system cache processing device further includes:
[0136] A queue task judgment unit, for judging whether all the task scheduling queues of the processing core to which the system cache task is added are background tasks if the system cache task is a foreground task; if so, triggering a foreground task advance unit;
[0137] The foreground task advance unit is used to advance the system cache task to the front end of the task scheduling queue.
[0138] In some embodiments, the system cache processing device further includes:
[0139] A remaining capacity determination unit, configured to determine whether the remaining capacity of the system cache in the storage volume meets the reservation condition; if so, triggering the foreground task advance unit; if not, triggering the background task advance unit;
[0140] The background task advance unit is used to select several background tasks in the task scheduling queue of the processing core to which the system cache task is added, and advance the selected several background tasks to the front of the task scheduling queue in a preset order.
[0141] In some embodiments, the remaining capacity determination unit includes:
[0142] a ratio determination unit, configured to calculate whether the ratio of background tasks to foreground tasks in the task scheduling queue of the processing core currently bound to the storage volume is greater than a third preset threshold; if so, triggering the first determination unit; if so, triggering the second determination unit;
[0143] A first determination unit, configured to determine that the remaining capacity of the system cache in the storage volume does not meet a reservation condition;
[0144] The second determination unit is configured to determine whether the remaining capacity of the system cache in the storage volume satisfies a reservation condition.
[0145] In some embodiments, the system cache processing device further includes:
[0146] The advance quantity determination unit is used to determine whether the number of system cache tasks that have been advanced by the task scheduling queue within a preset time period is greater than a preset value; if so, the queue holding unit is triggered; if not, the foreground task advance unit is triggered;
[0147] The holding queue unit is used to hold the system cache task at the end of the task scheduling queue.
[0148] For the description of the features of the system cache processing device provided in the embodiment of the present invention, reference may be made to the relevant description of the embodiment of the system cache processing method, which will not be described in detail here.
[0149] See also Figure 5 As shown, Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device comprises: a memory 60, for storing a computer program;
[0150] The processor 61 is used to implement the steps of the system cache processing method in the above embodiment when executing a computer program.
[0151] The electronic device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.
[0152] Among them, the processor 61 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 61 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 61 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0153] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 60 is at least used to store the following computer program 601, wherein, after the computer program is loaded and executed by the processor 61, it can implement the relevant steps of the system cache processing method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 60 may also include an operating system 602 and data 603, etc., and the storage method may be short-term storage or permanent storage. Among them, the operating system 602 may include Windows, Unix, Linux, etc. The data 603 may include, but is not limited to, data in the system cache processing method, etc.
[0154] In some embodiments, the electronic device may further include a display screen 62 , an input / output interface 63 , a communication interface 64 , a power supply 65 , and a communication bus 66 .
[0155] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure.
[0156] For the description of the features in the electronic device provided by the embodiment of the present invention, reference may be made to the relevant description of the embodiment of the system cache processing method, which will not be described in detail here.
[0157] It is understandable that if the system cache processing method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the current technology or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and executes all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk and other media that can store program codes.
[0158] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the system cache processing method described above are implemented.
[0159] For the description of the features in the computer-readable storage medium provided in the embodiment of the present invention, reference may be made to the relevant description of the embodiment of the system cache processing method, which will not be described in detail here.
[0160] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the system cache processing method described in the above embodiment when executed by a processor.
[0161] For descriptions of features in the computer program product provided by the embodiments of the present invention, reference may be made to the relevant descriptions of the embodiments of the system cache processing method, which will not be described in detail here.
[0162] The above is a detailed introduction to a system cache processing method provided by an embodiment of the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0163] 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 composition and steps of each example have been generally described in the above description according to function. 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 to be beyond the scope of the present invention.
[0164] The above is a detailed introduction to a system cache processing method, device, electronic device and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A system cache processing method, characterized in that: include: When a storage volume in the computer receives a system cache task to be processed, determining whether the amount of tasks in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold; If not, adding the system cache task to the task scheduling queue of the current processing core; If so, traverse all processing cores in the computer to determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; the second preset threshold is less than the first preset threshold; The system cache task is added to the task scheduling queue of the target processing core.
2. The system cache processing method according to claim 1, characterized in that: The system cache task includes a foreground task and a background task, and the system cache processing method further includes: If the system cache task is a background task, determining whether the processing time of the background task is greater than a preset duration; If yes, the background task is divided into a plurality of system cache subtasks according to the time sequence, and the plurality of system cache subtasks are sequentially allocated to the storage volume.
3. The system cache processing method according to claim 1, characterized in that: Also includes: Build the computer's storage space into a preset number of storage volumes; Selecting a preset number of processing cores from among all processing cores of the computer; Allocating the preset number of processing cores to the preset number of storage volumes in a one-to-one correspondence; Recording the allocated one-to-one corresponding core number of the processing core and the volume number of the storage volume to a preset location to complete the binding of the storage volume and the processing core; The step of adding the system cache task to the task scheduling queue of the target processing core includes: Determining a core number of the target processing core; Modify the core number of the processing core corresponding to the volume number of the storage volume in the preset position from the core number of the current processing core to the core number of the target processing core, so as to complete the binding of the storage volume with the target processing core; The system cache task received by the storage volume is added to the task scheduling queue of the target processing core based on the bound storage volume and the target processing core.
4. The system cache processing method according to any one of claims 1 to 3, characterized in that: The system cache task includes a foreground task and a background task, and the system cache processing method further includes: If the system cache task is a foreground task, determining whether all the task scheduling queues of the processing core to which the system cache task is added are background tasks; If so, the system cache task is advanced to the front of the task scheduling queue.
5. The system cache processing method according to claim 4, characterized in that: Before the system cache task is advanced to the front of the task scheduling queue, the method further includes: Determining whether the remaining capacity of the system cache in the storage volume meets the reservation condition; If yes, jump to the step of advancing the system cache task to the front of the task scheduling queue; If not, then select a number of background tasks in the task scheduling queue of the processing core to which the system cache task is added, and advance the selected number of background tasks to the front of the task scheduling queue in a preset order.
6. The system cache processing method according to claim 5, characterized in that: The determining whether the remaining capacity of the system cache in the storage volume meets the reservation condition includes: Calculating whether the ratio of background tasks to foreground tasks in the task scheduling queue of the processing core currently bound to the storage volume is greater than a third preset threshold; If so, determining that the remaining capacity of the system cache in the storage volume does not meet the reservation condition; If not, it is determined that the remaining capacity of the system cache in the storage volume meets the reservation condition.
7. The system cache processing method according to claim 4, characterized in that: Before the system cache task is advanced to the front of the task scheduling queue, the method further includes: Determine whether the number of system cache tasks that have been advanced in the task scheduling queue within a preset time period is greater than a preset value; If yes, keep the system cache task at the end of the task scheduling queue; If not, jump to the step of advancing the system cache task to the front of the task scheduling queue.
8. A system cache processing device, characterized in that: include: A task volume determination unit is used to determine whether the task volume in the task scheduling queue of the current processing core bound to the storage volume reaches a first preset threshold when the storage volume in the computer receives a system cache task to be processed; if not, trigger the first queuing unit; If so, the traversal unit is triggered; The first queuing unit is used to add the system cache task to the task scheduling queue of the current processing core; The traversal unit is used to traverse all processing cores in the computer and determine a target processing core whose task amount in the task scheduling queue is less than a second preset threshold; The second preset threshold is less than the first preset threshold; The second queuing unit is used to add the system cache task to the task scheduling queue of the target processing core.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the system cache processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the system cache processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Hard disk IO flow control method and device of distributed storage system, equipment and medium
CN119987675A
Hard disk IO flow control method, device and equipment of distributed storage system and medium
CN119987675B
GPU (Graphic Processing Unit) task creation system and method, graphics processing unit and electronic equipment
CN120909745A
