Flow control method and device for data buffer, equipment and medium

By dynamically adjusting the flow control delay of the data buffer and determining the strategy based on the amount of dirty page data and the rate of change, the problem of business performance jitter in the database under high data volume is solved, and the stability and performance of the buffer are continuously optimized.

CN119829620AActive Publication Date: 2025-04-15SHENZHEN INST OF COMPUTING SCI
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When the data volume is too large, the performance of the database business will experience periodic and violent jitter, mainly due to the exhaustion of data page cache resources, which will cause the service to be blocked and the performance will be suddenly reduced.

Method used

By obtaining the amount of dirty page data and the change rate of the number of dirty pages at adjacent moments, the target flow control strategy is determined, the target flow control delay is calculated, and the flow of the data buffer is controlled according to the delay, and the buffer allocation delay is dynamically adjusted to avoid resource exhaustion.

Benefits of technology

It effectively avoids the exhaustion of data buffers due to excessive business pressure, solves the problem of database performance jitter, and realizes the stability of data buffers and continuous optimization of database performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829620A_ABST
    Figure CN119829620A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data flow control, in particular to a flow control method and device for a data buffer, equipment and a medium. According to the first dirty page number at the previous moment, the second dirty page number at the current moment, the dirty page number change rate at the previous moment and the current dirty page number change rate, target flow control delay at the current moment is obtained through calculation, and flow of the data buffer area is controlled according to the target flow control delay. The method comprises the steps of determining a target flow control strategy of a database buffer area according to dirty page data volume and dirty page quantity change rate at adjacent moments, calculating target flow control delay at the current moment according to the target flow control strategy, controlling flow of the data buffer area according to the target flow control delay, and controlling the flow of the data buffer area by calculating the flow control delay of the buffer area at regular time. And the data buffer area automatically and dynamically adjusts the buffer area distribution delay according to the service pressure, so that the condition of performance fluctuation caused by exhaustion of the buffer area due to overlarge service pressure is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data flow control, and in particular to a flow control method, device, equipment and medium for a data buffer. Background Art

[0002] When the database runs business, when the business pressure is high, there will be unstable performance due to insufficient resources and fierce competition. The session flow control mechanism is usually used to solve this problem. By limiting the upper limit of the session, the resource competition bottlenecks in each module are blocked to avoid database performance jitter. However, when the batch business data volume is large and dirty pages are generated very quickly, when the dirty page flushing capacity of the database cannot match the dirty page production speed, the database will be exhausted due to data page cache resources. When the database processes business, it needs to apply for data page cache resources. When the resources are exhausted, it needs to wait for the database persistence mechanism to process the dirty pages. At this time, the business is blocked, causing the business performance to suddenly drop to 0. After a batch of dirty pages are flushed to the disk and the corresponding data page cache resources are released, the business performance begins to recover. Then the data page cache resources are gradually exhausted, and the database business performance will suddenly drop again. This cycle repeats, showing that the database business performance periodically fluctuates violently. Therefore, when the data volume is too large, how to control the flow of data page cache resources to avoid database performance jitter has become an urgent problem to be solved. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a data buffer flow control method, device, equipment and medium to solve the problem of periodic and severe jitter of database service performance when the data volume is too large.

[0004] In a first aspect, an embodiment of the present invention provides a flow control method for a data buffer, the flow control method comprising: Obtaining the first number of dirty pages in the data buffer at a previous moment and the second number of dirty pages in the data buffer at a current moment, and calculating a change rate of the current number of dirty pages at a current moment according to the first number of dirty pages and the second number of dirty pages; Obtaining a change rate of the number of dirty pages in the data buffer at a previous moment, and determining a target flow control strategy according to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages, and the change rate of the current 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 according to the target flow control strategy, the current rate of change of the number of dirty pages and the flow control delay, and control the flow of the data buffer according to the target flow control delay.

