A method, apparatus, device and medium for flow control of a data buffer

By calculating the rate of change of the number of dirty pages in the data buffer and the latency, the flow control strategy is dynamically adjusted, which solves the performance jitter problem of the database when the data volume is large and ensures the stable operation of the database.

CN119829620BActive Publication Date: 2025-11-11SHENZHEN INST OF COMPUTING SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411985349.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-11-11
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

When the data volume is too large, the database business performance will experience periodic and severe fluctuations, mainly due to the exhaustion of data page cache resources, which leads to business blockage and a sudden decrease in performance.

Method used

By obtaining the number of dirty pages and the rate of change of the number of dirty pages in the data buffer, the target flow control policy and latency are calculated, and the flow control of the data buffer is dynamically adjusted to stabilize the number of dirty pages and avoid resource exhaustion.

Benefits of technology

This ensures the stability of the data buffer, preventing performance fluctuations caused by excessive business pressure and maintaining the stability of database performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829620B_ABST
    Figure CN119829620B_ABST
Patent Text Reader

Abstract

This invention relates to the field of data flow control technology, and more particularly to a method, apparatus, device, and medium for flow control of a data buffer. Based on the number of first dirty pages at the previous time step, the number of second dirty pages at the current time step, the rate of change of the number of dirty pages at the previous time step, and the rate of change of the number of dirty pages at the current time step, the target flow control delay for the current time step is calculated. The flow of the data buffer is controlled according to the target flow control delay. Based on the amount of dirty page data and the rate of change of the number of dirty pages at adjacent time steps, a target flow control strategy for the database buffer is determined. Based on the target flow control strategy, the target flow control delay for the current time step is calculated. The flow of the data buffer is controlled according to the target flow control delay. By periodically calculating the buffer flow control delay, the data buffer automatically and dynamically adjusts the buffer allocation delay according to business pressure, thereby avoiding performance fluctuations caused by buffer exhaustion due to excessive business pressure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data flow control technology, and in particular to a method, apparatus, device and medium for flow control of a data buffer. Background Technology

[0002] When a database is running business operations, performance instability can occur due to insufficient resources and intense competition under high business pressure. Session rate limiting is typically used to address this issue, limiting the maximum number of sessions to prevent resource contention bottlenecks between modules and avoid database performance fluctuations. However, when batch business data volumes are large and dirty pages are generated very quickly, if the database's dirty page flushing capacity cannot keep up with the rate of dirty page generation, the database may run out of data page cache resources. When processing business data, the database needs to request data page cache resources. When these resources are exhausted, it must wait for the database persistence mechanism to process dirty pages, during which time the business is blocked, causing business performance to suddenly drop to zero. After a batch of dirty pages is flushed to disk, releasing the corresponding data page cache resources, business performance begins to recover. Then, the data page cache resources are gradually exhausted again, and database business performance drops sharply once more, repeating this cycle, resulting in periodic and severe fluctuations in database business performance. Therefore, how to implement flow control for data page cache resources to avoid database performance fluctuations when dealing with large amounts of data becomes a critical problem that needs to be solved. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a flow control method, apparatus, device and medium for a data buffer to solve the problem of periodic and severe fluctuations in database business performance when the data volume is too large.

[0004] In a first aspect, embodiments of the present invention provide a flow control method for a data buffer, the flow control method comprising:

[0005] Obtain the number of the first dirty pages in the data buffer at the previous time step and the number of the second dirty pages in the data buffer at the current time step. Calculate the rate of change of the current dirty page count at the current time step based on the number of the first dirty pages and the number of the second dirty pages.

[0006] Obtain the rate of change of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages.

[0007] Obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control policy, the current dirty page number change rate, and the flow control delay, and control the flow of the data buffer based on the target flow control delay.

[0008] In a second aspect, embodiments of the present invention provide a flow control device for a data buffer, the flow control device comprising:

[0009] The calculation module is used to obtain the number of the first dirty pages in the data buffer at the previous time and the number of the second dirty pages in the data buffer at the current time, and calculate the change rate of the current dirty page count at the current time based on the number of the first dirty pages and the number of the second dirty pages.

