Threshold Adjustment Method, Device and Computer Equipment for Shared Cache
By dynamically adjusting the threshold of shared cache and calculating the threshold adjustment rate based on the object's queue length and cache capacity, the problems of low resource utilization and unfair allocation in the prior art are solved, and more efficient resource utilization and fair allocation are achieved.
Patent Information
- Application Number
- CN202211213294.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-09-30
AI Technical Summary
In the prior art, under the dynamic threshold strategy, despite the presence of free cache, packets in the overload queue are still discarded, resulting in low utilization of shared cache resources and unfair resource allocation.
By obtaining the shared cache capacity of the target device and the dynamic threshold and queue length of each object, dynamically adjusting the threshold adjustment value of each object, and calculate the threshold adjustment rate based on the queue length and cache capacity to achieve adaptive dynamic threshold allocation.
Maximize the utilization rate of shared cache resources, maintain fairness in resource allocation, improve packet forwarding efficiency, and reduce the number of discards.
Smart Images

Figure CN115941634B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies, and particularly to a method, apparatus, and computer device for adjusting the threshold of a shared cache. Background Art
[0002] Shared cache is a commonly used resource statistical multiplexing method in computers and communication devices. Shared cache is to share a centralized cache among all output queues, such as the sharing of on-chip cache in each port of a switching chip, and the shared allocation of computer memory in each session connection. Taking a switch as an example, currently, most mainstream commercial switching devices adopt a switching structure with a shared cache. Usually, the forwarding of a data packet requires two memory accesses including writing and reading, and all switch ports can access the shared cache simultaneously. After a data packet arrives at the switch, it is sent to the shared cache by the switching matrix. The cache capacity is limited. For example, due to factors such as area constraints, the on-chip shared cache capacity of a switching chip is limited. Therefore, the cache allocation policy determines whether a data packet is sent to the destination output port for queuing or discarded due to insufficient cache capacity.
[0003] Generally, a shared cache adopts an allocation policy based on a dynamic threshold (DT), such that the amount of shared cache allowed to be occupied by each port is controlled by a determined threshold, and the threshold is the upper limit of the port queue length, and the thresholds of each port are equal. However, the dynamic threshold policy makes the size of the idle cache negatively correlated with the number of overloaded queues. There is a situation where when the arriving data packets of an overloaded port continue to increase, but the dynamic threshold no longer increases accordingly, which means that the corresponding overloaded queues need to discard the arriving services, but there is still some shared cache that is not effectively utilized.
[0004] It can be seen that under the current dynamic threshold policy, even if there is a lot of idle cache in the device, the overloaded queues cannot use the idle cache to cause data packets to be discarded, that is, the resource utilization of the shared cache is relatively low. Summary of the Invention
[0005] Based on this, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for adjusting the threshold of a shared cache to maximize the resource utilization rate of the shared cache and maintain the fairness of resource allocation in view of the above technical problems.
[0006] In a first aspect, this application provides a method for adjusting the threshold of a shared cache, and the method includes:
[0007] Obtain the shared cache capacity of a target device;
[0008] Respectively obtain the dynamic threshold and queue length of each object in the target device in the nth cycle, where n is an integer greater than or equal to 0;
[0009] Determine the threshold adjustment value of each object according to the queue length of each object in the target device in the nth cycle and the shared cache capacity respectively;
[0010] For any one of the objects, determine the dynamic threshold of the object in the (n + 1)th cycle according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth cycle.
[0011] In one embodiment, for any one of the objects, when n is 0, the dynamic threshold of the object at the nth moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
[0012] In one embodiment, the step of determining the threshold adjustment value of each object according to the queue length of each object in the target device in the nth cycle and the shared cache capacity respectively includes:
[0013] For any one of the objects, determine the threshold adjustment rate of the object according to the queue length of each object in the target device in the nth cycle and the shared cache capacity;
[0014] Based on the threshold adjustment rate of each object and the time interval between cycles, determine the threshold adjustment value of each object.
[0015] In one embodiment, the step of determining the threshold adjustment rate of the object according to the queue length of each object in the target device in the nth cycle and the shared cache capacity includes:
[0016] Determine the remaining cache occupancy ratio according to the sum of the queue lengths of each object in the target device in the nth cycle and the shared cache capacity, where the remaining cache occupancy ratio is negatively correlated with the sum of the queue lengths;
[0017] Determine the threshold adjustment rate of the object according to the remaining cache occupancy ratio and the queue length of the object in the nth cycle.
[0018] In one embodiment, the step of determining the remaining cache occupancy ratio according to the sum of the queue lengths of each object in the target device in the nth cycle and the shared cache capacity includes:
[0019] Obtain the preset free cache capacity;
[0020] Determine the target cache capacity according to the shared cache capacity and the free cache capacity;
[0021] Determine the remaining cache occupancy based on the sum of the queue lengths of each of the objects in the target device in the nth period and the target cache capacity.
[0022] In one embodiment, the method further includes:
[0023] When the sum of the queue lengths of each of the objects in the nth period is equal to the target cache capacity, use the result of adding 1 to the sum of the queue lengths of each of the objects in the nth period as the sum of the queue lengths of each of the objects in the nth period.
[0024] In a second aspect, the present application also provides a threshold adjustment device for a shared cache. The device includes:
[0025] A cache capacity acquisition module, configured to acquire the shared cache capacity of a target device;
[0026] A dynamic threshold acquisition module, configured to respectively acquire the dynamic threshold and the queue length of each object in the target device in the nth period, where n is an integer greater than or equal to 0;
[0027] A threshold adjustment value determination module, configured to respectively determine the threshold adjustment value of each object according to the queue length of each object in the target device in the nth period and the shared cache capacity;
[0028] A threshold allocation module, configured to, for any one of the objects, determine the dynamic threshold of the object in the (n + 1)th period according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth period.
[0029] In one embodiment, for any one of the objects, when n is 0, the dynamic threshold of the object at the nth moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
[0030] In one embodiment, the threshold adjustment value determination module is further configured to, for any one of the objects, determine the threshold adjustment rate of the object according to the queue length of each object in the target device in the nth period and the shared cache capacity; and determine the threshold adjustment value of each object based on the threshold adjustment rate of each object and the time interval between periods.
[0031] In one embodiment, the threshold adjustment value determination module is further configured to determine the remaining cache occupancy according to the sum of the queue lengths of each object in the target device in the nth period and the shared cache capacity, where the remaining cache occupancy is negatively correlated with the sum of the queue lengths; and determine the threshold adjustment rate of the object according to the remaining cache occupancy and the queue length of the object in the nth period.
[0032] In one embodiment, the threshold adjustment value determination module is further configured to obtain a preset idle cache capacity; determine a target cache capacity according to the shared cache capacity and the idle cache capacity; and determine a remaining cache occupancy ratio according to the sum of the queue lengths of each of the objects in the target device in the nth period and the target cache capacity.
[0033] In one embodiment, the apparatus further includes a convergence module, configured to, when the sum of the queue lengths of each of the objects in the nth period is equal to the target cache capacity, use the result of adding 1 to the sum of the queue lengths of each of the objects in the nth period as the sum of the queue lengths of each of the objects in the nth period.
[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the steps in the foregoing method embodiments are implemented.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the foregoing method embodiments are implemented.
[0036] In a fifth aspect, the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps in the foregoing method embodiments are implemented.
[0037] The above-mentioned threshold adjustment method, device, computer device, computer-readable storage medium, and computer program product for shared cache obtain the shared cache capacity of the target device; respectively obtain the dynamic thresholds and queue lengths of each object in the target device in the nth cycle, where n is an integer greater than or equal to 0; determine the threshold adjustment values of each object according to the queue lengths of each object in the target device in the nth cycle and the shared cache capacity; for any one of the objects, determine the dynamic threshold of the object in the (n + 1)th cycle according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth cycle. Compared with the dynamic threshold allocation strategy in the traditional technology where the thresholds of each port are equal, the threshold adjustment method, device, computer device, computer-readable storage medium, and computer program product for shared cache provided in this application introduce the queue lengths of each object in the target device, that is, the actual size of the shared cache occupied by each object, so that for any object, the dynamic threshold of the previous cycle can be adjusted in real time according to the queue length of the object to obtain the dynamic threshold of the next cycle, reasonably allocate the dynamic thresholds of each object in the target device, maximize the resource utilization rate of the shared cache, and maintain the fairness of resource allocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a schematic diagram related to the idle cache and overloaded queue in the traditional dynamic threshold strategy;
[0039] Figure 2 It is a schematic flowchart of the threshold adjustment method for shared cache in an embodiment;
[0040] Figure 3 It is a schematic flowchart of step 206 in an embodiment;
[0041] Figure 4 It is a schematic flowchart of step 302 in an embodiment;
[0042] Figure 5 It is a schematic flowchart of step 402 in an embodiment;
[0043] Figure 6 It is a schematic diagram of the traffic arriving at the switch port in an embodiment;
[0044] Figure 7 It is a schematic diagram of the evolution of the queue lengths of each port over time under the traditional dynamic threshold strategy;
[0045] Figure 8 It is a schematic diagram of the evolution of the queue lengths of each port over time under the threshold adjustment method for shared cache;
[0046] Figure 9 It is a structural block diagram of the threshold adjustment device for shared cache in an embodiment;
[0047] Figure 10 It is the internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0048] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] Shared cache is a commonly used resource statistical multiplexing method in computers and communication devices. For example, the on-chip cache in a switching chip is shared among various ports, and the computer memory is shared and allocated among various session connections. Generally, a dynamic threshold-based allocation strategy is adopted. Taking a switch as an example, the current mainstream commercial switching devices mostly adopt a switching structure with shared cache. After a packet arrives at the switch, it is sent to the shared cache by the switching matrix. The cache allocation strategy determines whether the packet is sent to the destination output port for queuing or discarded due to insufficient cache capacity. Shared cache is a centralized cache shared among all output queues. Usually, the forwarding of a data packet requires two memory accesses including writing and reading, and all switch ports can access the shared cache simultaneously. The sharing of computer memory by service session connections also adopts a similar mechanism. The cache capacity is always limited. For example, due to factors such as area constraints, the on-chip shared cache capacity of a switching chip is limited. How to effectively share and use the on-chip cache resources among various switch ports has become a key technology for improving the performance of switches.
[0050] The dynamic threshold strategy is a classic shared cache allocation strategy. It adopts a non-preemptive allocation method. The amount of shared cache that each port is allowed to occupy is controlled by a determined threshold, which is the upper limit of the port queue length. The classic threshold dynamic adjustment rule is as shown in formula (1), and the dynamic threshold size is proportional to the currently idle buffer space.
[0051]
[0052] Wherein, T(t) is the threshold at time t, B is the size of the shared cache capacity, Q i (t) is the queue length of the i-th port at time t, and N is the total number of ports. When the queue length reaches or exceeds this threshold, data packets are not allowed to enter the corresponding queue anymore. Because the dynamic threshold strategy has better adaptability than the early static allocation strategy and is simple to implement, it is widely used in different models of switching chips by current mainstream switching chip manufacturers (such as Broadcom, Cisco, and Huawei, etc.).
[0053] Although the dynamic threshold strategy has been widely used due to its good dynamic adaptability and simple implementation method, its threshold adjustment rule (Formula (1)) has an inherent defect: the idle cache size is negatively correlated with the number of overloaded queues. As shown in Figure 1, when there is 1 or 2 overloaded queues respectively, the final idle caches are B / 2 or B / 3 respectively. Even if the arriving traffic of these overloaded ports continues to grow, the dynamic threshold no longer increases accordingly, which means that the corresponding overloaded queues need to discard the arriving data packets, but at this time, there is still some shared cache that is not effectively utilized. Taking the on-chip shared cache of a switch in a data center as an example, in a many-to-one traffic pattern, the burst traffic is discarded by the switch with originally idle cache, and the process of retransmitting the discarded packets delays the transmission completion time of the flow or flow bundle, thereby affecting the responsiveness of the entire distributed system.
[0054] Based on this, the embodiments of the present application provide a method for adjusting the threshold of a shared cache, which uses a population evolution model to guide the adaptive adjustment of the dynamic threshold to solve the above problems, maximize the utilization rate of the shared cache resources, and maintain good fairness in resource allocation among competing users.
[0055] In one embodiment, as Figure 2 shown, a method for adjusting the threshold of a shared cache is provided. In this embodiment, this method is exemplified by being applied to a server. It can be understood that this method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0056] Step 202, obtain the shared cache capacity of the target device.
[0057] Wherein, the target device is the device that shares the cache for data packets. For example, in the scenario of on-chip shared cache of a switch, the target device is the switch; in other scenarios such as the allocation of TCP (Transmission Control Protocol) connection receive cache in an operating system and the allocation of pooled memory resources in a data center, the target device may be other devices such as virtual memory. The shared cache capacity is the size of the total cache, which is an inherent attribute of the target device, and different target devices have different shared cache capacities.
[0058] Step 204, respectively obtain the dynamic threshold and queue length of each object in the target device in the nth cycle, where n is an integer greater than or equal to 0.
[0059] In the embodiments of the present application, an object is used for data input and output in a target device, and the object can access a shared cache simultaneously. For example, in the scenario of a shared cache on a switch chip, the object can be a port of the switch; in the scenario of a TCP connection receive cache, the object can be a user. The dynamic threshold of the object is the maximum value of the cache that the object can actually occupy in the shared cache, that is, the upper limit of the queue length of the object. The queue length of the object is the number of data packets (data packets) that the object can receive or accommodate. The period can characterize the frequency of change of the dynamic threshold of each object in the target device, and the duration of one period can be determined according to the target device or actual requirements.
[0060] Step 206: Determine the threshold adjustment value of each object according to the queue length and the shared cache capacity of each object in the target device in the nth period.
[0061] In the embodiments of the present application, the queue lengths of each object in the nth period can be directly added up to obtain the sum of the queue lengths of all objects in the nth period. The sum of the queue lengths of all objects in the nth period is the total cache capacity that all objects have used in the nth period. The threshold adjustment value of an object is the difference between the dynamic thresholds of the object in two adjacent periods. For any object, the demand for resources in the shared cache is different at each moment, so the corresponding dynamic threshold can be adjusted dynamically. Specifically, the remaining available capacity can be determined according to the total cache capacity used by all objects and the shared buffer capacity, and then based on the current queue length of the object and the remaining available capacity, the adjustable space of the threshold of the object can be determined, that is, the threshold adjustment value is obtained, and the dynamic threshold is adjusted according to this value. That is, based on the sum of the queue lengths of all objects in the nth period, the queue length of the object in the nth period, and the shared cache capacity of the target device, the threshold adjustment value of the object between two adjacent periods can be determined.
[0062] Step 208: For any object, determine the dynamic threshold of the object in the (n + 1)th period according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth period.
[0063] Wherein, each period can include a start time and an end time, and the start time of the (n + 1)th period is the end time of the nth period. The threshold adjustment value of the object is the difference between the dynamic thresholds of the object in two adjacent periods, and the nth period and the (n + 1)th period are two adjacent periods. For any object, after obtaining the threshold adjustment value of the object, the dynamic threshold of the object in the nth period can be added to the threshold adjustment value to obtain the dynamic threshold of the object in the (n + 1)th period.
[0064] The threshold adjustment method for shared cache provided by the embodiments of the present application obtains the shared cache capacity of the target device; respectively obtains the dynamic thresholds and queue lengths of each object in the target device in the nth period, where n is an integer greater than or equal to 0; determines the threshold adjustment value of the object according to the queue length and shared cache capacity of each object in the target device in the nth period; for any object, determines the dynamic threshold of the object in the (n + 1)th period according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth period. Compared with the dynamic threshold allocation strategy in the traditional technology where the thresholds of each port are equal, the threshold adjustment method for shared cache provided by the present application introduces the queue length of each object in the target device, that is, the size of the shared cache actually occupied by each object, so that for any object, the dynamic threshold of the previous period can be adjusted according to the queue length of the object to obtain the dynamic threshold of the next period, reasonably allocates the dynamic thresholds of each object in the target device, maximizes the resource utilization rate of the shared cache, and maintains the fairness of resource allocation.
[0065] In one embodiment, for any object, the dynamic threshold of the object at the nth moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
[0066] Wherein, the total number of objects is the number of objects in the target device. Taking the shared cache allocation of a switch as an example, the total number of objects is the number of switch ports. For any object, when n is 0, the ratio of the shared cache capacity to the total number of objects can be used as the dynamic threshold of the object at the nth moment. That is, when n is 0, the dynamic thresholds of each object at the nth moment are equal.
[0067] In the embodiments of the present disclosure, the dynamic threshold of the object when n is 0 is set so that when the shared cache adjusts the dynamic threshold for each object, each object has the same dynamic threshold, maintaining the fairness of resource allocation.
[0068] In one embodiment, as Figure 3 shown, in step 206, according to the queue lengths and shared cache capacity of each object in the target device in the nth period, respectively determining the threshold adjustment values of each object may include:
[0069] Step 302, for any object, determines the threshold adjustment rate of the object according to the queue lengths and shared cache capacity of each object in the target device in the nth period.
[0070] Among them, the threshold adjustment rate of an object can be used to characterize the speed of dynamic threshold change of the object during the period from the current cycle to the next cycle. The threshold adjustment rate of the object can be a positive value, a negative value, or 0. After obtaining the sum of the queue lengths of each object in the nth cycle, for any object, based on the sum of the queue lengths of each object in the nth cycle, the queue length of the object in the nth cycle, and the shared cache capacity of the target device, the threshold adjustment rate of the object between two adjacent cycles can be determined.
[0071] Step 304: Determine the threshold adjustment value of each object based on the threshold adjustment rate of each object and the cycle interval duration.
[0072] Among them, the cycle interval duration is the time from the nth cycle to the n + 1th cycle. Since the start time of the n + 1th cycle is the end time of the nth cycle, the cycle interval duration is the time length of each cycle. The embodiments of the present application do not make specific limitations on the cycle interval duration, and the cycle interval duration can be determined according to the frequency of dynamic threshold change of each object in the target device during the actual application process. After obtaining the threshold adjustment rate and the cycle interval duration, the threshold adjustment rate can be multiplied by the cycle interval duration, and the obtained product is the threshold adjustment value of the object.
[0073] In the embodiments of the present disclosure, by determining different threshold adjustment rates for each object based on the respective queue lengths of each object, the cache requirements of each object can be adapted, the respective dynamic thresholds can be dynamically adjusted, and the shared cache resources can be fully and fairly allocated to the objects with requirements.
[0074] In one embodiment, as Figure 4 shown, in step 302, according to the queue lengths of each object in the target device in the nth cycle and the shared cache capacity, determining the threshold adjustment rate of the object may include:
[0075] Step 402: Determine the remaining cache ratio according to the sum of the queue lengths of each object in the target device in the nth cycle and the shared cache capacity, where the remaining cache ratio is negatively correlated with the sum of the queue lengths.
[0076] Among them, the remaining cache ratio is the ratio of the remaining cache capacity in the shared cache of the target device to the total available cache capacity. The remaining cache ratio can be obtained by subtracting the used cache ratio from 1. The used cache ratio is the ratio of the sum of the queue lengths of each object in the nth cycle to the total available cache capacity. The total available cache capacity can be determined from the shared cache capacity.
[0077] Step 404: Determine the threshold adjustment rate of the object according to the remaining cache ratio and the queue length of the object in the nth cycle.
[0078] Among them, the remaining cache ratio can be multiplied by the queue length of the object in the nth cycle and then multiplied by a constant parameter r i to obtain the product, which is the threshold adjustment rate of the object. The constant parameter r i can be used to represent the weight coefficient of the queue length of the object in the nth cycle. In the embodiments of the present application, the size of the constant parameter r i is not specifically limited and can be determined according to specific needs in actual applications.
[0079] In the embodiments of the present disclosure, based on the queue length and the remaining cache ratio of each object, different threshold adjustment rates of each object are determined, so that the larger the queue length of the object, that is, the larger the actual cache size occupied by the object, the faster the threshold adjustment. Furthermore, the cache requirements of each object can be adapted, and the respective dynamic thresholds can be dynamically adjusted, so as to fully and fairly allocate the shared cache resources to the objects in need.
[0080] In one embodiment, as Figure 5 shown, in step 402, according to the sum of the queue lengths of each object in the target device in the nth cycle and the shared cache capacity to determine the remaining cache ratio, it may include:
[0081] Step 502, obtain the preset free cache capacity.
[0082] Among them, the free cache capacity can be preset and limited according to specific needs in actual applications. Taking a switch as an example, the role of the free cache capacity is to reserve a certain amount of free cache at any time to receive data packets that suddenly arrive on idle or lightly loaded ports, preventing overloaded ports from monopolizing the cache and lightly loaded ports from being unable to receive new data packets. For example: if the switch only uses 4 ports in the nth cycle and all 4 ports are overloaded ports, that is, the queue length has reached the adjusted dynamic threshold, in the (n + 1)th cycle, when a new data packet arrives at the 5th port, the 5th port will use the free cache capacity to cache the data packet so that the 5 ports can re-adjust the dynamic threshold according to their respective queue lengths.
[0083] Step 504, determine the target cache capacity according to the shared cache capacity and the free cache capacity.
[0084] Among them, the target cache capacity is the total available cache capacity in the shared cache, which can be determined by the difference between the shared cache capacity and the free cache capacity.
[0085] Step 506, determine the remaining cache ratio according to the sum of the queue lengths of each object in the target device in the nth cycle and the target cache capacity.
[0086] Among them, the remaining cache ratio is the ratio of the remaining cache capacity in the shared cache of the target device to the target cache capacity. The remaining cache ratio can be obtained by subtracting the used cache ratio from 1. The used cache ratio is the ratio of the sum of the queue lengths of each object in the nth period to the target cache capacity.
[0087] Taking the allocation of the switch shared cache as an example, the threshold adjustment rate of an object can be obtained based on the differential equation constructed by the Lotka-Volterra model. It should be noted that the differential equation satisfies the following formula (II).
[0088]
[0089] Among them, dT i (t) / dt represents the threshold adjustment rate, and T i (t) represents the dynamic threshold of the i-th (i = 1, 2,... N) port at time t, B is the shared cache capacity of the switch chip, N is the number of switch ports, Q i (t) is the queue length of the i-th port at time t, and K is the idle cache capacity, r i is a constant parameter.
[0090] In the embodiments of the present application, the corresponding threshold adjustment rate can also be obtained based on other population evolution models such as Malthus and Logistic. The embodiments of the present application do not further limit the threshold adjustment rate formulas obtained by the above two models, as long as the dynamic threshold of each object is adjusted according to the queue length Q i (t) of each object.
[0091] By converting the above formula (II) into an equivalent discrete difference equation, the threshold adjustment value of the object can be obtained. The equivalent discrete difference equation satisfies the following formula (III).
[0092] T i (n + 1) = T i (n) + r i Q i (n)T s (1 - sumQ / (B - K)) Formula (III)
[0093] Among them, sumQ is the sum of the queue lengths of each object in the nth period, T s is the discretized sampling period, T i (n) and Q i (n) are the dynamic threshold and queue length of the i-th port at the nth sampling moment (nth period) respectively. T s The discretized sampling period is the time interval between periods. T i(n + 1) is the dynamic threshold of the i-th port in the (n + 1)-th cycle.
[0094] Equation (3) and Equation (4) together constitute a dynamic adaptive threshold adjustment rule based on the population evolution model, called the ADT (Adaptive Dynamic Threshold) strategy.
[0095] In the embodiments of the present disclosure, based on the idle cache capacity and the sum of the queue lengths of each object in the n-th cycle, the remaining cache ratio is determined, so that the threshold adjustment method of the shared cache provided by the present application can be applied to the dynamic threshold adaptive adjustment of different numbers of objects in the target device, and the shared cache resources are fully and fairly allocated to all objects with demands.
[0096] In one embodiment, the threshold adjustment method of the shared cache may further include: when the sum of the queue lengths of each object in the n-th cycle is equal to the target cache capacity, using the result of adding 1 to the sum of the queue lengths of each object in the n-th cycle as the sum of the queue lengths of each object in the n-th cycle.
[0097] Exemplarily, taking Equation (3) as an example, to ensure the convergence of the evolution process of the discrete difference equation therein, the following constraint condition needs to be added: when sumQ = B - K, let sumQ = B - K + 1.
[0098] In the embodiments of the present disclosure, when the sum of the queue lengths of each object in the n-th cycle, that is, when each object has actually fully occupied the target cache capacity in the shared cache, a convergence constraint is imposed on the sum of the queue lengths of each object in the n-th cycle, so that the threshold adjustment rate can be negative, and thus the cache actually occupied by each object will never exceed the shared cache capacity, maximizing the utilization rate of the shared cache resources, and at the same time maintaining good fairness in resource allocation among competing objects.
[0099] Taking a shared cache switch as an example, given an 8-port switch (N = 8), the shared cache capacity B = 200 pkts (the total number of packets that can be cached). The traffic arrivals on the 8 output ports of the switch are as Figure 6 shown, with persistent traffic, short burst traffic, and ON / OFF traffic flows. The parameters are set according to the default configuration, T s = 0.001, r i = 1, K = 0. Figure 7 and Figure 8They are the results of the evolution of the queue lengths of each port over time under the traditional dynamic threshold (DT) strategy and the threshold adjustment method (ADT) of shared cache provided by this application respectively. Among them, the remaining cache curve depicts the change of the remaining cache. It can be seen that compared with the DT strategy, the threshold adjustment method of shared cache provided by this application can adapt to the port cache requirements, dynamically adjust their respective thresholds, and allocate the shared cache resources fully and fairly to the ports in need. As shown in Table 1, the total amount is the total amount of data packets arriving at the switch, and ports 1-8 respectively correspond to the number of discarded packets. It can be seen that the threshold adjustment method of shared cache provided by this application has no idle resources, improves the utilization rate of shared cache resources, and reduces the number of discarded packets at the ports.
[0100] Table 1
[0101]
[0102]
[0103] The threshold adjustment method of shared cache provided by the embodiments of this application is different from the traditional dynamic threshold DT strategy that sets the threshold T(n) for all ports with the same threshold T(t), but introduces the actual shared cache size Q(n) occupied by each user, and adjusts the cache sharing threshold T(n) respectively under the drive of formula (3), sharing the cache resources fairly and effectively among the ports (users) in need. It should be noted that the embodiments of this application take the allocation of on-chip shared cache of the switch as an example for illustration, but the threshold adjustment method of shared cache provided by this application is also applicable to the situations where threshold allocation of shared cache is adopted in other computers and communication devices, such as the allocation of TCP connection receive cache in the operating system and the allocation of pooled memory resources in the data center, etc. i (n), but introduces the actual shared cache size Q i (n) occupied by each user, and adjusts the cache sharing threshold T i (n) respectively under the drive of formula (3), sharing the cache resources fairly and effectively among the ports (users) in need. It should be noted that the embodiments of this application take the allocation of on-chip shared cache of the switch as an example for illustration, but the threshold adjustment method of shared cache provided by this application is also applicable to the situations where threshold allocation of shared cache is adopted in other computers and communication devices, such as the allocation of TCP connection receive cache in the operating system and the allocation of pooled memory resources in the data center, etc.
[0104] It should be understood that although the steps in the flowcharts involved in the above-mentioned embodiments are shown in sequence according to the arrows, these steps do not necessarily need to be executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily need to be executed at the same moment, but can be executed at different moments. The execution order of these steps or stages does not necessarily need to be sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0105] Based on the same inventive concept, an embodiment of the present application further provides a threshold adjustment device for implementing the shared cache involved above. The solution provided by this device for solving problems is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the threshold adjustment device for the shared cache provided below can refer to the limitations on the threshold adjustment method for the shared cache in the above text, and will not be elaborated here.
[0106] In one embodiment, referring to Figure 9 , a threshold adjustment device 900 for the shared cache is provided. The threshold adjustment device 900 for the shared cache includes:
[0107] A cache capacity acquisition module 902, configured to acquire the shared cache capacity of the target device;
[0108] A dynamic threshold acquisition module 904, configured to respectively acquire the dynamic threshold and queue length of each object in the target device in the nth period, where n is an integer greater than or equal to 0;
[0109] A threshold adjustment value determination module 906, configured to respectively determine the threshold adjustment value of each object according to the queue length and shared cache capacity of each object in the target device in the nth period;
[0110] A threshold allocation module 908, configured to, for any object, determine the dynamic threshold of the object in the (n + 1)th period according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth period.
[0111] The threshold adjustment device for the shared cache provided by the embodiment of the present application acquires the shared cache capacity of the target device; respectively acquires the dynamic threshold and queue length of each object in the target device in the nth period, where n is an integer greater than or equal to 0; respectively determines the threshold adjustment value of each object according to the queue length and shared cache capacity of each object in the target device in the nth period; for any object, determines the dynamic threshold of the object in the (n + 1)th period according to the threshold adjustment value of the object and the dynamic threshold of the object in the nth period. Compared with the dynamic threshold allocation strategy in the traditional technology where the thresholds of each port are equal, the threshold adjustment device for the shared cache provided by the present application introduces the queue length of each object in the target device, that is, the actual size of the shared cache occupied by each object, so that for any object, the dynamic threshold of the previous period can be adjusted according to the queue length of the object to obtain the dynamic threshold of the next period, reasonably allocate the dynamic thresholds of each object in the target device, maximize the resource utilization rate of the shared cache, and maintain the fairness of resource allocation.
[0112] In one embodiment, for any object, when n is 0, the dynamic threshold of the object at the n-th moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
[0113] In one embodiment, the threshold adjustment value determination module 906 is further configured to, for any object, determine the threshold adjustment rate of the object according to the queue length of each object in the target device at the n-th cycle and the shared cache capacity; and determine the threshold adjustment value of each object based on the threshold adjustment rate of each object and the cycle interval duration.
[0114] In one embodiment, the threshold adjustment value determination module 906 is further configured to determine the remaining cache ratio according to the sum of the queue lengths of each object in the target device at the n-th cycle and the shared cache capacity, where the remaining cache ratio is negatively correlated with the sum of the queue lengths; and determine the threshold adjustment rate of the object according to the remaining cache ratio and the queue length of the object at the n-th cycle.
[0115] In one embodiment, the threshold adjustment value determination module 906 is further configured to obtain the preset free cache capacity; determine the target cache capacity according to the shared cache capacity and the free cache capacity; and determine the remaining cache ratio according to the sum of the queue lengths of each object in the target device at the n-th cycle and the target cache capacity.
[0116] In one embodiment, the threshold adjustment device 900 of the shared cache further includes a convergence module. The convergence module is configured to, when the sum of the queue lengths of each object at the n-th cycle is equal to the target cache capacity, use the result of adding 1 to the sum of the queue lengths of each object at the n-th cycle as the sum of the queue lengths of each object at the n-th cycle.
[0117] Each module in the above-mentioned threshold adjustment device of the shared cache can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0118] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 10As shown. The computer device includes a processor, a memory, and a network interface connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a method for adjusting the threshold of a shared cache.
[0119] Those skilled in the art can understand that Figure 10 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0120] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the steps in the above method embodiments are implemented.
[0121] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the steps in the above method embodiments are implemented. In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0123] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0124] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0125] The above-described embodiments merely represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for adjusting the threshold of a shared cache, characterized in that The method includes: Obtaining the shared cache capacity of the target device; Respectively obtaining the dynamic threshold and queue length of each object in the target device in the nth period, where n is an integer greater than or equal to 0; For any one of the objects, determining the dynamic threshold of the object in the (n + 1)th period according to the following formula: Among them, Q i (n) is the queue length of the i-th object in the n-th period, N is the total number of the objects, B is the shared cache capacity, K is the preset idle cache capacity, r i is a constant parameter, T s is the time interval between periods, T i (n) is the dynamic threshold of the i-th object in the n-th period, T i (n + 1) is the dynamic threshold of the i-th object in the n + 1-th period; When the sum of the queue lengths of each object in the nth period is equal to the target cache capacity, taking the result of adding 1 to the sum of the queue lengths of each object in the nth period as the sum of the queue lengths of each object in the nth period, where the target cache capacity is the difference between the shared cache capacity and the free cache capacity.
2. The method according to claim 1, wherein For any one of the objects, when n is 0, the dynamic threshold of the object at the nth moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
3. A threshold adjustment device for a shared cache, characterized in that, The device includes: A cache capacity acquisition module, configured to obtain the shared cache capacity of the target device; A dynamic threshold acquisition module, configured to respectively obtain the dynamic threshold and queue length of each object in the target device in the nth period, where n is an integer greater than or equal to 0; A threshold allocation module, configured to determine the dynamic threshold of the object in the (n + 1)th period according to the following formula: Among them, Q i (n) is the queue length of the i-th object in the n-th period, N is the total number of the objects, B is the shared cache capacity, K is the preset free cache capacity, r i is a constant parameter, T s is the time interval between periods, T i (n) is the dynamic threshold of the i-th object in the n-th period, T i (n + 1) is the dynamic threshold of the i-th object in the (n + 1)-th period; A convergence module, configured to, when the sum of the queue lengths of each object in the nth period is equal to the target cache capacity, take the result of adding 1 to the sum of the queue lengths of each object in the nth period as the sum of the queue lengths of each object in the nth period, where the target cache capacity is the difference between the shared cache capacity and the free cache capacity.
4. The device according to claim 3, characterized in that For any one of the objects, when n is 0, the dynamic threshold of the object at the nth moment is determined according to the shared cache capacity and the total number of objects, where the dynamic threshold is negatively correlated with the total number of objects.
5. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to claim 1 or 2 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to claim 1 or 2 are implemented.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to claim 1 or 2 are implemented.
Citation Information
Patent Citations
Queue monitoring to filter the trend for enhanced buffer management and dynamic queue threshold in 4g IP network / equipment for better traffic performance
US20140105218A1
Buffer management scheme employing dynamic thresholds
US6788697B1