[0005] In a second aspect, an embodiment of the present invention provides a flow control device for a data buffer, the flow control device comprising: A calculation module, used for obtaining the first number of dirty pages in the data buffer at a previous moment and the second number of dirty pages in the data buffer at a current moment, and calculating a change rate of the current number of dirty pages at a current moment according to the first number of dirty pages and the second number of dirty pages; A determination module, used for obtaining a change rate of the number of dirty pages in the data buffer at a previous moment, and determining a target flow control strategy according to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages, and the change rate of the current number of dirty pages; A 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 according to the target flow control strategy, the current rate of change of the number of dirty pages and the flow control delay, and control the flow of the data buffer according to the target flow control delay.

[0006] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the flow control method as described in the first aspect when executing the computer program.

[0007] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the flow control method as described in the first aspect is implemented.

[0008] Compared with the prior art, the present invention has the following beneficial effects: Obtain the first number of dirty pages in the data buffer at the previous moment and the second number of dirty pages in the data buffer at the current moment, calculate the change rate of the current number of dirty pages at the current moment based on the first number of dirty pages and the second number of dirty pages, obtain the change rate of the number of dirty pages in the data buffer at the previous moment, determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages and the change rate of the current 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 strategy, the change rate of the current number of dirty pages and the flow control delay, and control the flow of the data buffer based on the target flow control delay. In the present application, the target flow control strategy of the database buffer is determined based on the amount of dirty page data and the change rate of the number of dirty pages at adjacent moments, calculate the target flow control delay at the current moment based on the target flow control strategy, and control the flow of the data buffer based on the target flow control delay, and the data buffer automatically and dynamically adjusts the buffer allocation delay based on the business pressure by periodically calculating the buffer flow control delay, thereby avoiding the situation where the buffer is exhausted due to excessive business pressure and causes performance fluctuations. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0010] Figure 1 It is a flow chart of a method for controlling flow in a data buffer zone provided in the first embodiment of the present invention; Figure 2 It is a structural block diagram of a flow control device for a data buffer provided by Embodiment 2 of the present invention; Figure 3 It is a structural diagram of a computer device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0011] 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 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.

[0012] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, systems, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

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

[0014] It should also be understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

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

[0016] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0017] References to "one embodiment" or "some embodiments" etc. described in the present specification mean that one or more embodiments of the present invention include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0018] It should be understood that the order of execution of the steps in the following embodiments does not imply a precedence 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.

[0019] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.

[0020] See also Figure 1 , is a flow chart of a method for controlling flow of a data buffer provided in Embodiment 1 of the present invention, such as Figure 1 As shown, the flow control method of the data buffer may include the following steps.

[0021] S101: Obtain the number of first dirty pages in the data buffer at the previous moment and the number of second dirty pages in the data buffer at the current moment, and calculate the current dirty page number change rate at the current moment according to the first dirty page number and the second dirty page number.

[0022] In step S101, the first number of dirty pages in the data buffer at the previous moment and the second number of dirty pages in the data buffer at the current moment, that is, the number of dirty pages at adjacent moments, are obtained, and the current rate of change of the number of dirty pages at the current moment is calculated based on the first number of dirty pages and the second number of dirty pages, wherein the current rate of change of the number of dirty pages is used to determine the changing trend of the number of dirty pages, so as to perform different controls according to different changing trends.

[0023] In this embodiment, the dirty pages of the database are all hung on a linked list, and the database data buffer manages the dirty page linked list. The database background will flush the dirty pages to disk, and the dirty pages flushed to disk will release the occupied data buffer memory resources. By regularly monitoring the health status of the data buffer, the use of the data buffer by the current business pressure can be reflected. Therefore, the used resources in the data buffer are monitored, and the number of the first dirty pages in the data buffer at the previous moment and the number of the second dirty pages in the data buffer at the current moment are obtained. According to the number of the first dirty pages and the number of the second dirty pages, the change rate of the current number of dirty pages at the current moment is calculated, and the flow of the data buffer is controlled according to the change rate to ensure the stability of the data buffer.