[0010] The determination module is used to obtain the rate of change of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages.

[0011] The control module is used to obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control strategy, the current dirty page number change rate and the flow control delay, and control the flow of the data buffer according to the target flow control delay.

[0012] Thirdly, embodiments of the present invention provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the flow control method as described in the first aspect.

[0013] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the flow control method as described in the first aspect.

[0014] The advantages of this invention compared to the prior art are:

[0015] The process involves obtaining the number of the first dirty pages in the data buffer at the previous time step and the number of the second dirty pages in the data buffer at the current time step. Based on these numbers, the rate of change of the current dirty page count is calculated. The rate of change of the dirty page count at the previous time step is also obtained. Based on the first dirty page count, the second dirty page count, the rate of change of the dirty page count, and the current rate of change of the dirty page count, a target flow control strategy is determined. The flow control delay of the data buffer at the previous time step is obtained. Based on the target flow control strategy, the current rate of change of the dirty page count, and the flow control delay, the target flow control delay at the current time step is calculated. The flow of the data buffer is then controlled based on the target flow control delay. In this application, the target flow control strategy for the database buffer is determined based on the amount of dirty page data and the rate of change of the dirty page count at adjacent time steps. The target flow control delay at the current time step is calculated based on the target flow control strategy. The flow of the data buffer is then controlled based on the target flow control delay. By periodically calculating the buffer flow control delay, the data buffer automatically and dynamically adjusts the buffer allocation delay according to business pressure, thereby avoiding performance fluctuations caused by buffer exhaustion due to excessive business pressure. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a flowchart illustrating a flow control method for a data buffer provided in Embodiment 1 of the present invention;

[0018] Figure 2 This is a structural block diagram of a data buffer flow control device provided in Embodiment 2 of the present invention;

[0019] Figure 3 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, circuits, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.

[0022] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0023] It should also be understood that the term “and / or” as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0024] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0025] Furthermore, in the description of this invention and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0026] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of the invention include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0027] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0028] To illustrate the technical solution of the present invention, specific embodiments are described below.

[0029] See Figure 1 This is a flowchart illustrating a flow control method for a data buffer provided in Embodiment 1 of the present invention, as shown below. Figure 1 As shown, the flow control method for the data buffer may include the following steps.

[0030] S101: Obtain the number of the first dirty pages in the data buffer at the previous time step and the number of the second dirty pages in the data buffer at the current time step. Based on the number of the first dirty pages and the number of the second dirty pages, calculate the rate of change of the current number of dirty pages at the current time step.

[0031] In step S101, the number of the first dirty pages in the data buffer at the previous time and the number of the second dirty pages in the data buffer at the current time are obtained, that is, the number of dirty pages at adjacent time. Based on the number of the first dirty pages and the number of the second dirty pages, the change rate of the current dirty page number at the current time is calculated. The change rate of the current dirty page number is used to determine the trend of the change of the dirty page number so as to perform different controls according to different trends.

[0032] In this embodiment, dirty pages in the database are linked on a list, and the database data buffer manages this dirty page list. The database backend flushes dirty pages to disk, releasing the data buffer memory resources they occupy. By periodically monitoring the health status of the data buffer, the current business pressure on its usage can be reflected. Therefore, the usage of resources in the data buffer is monitored, obtaining the number of the first dirty pages in the data buffer at the previous moment and the number of the second dirty pages at the current moment. Based on these two numbers, the rate of change of the current number of dirty pages is calculated, and the flow of traffic to the data buffer is controlled according to this rate of change to ensure its stability.

[0033] It should be noted that the formula for calculating the rate of change of the current dirty page count at the current moment, based on the first dirty page count and the second dirty page count, is as follows:

[0034]

[0035] in, This represents the rate of change in the number of dirty pages. This refers to the number of the second dirty pages. This represents the number of the first dirty pages.

[0036] In this embodiment, the change rate of the current dirty page number at the current moment is calculated based on the first dirty page number and the second dirty page number. The change rate of the current dirty page number represents the trend of the change of the dirty page number at the current moment compared with the dirty page number at the previous moment, so as to carry out different controls according to different trends.

[0037] S102: Obtain the rate of change of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the number of the first dirty pages, the number of the second dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages.

[0038] In step S102, the rate of change of the number of dirty pages in the data buffer at the previous time step is obtained. The rate of change of the number of dirty pages in the data buffer at the previous time step is the trend of the number of the first dirty pages in the data buffer at the previous time step compared with the number of dirty pages in the data buffer at the previous time step. Based on the number of the first dirty pages, the number of the second dirty pages, the rate of change of the number of dirty pages and the current rate of change of the number of dirty pages, a target flow control strategy is determined. The target flow control strategy is a strategy for controlling the flow in and out of the data buffer.

[0039] In this embodiment, the rate of change of the number of dirty pages in the data buffer at the previous time step is obtained. This rate of change can be calculated based on the number of the first dirty pages in the data buffer at the previous time step and the number of dirty pages in the data buffer at the time step preceding the previous time step. A target flow control strategy is determined based on the number of the first dirty pages, the number of the second dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages. Different flow control strategies correspond to different numbers of dirty pages, different rates of change of the first dirty pages, different rates of change of the number of dirty pages, and different rates of change of the current number of dirty pages.

[0040] For example, when the number of the second dirty pages is greater than the number of the first dirty pages, and the rate of change of the current number of dirty pages is greater than the rate of change of the current number of dirty pages, meaning that the number of dirty pages has increased compared to the previous time, and the increase in the number of dirty pages at the current time is greater than the increase in the number of dirty pages at the previous time, the trend of the number of dirty pages in the data buffer is a continuous increase, and the rate of increase is accelerating. In this case, flow control should be implemented on the data buffer to prevent more dirty pages from entering the data buffer, causing excessive resource pressure on the data buffer and degrading database performance. The target flow control strategy could be to reduce the number of dirty pages entering the data buffer per unit time, ensuring that the memory resources corresponding to the number of dirty pages entering the data buffer per unit time are less than the resources released by the data buffer per unit time, thereby continuously reducing the resource pressure on the data buffer. Alternatively, dirty pages could be delayed from entering the data buffer to reduce the resource pressure on the data buffer.

[0041] When the number of the second dirty pages is greater than the number of the first dirty pages, and the rate of change of the current number of dirty pages is not greater than the rate of change of the number of dirty pages, meaning that the number of dirty pages has increased compared to the previous time step, and the increase in the number of dirty pages at the current time step is less than the increase in the number of dirty pages at the previous time step, indicating that the number of dirty pages in the data buffer is increasing but at a slower rate, flow control is needed to prevent more dirty pages from entering the data buffer, which would put excessive pressure on the data buffer resources and reduce database performance. The target flow control strategy could be to reduce the number of dirty pages entering the data buffer per unit time, ensuring that the memory resources corresponding to the number of dirty pages entering the data buffer per unit time are less than the resources released by the data buffer per unit time, thereby continuously reducing the pressure on the data buffer resources. Alternatively, dirty pages could be delayed before entering the data buffer to reduce the resource pressure on the data buffer.

[0042] When the number of second dirty pages is no greater than the number of first dirty pages, meaning the number of dirty pages has decreased compared to the previous time, and the trend of the number of dirty pages in the data buffer is continuously decreasing, if the decreasing trend is significant, the target flow control strategy can be to not control the flow to the data buffer. If the decreasing trend becomes smaller and smaller, and the data buffer still experiences corresponding resource pressure, the target flow control strategy can be to reduce the number of dirty pages entering the data buffer per unit time, ensuring that the memory resources corresponding to the number of dirty pages entering the data buffer per unit time are less than the resources released by the data buffer per unit time, thereby continuously reducing the resource pressure on the data buffer. Alternatively, dirty pages can be delayed before entering the data buffer to reduce the resource pressure on the data buffer.