[0024] It should be noted that, according to the first dirty page number and the second dirty page number, the calculation formula for calculating the change rate of the current dirty page number at the current moment is as follows: in, is the current rate of change of the number of dirty pages, is the number of second dirty pages, The number of the first dirty page.

[0025] In this embodiment, the current rate of change of the number of dirty pages at the current moment is calculated based on the first number of dirty pages and the second number of dirty pages, wherein the current rate of change of the number of dirty pages represents the changing trend of the number of dirty pages at the current moment compared with the number of dirty pages at the previous moment, so as to perform different controls according to different changing trends.

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

[0027] In step S102, the rate of change of the number of dirty pages in the data buffer at the previous moment is obtained, wherein the rate of change of the number of dirty pages in the data buffer at the previous moment is the change trend of the number of first dirty pages in the data buffer at the previous moment compared with the number of dirty pages in the data buffer at the moment before the previous moment, and the target flow control strategy is determined according to 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, wherein the target flow control strategy is a strategy for controlling the flow in and out of the data buffer.

[0028] In this embodiment, the change rate of the number of dirty pages in the data buffer at the last moment is obtained, wherein the change rate of the number of dirty pages in the data buffer at the last moment can be calculated based on the first number of dirty pages in the data buffer at the last moment and the number of dirty pages in the data buffer at the previous moment corresponding to the last moment. According to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages and the current change rate of the number of dirty pages, the target flow control strategy is determined, wherein the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages and the current change rate of the number of dirty pages are different, and the corresponding flow control strategy is different.

[0029] For example, when the second number of dirty pages is greater than the first number of 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, that is, the number of dirty pages has increased at the current moment compared to the previous moment, and the number of dirty pages increased at the current moment is greater than the number of dirty pages increased at the previous moment. That is, the change trend of the number of dirty pages in the data buffer is a trend of continuous increase, and the rate of increase is getting faster and faster. At this time, the data buffer is flow controlled to prevent more dirty pages from entering the data buffer, causing greater resource pressure on the data buffer and reducing database performance. The target flow control strategy can be to reduce the number of dirty pages entering the data buffer per unit time, so 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, so as to continuously reduce the resource pressure of the data buffer. Or control the dirty page delay to enter the data buffer to reduce the resource pressure of the data buffer.

[0030] When the second number of dirty pages is greater than the first number of 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, that is, the number of dirty pages has increased at the current moment compared to the previous moment, and the number of dirty pages increased at the current moment is less than the number of dirty pages increased at the previous moment. That is, the change trend of the number of dirty pages in the data buffer is a trend of continuous increase, and the increase rate is getting slower and slower. At this time, the data buffer is flow controlled to prevent more dirty pages from entering the data buffer, causing greater resource pressure on the data buffer and reducing database performance. The target flow control strategy can be to reduce the number of dirty pages entering the data buffer per unit time, so 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, so as to continuously reduce the resource pressure of the data buffer. Or control the dirty pages to enter the data buffer with a delay to reduce the resource pressure of the data buffer.

[0031] When the second number of dirty pages is not greater than the first number of dirty pages, that is, the number of dirty pages at the current moment is reduced compared to the previous moment, that is, the trend of the number of dirty pages in the data buffer is a decreasing trend. If the decreasing trend is large, the target flow control strategy may be not to control the flow of the data buffer. If the decreasing trend is getting smaller and smaller, and there is still corresponding resource pressure in the data buffer, the target flow control strategy may be to reduce the number of dirty pages entering the data buffer per unit time, so 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, so as to continuously reduce the data buffer resource pressure. Or control the dirty page delay to enter the data buffer to reduce the resource pressure of the data buffer.

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

[0033] Optionally, determining a target flow control strategy according to the first dirty page number, the second dirty page number, the dirty page number change rate, and the current dirty page number change rate includes: When the second number of dirty pages is greater than the first number of 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, determining the preset first flow control strategy as the target flow control strategy; When the second number of dirty pages is greater than the first number of 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, determining the preset second flow control strategy as the target flow control strategy; When the second dirty page quantity is not greater than the first dirty page quantity, the preset third flow control strategy is determined as the target flow control strategy.