[0043] In this embodiment, a target flow control strategy is determined based on the number of first dirty pages, the number of second dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages. This allows the flow of the data buffer to be controlled according to the corresponding target flow control strategy, ensuring that the data buffer can always maintain the corresponding stability.

[0044] Optionally, a target flow control strategy is determined based on the number of first dirty pages, the number of second dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages, including:

[0045] When the number of the second dirty pages is greater than the number of the first dirty pages and the rate of change of the current number of dirty pages is greater than the rate of change of the number of dirty pages, the preset first flow control strategy is determined as the target flow control strategy.

[0046] When the number of the second dirty pages is greater than the number of the first dirty pages and the current rate of change of the number of dirty pages is not greater than the rate of change of the number of dirty pages, the preset second flow control strategy is determined as the target flow control strategy.

[0047] When the number of second dirty pages is not greater than the number of first dirty pages, the preset third flow control strategy is determined as the target flow control strategy.

[0048] In this embodiment, when the number of second dirty pages is greater than the number of first dirty pages, and the rate of change of the current number of dirty pages is greater than the rate of change of the number of dirty pages, that is, when the number of dirty pages has increased compared to the previous time, and the increase in the number of dirty pages at the current time is greater than the increase in the number of dirty pages at the previous time, the trend of the number of dirty pages in the data buffer is a continuous increase, and the rate of increase is accelerating. A preset first flow control strategy is determined as the target flow control strategy. This preset first flow control strategy controls dirty pages to enter the data buffer with a delay. The delay time can be a preset fixed time or a dynamically set time; this embodiment does not limit this. That is, dirty pages are controlled to enter the data buffer within the corresponding delay period to reduce the resource pressure on the data buffer.

[0049] It should be noted that the delay in the entry of dirty pages into the data buffer is controlled, and the delay time is a continuously increasing trend. That is, when the number of the second dirty pages is greater than the number of the first dirty pages, and the rate of change of the current number of dirty pages is not greater than the rate of change of the current number of dirty pages, the corresponding delay time is increased, so that the delay time at the current moment is greater than the delay time at the previous moment.

[0050] When the number of second dirty pages is greater than the number of first dirty pages, and the rate of change of the current number of dirty pages is not greater than the rate of change of the number of dirty pages, that is, the number of dirty pages has increased compared to the previous time, and the increase in the number of dirty pages at the current time is less than the increase in the number of dirty pages at the previous time. In other words, the trend of the number of dirty pages in the data buffer is a continuous increase, and the rate of increase is getting slower and slower. A preset second flow control strategy is determined as the target flow control strategy. The preset second flow control strategy controls dirty pages to enter the data buffer with a delay. The delay time can be a preset fixed time or a dynamically set time; this embodiment does not limit this. That is, dirty pages are controlled to enter the data buffer within the corresponding delay period to reduce the resource pressure on the data buffer.

[0051] It should be noted that the delay time for dirty pages to enter the data buffer does not need to be increased. That is, when the number of the second dirty pages is greater than the number of the first dirty pages, and the rate of change of the current number of dirty pages is not greater than the rate of change of the current number of dirty pages, the delay time does not need to be increased. The delay time at the current moment does not need to be greater than the delay time at the previous moment.

[0052] When the number of second dirty pages is no greater than the number of first dirty pages, meaning the number of dirty pages has decreased compared to the previous time, and the trend of the number of dirty pages in the data buffer is continuously decreasing, the preset third flow control strategy is determined as the target flow control strategy. The preset third flow control strategy either delays the entry of dirty pages into the data buffer or disables flow control on the data buffer. That is, if the decreasing trend is significant, the target flow control strategy can be to disable flow control on the data buffer. If the decreasing trend becomes smaller and smaller, but the data buffer still experiences corresponding resource pressure, the target flow control strategy can delay the entry of dirty pages into the data buffer.

[0053] It should be noted that the delay in the entry of dirty pages into the data buffer is controlled, and the delay time has a continuously decreasing trend. That is, when the number of second dirty pages is not greater than the number of first dirty pages, the delay time at the current moment is less than the delay time at the previous moment.

[0054] S103: Obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control policy, the current rate of change of dirty pages, and the flow control delay, and control the flow of the data buffer based on the target flow control delay.

[0055] In step S103, the flow control delay of the data buffer at the previous time step is calculated based on the number of dirty pages corresponding to the previous time step. The target flow control delay at the current time step is calculated based on the target flow control strategy, the current rate of change of the number of dirty pages, and the flow control delay. The target flow control delay is the delay time for dirty pages to enter the data buffer at the current time step. The flow of the data buffer is controlled according to the target flow control delay.

[0056] In this embodiment, the flow control delay of the data buffer at the previous time step is obtained. Based on the target flow control policy, the current dirty page count change rate, and the flow control delay, the target flow control delay at the current time step is calculated. That is, based on the flow control delay of the data buffer at the previous time step, the target flow control policy determines whether to increase, decrease, or leave the flow control delay unchanged. After calculating the target flow control delay at the current time step, the flow of the data buffer is controlled according to the target flow control delay.

[0057] In this embodiment, the target flow control delay is calculated based on the target flow control strategy, the current rate of change of dirty pages, and the flow control delay. This allows for automatic adjustment of the flow control in the data buffer based on the target flow control delay, ensuring that dirty pages enter the data buffer only after the corresponding time of the target flow control delay, thus maintaining a stable number of dirty pages in the data buffer. This adaptive adjustment based on the target flow control delay resolves the problem of severe database performance fluctuations caused by data buffer resource bottlenecks.

[0058] Optionally, the target flow control delay at the current moment is calculated based on the target flow control policy, the current rate of change of dirty pages, and the flow control delay, including:

[0059] When the target flow control strategy is the first flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page change rate and flow control delay, combined with the preset first calculation strategy.

[0060] In this embodiment, when the target flow control strategy is the first flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page count change rate and flow control delay, combined with a preset first calculation strategy. The calculation formula corresponding to the first calculation strategy is as follows:

[0061]

[0062] in, The target flow control delay at the current moment when the target flow control policy is the first flow control policy. The flow control delay is for the data buffer from the previous time step. This represents the absolute value of the rate of change in the current number of dirty pages. This is the latency calculation factor. The latency calculation factor can be determined based on the data cache's flushing speed of dirty pages to disk.

[0063] In this embodiment, when the target flow control strategy is the first flow control strategy, a corresponding delay duration is added to the flow control delay of the previous moment. The added delay duration is related to the current rate of change of the number of dirty pages. That is, based on the rate of change of the number of dirty pages in adjacent moments, a larger rate of change of the current number of dirty pages results in a larger added delay duration, and a smaller rate of change of the current number of dirty pages results in a smaller added delay duration. This allows the delay duration for controlling the data buffer flow to be automatically adjusted according to the current rate of change of the number of dirty pages, thereby improving the rationality and accuracy of the target flow control delay. The corresponding delay duration is dynamically allocated to the data buffer according to the target flow control delay, thus avoiding performance fluctuations caused by the exhaustion of the data buffer due to excessive business pressure.

[0064] Optionally, the target flow control delay at the current moment is calculated based on the target flow control policy, the current rate of change of dirty pages, and the flow control delay, and further includes:

[0065] When the target flow control strategy is the second flow control strategy, the target flow control delay at the current moment is calculated based on the flow control delay and the preset first calculation strategy.

[0066] In this embodiment, when the target flow control strategy is the second flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page count change rate and flow control delay, combined with a preset second calculation strategy. The calculation formula corresponding to the second calculation strategy is as follows:

[0067]

[0068] in, The target flow control delay at the current moment when the target flow control policy is the first flow control policy. The flow control delay is for the data buffer from the previous time step. This represents the rate of change in the current number of dirty pages.