[0034] In this embodiment, when the second number of dirty pages is greater than the first number of 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, that is, the number of dirty pages has increased at the current moment compared to the previous moment, and the number of dirty pages increased at the current moment is greater than the number of dirty pages increased at the previous moment. That is, the changing trend of the number of dirty pages in the data buffer is a trend of continuous increase, and the rate of increase is getting faster and faster. The preset first flow control strategy is determined as the target flow control strategy, wherein the preset first flow control strategy is to control the delay of dirty pages entering the data buffer, and the delay time can be a preset fixed time or a dynamically set time, which is not limited in this embodiment. That is, dirty pages are controlled to enter the data buffer within the corresponding delay period to reduce the resource pressure of the data buffer.

[0035] It should be noted that the delay of dirty pages entering the data buffer is controlled, and the delay time tends to increase continuously. That is, when the number of the second dirty pages is greater than the number of the first dirty pages and the change rate of the current number of dirty pages is not greater than the change rate of the 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.

[0036] When the second number of dirty pages is greater than the first number of 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, that is, the number of dirty pages has increased at the current moment compared to the previous moment, and the number of dirty pages increased at the current moment is less than the number of dirty pages increased at the previous moment. That is, the changing trend of the number of dirty pages in the data buffer is a trend of continuous increase, and the rate of increase is getting slower and slower. Determine the preset second flow control strategy as the target flow control strategy. Among them, the preset second flow control strategy is to control the delay of dirty pages entering the data buffer, and the delay time can be a preset fixed time or a dynamically set time, which is not limited in this embodiment. That is, dirty pages are controlled to enter the data buffer within the corresponding delay period to reduce the resource pressure of the data buffer.

[0037] It should be noted that the delay of dirty pages entering the data buffer is controlled, and the delay time does not need to continue to increase. That is, when the number of the second dirty pages is greater than the number of the first dirty pages and the change rate of the current number of dirty pages is not greater than the change rate of the number of dirty pages, there is no need to continue to increase the delay time, and the delay time at the current moment does not need to be greater than the delay time at the previous moment.

[0038] When the second number of dirty pages is not greater than the first number of dirty pages, that is, the number of dirty pages at the current moment is reduced compared to the previous moment, that is, the trend of the number of dirty pages in the data buffer is a decreasing trend, the preset third flow control strategy is determined as the target flow control strategy. Among them, the preset third flow control strategy is to control the delay of dirty pages entering the data buffer or to turn off the flow control of the data buffer. That is, if the decreasing trend is larger, the target flow control strategy can be to turn off the flow control of the data buffer. If the decreasing trend is getting smaller and smaller, and there is still corresponding resource pressure in the data buffer, the target flow control strategy can control the delay of dirty pages entering the data buffer.

[0039] It should be noted that the delay of controlling dirty pages to enter the data buffer is a 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.

[0040] S103: Obtain the flow control delay of the data buffer at the previous moment, calculate the target flow control delay at the current moment according to 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.

[0041] In step S103, the flow control delay of the data buffer at the previous moment is calculated based on the number of dirty pages at the previous moment corresponding to the previous moment. According to 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 at the current moment is calculated, wherein the target flow control delay is the delay time for the dirty page to enter the data buffer at the current moment. According to the target flow control delay, the flow of the data buffer is controlled.

[0042] In this embodiment, the flow control delay of the data buffer at the previous moment is obtained, and the target flow control delay at the current moment is calculated according to the target flow control strategy, the current dirty page number change rate and the flow control delay, that is, based on the flow control delay of the data buffer at the previous moment, it is determined whether to increase the delay, decrease the delay, or keep it unchanged based on the flow control delay of the data buffer at the previous moment according to the target flow control strategy. After calculating the target flow control delay at the current moment, the flow of the data buffer is controlled according to the target flow control delay.