[0069] In this embodiment, when the target flow control strategy is the second flow control strategy, that is, when the number of second dirty pages is greater than the number of first dirty pages and the current rate of change of the number of dirty pages is not greater than the rate of change of the number of dirty pages, the corresponding delay duration is not changed, and the flow control delay of the previous moment is used as the target flow control delay of the current moment.

[0070] Optionally, the target flow control delay at the current moment is calculated based on the target flow control policy, the current rate of change of dirty pages, and the flow control delay, and further includes:

[0071] When the target flow control strategy is the third flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page number change rate and flow control delay, combined with the preset third calculation strategy.

[0072] In this embodiment, when the target flow control strategy is the third flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page count change rate and flow control delay, combined with a preset third calculation strategy. The calculation formula corresponding to the third calculation strategy is as follows:

[0073]

[0074] in, The target flow control delay at the current moment when the target flow control policy is the first flow control policy. The flow control delay is for the data buffer from the previous time step. This represents the absolute value of the rate of change in the current number of dirty pages. This is the latency calculation factor. The latency calculation factor can be determined based on the data cache's flushing speed of dirty pages to disk.

[0075] In this embodiment, when the target flow control strategy is the third flow control strategy, the corresponding delay duration is reduced based on the flow control delay of the previous moment. The reduced delay duration is related to the current rate of change of the number of dirty pages; that is, based on the rate of change of the number of dirty pages in adjacent moments, a larger rate of change in the number of dirty pages results in a larger reduction in delay duration, and a smaller rate of change in the number of dirty pages results in a smaller reduction in delay duration. This allows the delay duration for controlling the data buffer flow to be automatically adjusted according to the current rate of change of the number of dirty pages, thereby improving the rationality and accuracy of the target flow control delay. Dynamically allocating the corresponding delay duration to the data buffer based on the target flow control delay avoids performance fluctuations caused by the data buffer being exhausted due to excessive business pressure.

[0076] Optionally, the flow of the data buffer is controlled according to the target flow control delay, including:

[0077] Determine the magnitude of the target flow control delay. If the target flow control delay is greater than zero, then after the target flow control delay time, the control data buffer receives new dirty page data.

[0078] In this embodiment, the magnitude of the target flow control delay is determined. If the target flow control delay is greater than zero, the flow of the data buffer needs to be delayed. After the target flow control delay time, the data buffer is controlled to receive new dirty page data.

[0079] Optionally, after determining the magnitude of the target flow control delay, the method further includes:

[0080] If the target flow control delay is not greater than zero, then flow control on the data buffer is disabled.

[0081] In this embodiment, after determining the magnitude of the target flow control delay, if the target flow control delay is not greater than zero, then flow control on the data buffer is disabled. For example, if the number of second dirty pages is not greater than the number of first dirty pages, and the flow control delay minus the product of the current dirty page number change rate and the delay calculation factor results in a situation where the target flow control delay is less than zero, then flow control on the data buffer is disabled.

[0082] It should be noted that when the number of the second dirty pages is no greater than the number of the first dirty pages, the calculated target flow control latency may not be greater than zero. When the number of the second dirty pages is no greater than the number of the first dirty pages, it is assumed that the number of dirty pages in the data buffer is continuously decreasing. If the number of dirty pages decreases significantly, the memory resources occupied in the data buffer are less. In this case, the data buffer receiving new dirty page data has no impact on database performance. Therefore, flow control for the data buffer can be disabled.

[0083] The process involves obtaining the number of the first dirty pages in the data buffer at the previous time step and the number of the second dirty pages in the data buffer at the current time step. Based on these numbers, the rate of change of the current dirty page count is calculated. The rate of change of the dirty page count at the previous time step is also obtained. Based on the first dirty page count, the second dirty page count, the rate of change of the dirty page count, and the current rate of change of the dirty page count, a target flow control strategy is determined. The flow control delay of the data buffer at the previous time step is obtained. Based on the target flow control strategy, the current rate of change of the dirty page count, and the flow control delay, the target flow control delay at the current time step is calculated. The flow of the data buffer is then controlled based on the target flow control delay. In this application, the target flow control strategy for the database buffer is determined based on the amount of dirty page data and the rate of change of the dirty page count at adjacent time steps. The target flow control delay at the current time step is calculated based on the target flow control strategy. The flow of the data buffer is then controlled based on the target flow control delay. By periodically calculating the buffer flow control delay, the data buffer automatically and dynamically adjusts the buffer allocation delay according to business pressure, thereby avoiding performance fluctuations caused by buffer exhaustion due to excessive business pressure.

[0084] See Figure 2 , Figure 2 This is a structural block diagram of a data buffer flow control device according to Embodiment 2 of the present invention. For ease of explanation, only the parts related to the embodiments of this application are shown. See also Figure 2 The flow control device 20 includes a calculation module 21, a determination module 22, and a control module 23.

[0085] The calculation module 21 is used to obtain the number of the first dirty pages in the data buffer at the previous time and the number of the second dirty pages in the data buffer at the current time, and calculate the change rate of the current dirty page count at the current time based on the number of the first dirty pages and the number of the second dirty pages.

[0086] The determination module 22 is used to obtain the change rate of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the number of the first dirty pages, the number of the second dirty pages, the change rate of the number of dirty pages and the current change rate of the number of dirty pages.

[0087] The control module 23 is used to obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control strategy, the current dirty page number change rate and the flow control delay, and control the flow of the data buffer based on the target flow control delay.

[0088] Optionally, the determining module 22 includes:

[0089] The first determining unit is used to determine the preset first flow control strategy as the target flow control strategy when the number of second dirty pages is greater than the number of first dirty pages and the current rate of change of the number of dirty pages is greater than the rate of change of the number of dirty pages.

[0090] The second determining unit is used to determine the preset second flow control strategy as the target flow control strategy when the number of second dirty pages is greater than the number of first dirty pages and the current rate of change of the number of dirty pages is not greater than the rate of change of the number of dirty pages.

[0091] The third determining unit is used to determine the preset third flow control strategy as the target flow control strategy when the number of second dirty pages is not greater than the number of first dirty pages.

[0092] Optionally, the control module 23 includes:

[0093] The first calculation unit is used to calculate the target flow control delay at the current moment based on the current dirty page quantity change rate and flow control delay, combined with the preset first calculation strategy, when the target flow control strategy is the first flow control strategy.

[0094] Optionally, the control module 23 includes:

[0095] The second calculation unit is used to calculate the target flow control delay at the current moment based on the flow control delay and in combination with the preset first calculation strategy when the target flow control strategy is the second flow control strategy.

[0096] Optionally, the control module 23 includes:

[0097] The third calculation unit is used to calculate the target flow control delay at the current moment based on the current dirty page quantity change rate and flow control delay, combined with the preset third calculation strategy, when the target flow control strategy is the third flow control strategy.

[0098] Optionally, the control module 23 includes:

[0099] The control unit is used to determine the magnitude of the target flow control delay. If the target flow control delay is greater than zero, the control data buffer receives new dirty page data after the target flow control delay time.

[0100] Optionally, the control unit includes:

[0101] The shutdown unit is used to disable flow control on the data buffer if the target flow control delay is not greater than zero.

[0102] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.

[0103] Figure 3 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 3 As shown, the computer device of this embodiment includes: at least one processor ( Figure 3 Only one is shown in the diagram), a memory, and a computer program stored in the memory and executable on at least one processor, which, when executed by the processor, implements the steps in any of the above-described flow control embodiments.

[0104] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 3 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown in the illustration, or combinations of certain components, or different components, such as network interfaces, displays, and input devices.

[0105] The processor referred to can be a CPU, but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0106] Memory includes readable storage media, internal memory, etc., wherein internal memory can be the RAM of a computer device, providing an environment for the operation of the operating system and computer-readable instructions stored in the readable storage media. The readable storage media can be the hard drive of a computer device, or in other embodiments, it can be an external storage device of the computer device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, memory can include both internal storage units and external storage devices of the computer device. Memory is used to store the operating system, applications, bootloader, data, and other programs, such as program code for computer programs. Memory can also be used to temporarily store data that has been output or will be output.