[0043] In this embodiment, the target flow control delay at the current moment is calculated according to the target flow control strategy, the current rate of change of the number of dirty pages and the flow control delay, so that when the flow of the data buffer is controlled, it can be automatically adjusted according to the target flow control delay, and the dirty pages are controlled to enter the data buffer after the corresponding time of the target flow control delay, so that the number of dirty pages in the data buffer remains stable. Adaptive adjustment according to the target flow control delay solves the problem of severe jitter of database performance caused by the bottleneck of data buffer resources.

[0044] Optionally, the target flow control delay at the current moment is calculated according to the target flow control policy, the current dirty page quantity change rate and the flow control delay, including: When the target flow control strategy is the first flow control strategy, the target flow control delay at the current moment is calculated according to the current dirty page quantity change rate and the flow control delay in combination with the preset first calculation strategy.

[0045] 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 number change rate and the flow control delay, combined with the preset first calculation strategy. The calculation formula corresponding to the first calculation strategy is as follows: in, is the target flow control delay at the current moment when the target flow control strategy is the first flow control strategy, is the flow control delay of the data buffer at the previous moment, is the absolute value of the current rate of change of the number of dirty pages, is the delay calculation factor. The delay calculation factor can be determined according to the speed of flushing dirty pages in the data cache area.

[0046] In this embodiment, when the target flow control strategy is the first flow control strategy, the corresponding delay duration is increased based on the flow control delay of the previous moment, and the increased delay duration is related to the current rate of change of the number of dirty pages, that is, according to the rate of change of the number of dirty pages at adjacent moments, when the current rate of change of the number of dirty pages is large, the increased delay duration is large, and when the current rate of change of the number of dirty pages is small, the increased delay duration is small, so that the duration of the flow delay of the control data cache area can 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 cache area according to the target flow control delay, thereby avoiding the situation where the data buffer is exhausted due to excessive business pressure and performance fluctuations.

[0047] Optionally, the target flow control delay at the current moment is calculated according to the target flow control policy, the current rate of change of the number of dirty pages and the flow control delay, further comprising: When the target flow control strategy is the second flow control strategy, the target flow control delay at the current moment is calculated according to the flow control delay in combination with the preset first calculation strategy.

[0048] 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 number change rate and the flow control delay, combined with the preset second calculation strategy. The calculation formula corresponding to the second calculation strategy is as follows: in, is the target flow control delay at the current moment when the target flow control strategy is the first flow control strategy, is the flow control delay of the data buffer at the previous moment, Is the current rate of change of the number of dirty pages.

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

[0050] Optionally, the target flow control delay at the current moment is calculated according to the target flow control policy, the current rate of change of the number of dirty pages and the flow control delay, further comprising: When the target flow control strategy is the third flow control strategy, the target flow control delay at the current moment is calculated according to the current dirty page quantity change rate and the flow control delay in combination with the preset third calculation strategy.

[0051] 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 number change rate and the flow control delay, combined with the preset third calculation strategy. The calculation formula corresponding to the third calculation strategy is as follows: in, is the target flow control delay at the current moment when the target flow control strategy is the first flow control strategy, is the flow control delay of the data buffer at the previous moment, is the absolute value of the current rate of change of the number of dirty pages, is the delay calculation factor. The delay calculation factor can be determined according to the speed of flushing dirty pages in the data cache area.

[0052] 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 at the previous moment, and the reduced delay duration is related to the current rate of change of the number of dirty pages, that is, according to the rate of change of the number of dirty pages at adjacent moments, when the current rate of change of the number of dirty pages is large, the reduced delay duration is large, and when the current rate of change of the number of dirty pages is small, the reduced delay duration is small, so that when controlling the delay duration of the flow of the data cache area, it can 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. According to the target flow control delay, the corresponding delay duration is dynamically allocated to the data cache area, thereby avoiding the situation where the data buffer is exhausted due to excessive business pressure and performance fluctuations.

[0053] Optionally, the flow of the data buffer is controlled according to the target flow control delay, including: The size of the target flow control delay is determined. If the target flow control delay is greater than zero, the data buffer is controlled to receive new dirty page data after the target flow control delay.