[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above device can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. If the integrated unit is implemented as 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, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code, a recording medium, a computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0108] The implementation of all or part of the processes in the methods of the above embodiments can also be accomplished by a computer program product. When the computer program product is run on a computer device, it enables the computer device to execute the steps in the above method embodiments.

[0109] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0110] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0111] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0112] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0113] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A flow control method for a data buffer, characterized in that, The flow control method includes: Obtain the number of the first dirty pages in the data buffer at the previous time step and the number of the second dirty pages in the data buffer at the current time step. Calculate the rate of change of the current dirty page count at the current time step based on the number of the first dirty pages and the number of the second dirty pages. Obtain the rate of change of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages. Obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control policy, the current dirty page number change rate, and the flow control delay, and control the flow of the data buffer based on the target flow control delay.

2. The flow control method as described in claim 1, characterized in that, The step of determining the target flow control strategy based on the first dirty page count, the second dirty page count, the rate of change of the dirty page count, and the current rate of change of the dirty page count includes: When the number of the second dirty pages is greater than the number of the first dirty pages and the rate of change of the current dirty page number is greater than the rate of change of the dirty page number, the preset first flow control strategy is determined as the target flow control strategy. When the number of the second dirty pages is greater than the number of the first dirty pages and the rate of change of the current dirty page number is not greater than the rate of change of the dirty page number, the preset second flow control strategy is determined as the target flow control strategy. When the number of the second dirty pages is not greater than the number of the first dirty pages, the preset third flow control strategy is determined as the target flow control strategy.

3. The flow control method as described in claim 2, characterized in that, The step of calculating the target flow control delay at the current moment based on the target flow control strategy, the current rate of change of dirty page count, and the flow control delay includes: When the target flow control strategy is the first flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page number change rate and the flow control delay, combined with the preset first calculation strategy.

4. The flow control method as described in claim 2, characterized in that, The step of calculating the target flow control delay at the current moment based on the target flow control strategy, the current dirty page quantity change rate, and the flow control delay further includes: When the target flow control strategy is the second flow control strategy, the target flow control delay at the current time is calculated based on the flow control delay and in conjunction with the preset first calculation strategy.

5. The flow control method as described in claim 2, characterized in that, The step of calculating the target flow control delay at the current moment based on the target flow control strategy, the current dirty page quantity change rate, and the flow control delay further includes: When the target flow control strategy is the third flow control strategy, the target flow control delay at the current moment is calculated based on the current dirty page number change rate and the flow control delay, combined with the preset third calculation strategy.

6. The flow control method as described in claim 1, characterized in that, The step of controlling the flow of the data buffer based on the target flow control delay includes: Determine the magnitude of the target flow control delay. If the target flow control delay is greater than zero, then after the target flow control delay time, control the data buffer to receive new dirty page data.

7. The flow control method as described in claim 6, characterized in that, After determining the magnitude of the target flow control delay, the method further includes: If the target flow control delay is not greater than zero, then flow control on the data buffer is turned off.

8. A flow control device for a data buffer, characterized in that, The flow control device includes: The calculation module is used to obtain the number of the first dirty pages in the data buffer at the previous time and the number of the second dirty pages in the data buffer at the current time, and calculate the change rate of the current dirty page count at the current time based on the number of the first dirty pages and the number of the second dirty pages. The determination module is used to obtain the rate of change of the number of dirty pages in the data buffer at the previous moment, and determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the rate of change of the number of dirty pages, and the current rate of change of the number of dirty pages. The control module is used to obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment based on the target flow control strategy, the current dirty page number change rate and the flow control delay, and control the flow of the data buffer according to the target flow control delay.

9. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the flow control method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the flow control method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and server for buffer area management aiming at multiple tenants

    CN107025223A

  • State data cleaning method and device of substation equipment and computer equipment

    CN114238271A