[0054] In this embodiment, the size of the target flow control delay is determined. If the target flow control delay is greater than zero, it is necessary to delay control the flow of the data buffer area. After the target flow control delay time, the data buffer is controlled to receive new dirty page data.

[0055] Optionally, after determining the size of the target flow control delay, the method further includes: If the target flow control delay is not greater than zero, the flow control on the data buffer is turned off.

[0056] In this embodiment, after determining the size of the target flow control delay, if the target flow control delay is not greater than zero, the flow control of the data buffer is turned off. For example, when the second number of dirty pages is not greater than the first number of dirty pages, the flow control delay minus the product of the current dirty page number change rate and the delay calculation factor, if the target flow control strategy is less than zero, if the target flow control delay is not greater than zero, the flow control of the data buffer is turned off.

[0057] It should be noted that when the second number of dirty pages is not greater than the first number of dirty pages, the calculated target flow control delay may not be greater than zero. When the second number of dirty pages is not greater than the first number of dirty pages, it is considered that the dirty pages in the data buffer area are continuously decreasing. If the number of dirty pages decreases greatly, the memory resources occupied in the data buffer area are relatively small. At this time, the data buffer area receives new dirty page data, which has no effect on the performance of the database. Therefore, the flow control of the data buffer area can be turned off.

[0058] Obtain the first number of dirty pages in the data buffer at the previous moment and the second number of dirty pages in the data buffer at the current moment, calculate the change rate of the current number of dirty pages at the current moment based on the first number of dirty pages and the second number of dirty pages, obtain the change rate of the number of dirty pages in the data buffer at the previous moment, determine the target flow control strategy based on the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages and the change rate of the current 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 strategy, the change rate of the current number of dirty pages and the flow control delay, and control the flow of the data buffer based on the target flow control delay. In the present application, the target flow control strategy of the database buffer is determined based on the amount of dirty page data and the change rate of the number of dirty pages at adjacent moments, calculate the target flow control delay at the current moment based on the target flow control strategy, and control the flow of the data buffer based on the target flow control delay, and the data buffer automatically and dynamically adjusts the buffer allocation delay based on the business pressure by periodically calculating the buffer flow control delay, thereby avoiding the situation where the buffer is exhausted due to excessive business pressure and causes performance fluctuations.

[0059] See also Figure 2 , Figure 2 1 is a structural block diagram of a flow control device for a data buffer provided by Embodiment 2 of the present invention. For the sake of convenience, only the part related to the embodiment of the present application is shown. Figure 2 The flow control device 20 includes a calculation module 21 , a determination module 22 , and a control module 23 .

[0060] The calculation module 21 is used to obtain the first dirty page number in the data buffer at the previous moment and the second dirty page number in the data buffer at the current moment, and calculate the current dirty page number change rate at the current moment according to the first dirty page number and the second dirty page number.

[0061] 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 according to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages and the current change rate of the number of dirty pages.

[0062] 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 according to 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.

[0063] Optionally, the determination module 22 includes: The first determining unit is used to determine the preset first flow control strategy as the target flow control strategy when the second dirty page number is greater than the first dirty page number and the current dirty page number change rate is greater than the dirty page number change rate.

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

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

[0066] Optionally, the control module 23 includes: The first calculation unit is used to calculate the target flow control delay at the current moment according to the current dirty page quantity change rate and the flow control delay in combination with the preset first calculation strategy when the target flow control strategy is the first flow control strategy.

[0067] Optionally, the control module 23 includes: The second calculation unit is used to calculate the target flow control delay at the current moment according to the flow control delay in combination with the preset first calculation strategy when the target flow control strategy is the second flow control strategy.

[0068] Optionally, the control module 23 includes: The third calculation unit is used to calculate the target flow control delay at the current moment according to the current dirty page quantity change rate and the flow control delay, combined with the preset third calculation strategy when the target flow control strategy is the third flow control strategy.

[0069] Optionally, the control module 23 includes: The control unit is used to determine the size of the target flow control delay. If the target flow control delay is greater than zero, the data buffer is controlled to receive new dirty page data after the target flow control delay.

[0070] Optionally, the control unit includes: The closing unit is used to close the flow control of the data buffer if the target flow control delay is not greater than zero.

[0071] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0072] Figure 3Schematic diagram of the structure of a computer device provided by 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 figure), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps in any of the above-mentioned flow control embodiments are implemented.

[0073] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 3 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.

[0074] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0075] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments, it may also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.

[0076] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit 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 present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0077] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.

[0078] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0079] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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 this application.

[0080] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0082] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A flow control method for a data buffer, characterized in that: The flow control method comprises: Obtaining the first number of dirty pages in the data buffer at a previous moment and the second number of dirty pages in the data buffer at a current moment, and calculating a change rate of the current number of dirty pages at a current moment according to the first number of dirty pages and the second number of dirty pages; Obtaining a change rate of the number of dirty pages in the data buffer at a previous moment, and determining a target flow control strategy according to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages, and the change rate of the current 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 according to the target flow control strategy, the current rate of change of the number of dirty pages and the flow control delay, and control the flow of the data buffer according to the target flow control delay.

2. The flow control method according to claim 1, characterized in that: The determining a target flow control strategy according to the first number of dirty pages, the second number of dirty pages, the rate of change of the number of dirty pages, and the rate of change of the current number of dirty pages includes: When the second number of dirty pages is greater than the first number of 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, determining the preset first flow control strategy as the target flow control strategy; When the second number of dirty pages is greater than the first number of 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, determining the preset second flow control strategy as the target flow control strategy; When the second dirty page quantity is not greater than the first dirty page quantity, a preset third flow control strategy is determined as the target flow control strategy.

3. The flow control method according to claim 2, characterized in that: The calculating the target flow control delay at the current moment according to the target flow control strategy, the current dirty page quantity change rate and the flow control delay comprises: When the target flow control strategy is the first flow control strategy, the target flow control delay at the current moment is calculated according to the current dirty page quantity change rate and the flow control delay in combination with a preset first calculation strategy.

4. The flow control method according to claim 2, characterized in that: The calculating the target flow control delay at the current moment according to the target flow control strategy, the current dirty page quantity change rate and the flow control delay also includes: When the target flow control strategy is the second flow control strategy, the target flow control delay at the current moment is calculated according to the flow control delay in combination with the preset first calculation strategy.

5. The flow control method according to claim 2, characterized in that: The calculating the target flow control delay at the current moment according to the target flow control strategy, the current dirty page quantity change rate and the flow control delay also includes: When the target flow control strategy is the third flow control strategy, the target flow control delay at the current moment is calculated according to the current dirty page quantity change rate and the flow control delay in combination with the preset third calculation strategy.

6. The flow control method according to claim 1, characterized in that: The controlling the delay according to the target flow rate to control the flow rate of the data buffer zone includes: The size of the target flow control delay is determined. If the target flow control delay is greater than zero, the data buffer is controlled to receive new dirty page data after the target flow control delay.

7. The flow control method according to claim 6, characterized in that: After determining the size of the target flow control delay, the method further includes: If the target flow control delay is not greater than zero, the 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 comprises: A calculation module, used for obtaining the first number of dirty pages in the data buffer at a previous moment and the second number of dirty pages in the data buffer at a current moment, and calculating a change rate of the current number of dirty pages at a current moment according to the first number of dirty pages and the second number of dirty pages; A determination module, used for obtaining a change rate of the number of dirty pages in the data buffer at a previous moment, and determining a target flow control strategy according to the first number of dirty pages, the second number of dirty pages, the change rate of the number of dirty pages, and the change rate of the current number of dirty pages; A 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 according to the target flow control strategy, the current rate of change of the number of dirty pages 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, and the processor implements the flow control method according to any one of claims 1 to 7 when executing the computer program.

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

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

  • Protection domains for files at file-level or page-level

    US20210055869A1

  • Write-behind optimization of covering cache

    US20220414015A1

  • Data access method and apparatus

    WO2024066496A1