A cache control method, system and related components
By monitoring and adjusting the group-associative structure parameters of the cache, the problem of unstable hit rate was solved, the hit rate was improved and the access latency was reduced, thus ensuring the stability of the application.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
- Filing Date
- 2022-08-30
- Publication Date
- 2026-04-21
AI Technical Summary
Under a constant set-associative structure, the cache hit rate is unstable when responding to different read and write commands, resulting in unstable running speed of upper-layer applications.
By monitoring the hit rate of request messages, the set-associative structure parameters of the cache are adjusted to dynamically adjust the address mapping and replacement algorithm, ensuring that the hit rate reaches the target level.
It improved the overall hit rate of request messages, reduced the probability of access latency, and stabilized the running speed of upper-layer applications.
Smart Images

Figure CN115437824B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of caching, and in particular to a cache control method, system, and related components. Background Technology
[0002] A cache, or simply cache, is a level-one memory located between main memory and the CPU (Central Processing Unit), used to provide the CPU with read and write services at a higher speed than main memory.
[0003] When the CPU reads data, the hardware first automatically decodes the column number field of the access address to compare all row numbers of that column in the cache with the row number field of the main memory address. If they match, it means the main memory unit to be accessed is already in the cache, called a hit. The hardware then maps the main memory address to the cache address and performs the access operation. If they do not match, it means the unit is not in the cache, called a miss. The hardware performs the main memory access operation and automatically loads the main memory unit group containing that unit into an empty memory unit group in the same column of the cache. At the same time, it stores the row number of that group in main memory into the corresponding unit in the associative memory. When a miss occurs and there is no empty space in the corresponding column of the cache, a group in that column is replaced to make room for the newly loaded group. This process is called replacement.
[0004] The cache internally uses a directory-based address mapping system to establish a correspondence between the address of a piece of data in main memory and its address in the cache. Specifically, common address mapping structures include fully associative, directly associative, and set-associative structures. Fully associative structures have a high hit rate but require more matching objects, resulting in slower access speeds and higher hardware resource consumption. Directly associative structures have simpler circuit design but lower hit rates and more frequent replacement operations. Set-associative structures are a middle ground between fully associative and directly associative structures, offering both high hit rate and high utilization.
[0005] However, different upper-layer applications have different ways of reading and writing memory. Under the constant set-associative structure, the cache hit rate is not the same when responding to different read and write commands. When the hit rate is low, cache access latency will occur, resulting in unstable running speed of upper-layer applications.
[0006] Therefore, how to provide a solution to the above-mentioned technical problems is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0007] In view of this, the purpose of this invention is to provide a cache control method, system, and related components with a high hit rate. The specific solution is as follows:
[0008] A cache control method, comprising:
[0009] Get the request message for the current CPU;
[0010] Respond to the request message according to the current directory working mode, and monitor the hit rate of the request message;
[0011] Determine whether the hit rate has reached the target hit rate;
[0012] If not, adjust the group-connected structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode.
[0013] Preferably, the cache control method further includes:
[0014] Monitor the hit rate of the request message when the current directory working mode responds to the request message;
[0015] Determine whether the hit rate reaches the target hit rate;
[0016] If not, then perform the following actions until the hit rate reaches the target hit rate:
[0017] Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode.
[0018] Preferably, the cache control method further includes:
[0019] If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
[0020] Preferably, after obtaining the request message for the current CPU, the process includes:
[0021] Based on the type of the request message, determine the group-connected structure parameters of the current directory working mode;
[0022] The types of the request messages include continuous memory read / write type and non-continuous memory read / write type.
[0023] Preferably, the cache control method further includes:
[0024] Receive mode command;
[0025] Adjust the group-connected structure parameters in the current directory working mode according to the mode instruction, so as to respond to the remainder of the request message according to the adjusted directory working mode.
[0026] Preferably, the process of adjusting the group-associative structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode includes:
[0027] First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
[0028] Preferably, the cache control method further includes:
[0029] All cache lines are replaced according to the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
[0030] Accordingly, this application also discloses a cache control system, including:
[0031] The acquisition module is used to acquire the request message of the current CPU;
[0032] The response module is used to respond to the request message according to the current directory working mode and monitor the hit rate of the request message;
[0033] The judgment module is used to determine whether the hit rate has reached the target hit rate;
[0034] An action module is used to adjust the group-connected structure parameters in the current directory working mode if the result of the judgment module is negative, so as to trigger the response module to respond to the remaining part of the request message according to the current directory working mode.
[0035] Accordingly, this application also discloses an electronic device, including:
[0036] Memory, used to store computer programs;
[0037] A processor, configured to implement the cache control method described in any of the preceding descriptions when executing the computer program.
[0038] Accordingly, this application also discloses a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the cache control method described in any of the above claims.
[0039] This application discloses a cache control method, comprising: acquiring a request message of the current CPU; responding to the request message according to the current directory working mode and monitoring the hit rate of the request message; determining whether the hit rate reaches a target hit rate; if not, adjusting the group-associative structure parameters in the current directory working mode to respond to the remaining part of the request message according to the adjusted directory working mode. This application, by monitoring the hit rate of the request message during the response process and adjusting the group-associative structure parameters of target working modes with hit rates below the target hit rate, achieves the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0041] Figure 1 This is a flowchart illustrating the steps of a cache control method in an embodiment of the present invention.
[0042] Figure 2 This is a structural distribution diagram of an address mapping partition in an embodiment of the present invention;
[0043] Figure 3 This is a grouping structure diagram of a cache line in an embodiment of the present invention;
[0044] Figure 4 This is a tree structure diagram of a variable replacement algorithm in an embodiment of the present invention;
[0045] Figure 5 This is a structural distribution diagram of a cache control system according to an embodiment of the present invention;
[0046] Figure 6 This is a structural distribution diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0048] Different upper-layer applications have different ways of reading and writing memory. Under a constant set-associative structure, the cache hit rate is not the same when responding to different read and write commands. When the hit rate is low, cache access latency will occur, resulting in unstable running speed of upper-layer applications.
[0049] This application monitors the hit rate of request messages during the response process and adjusts the group-connected structure parameters of target working modes with hit rates below the target hit rate, thereby achieving the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost.
[0050] This invention discloses a cache control method, see [link to relevant documentation]. Figure 1 As shown, it includes:
[0051] S1: Obtain the request message for the current CPU;
[0052] Specifically, the process of obtaining the request message includes parsing, caching, and splitting the request message, and then internally distributing the split address and data information.
[0053] S2: Respond to request messages according to the current directory working mode and monitor the hit rate of request messages;
[0054] Specifically, the process of responding to a request message includes: parsing the tag portion and index from the message address of the request message according to the current directory working mode; performing tag matching according to the address mapping rules in the current directory working mode and recording and saving the matching results; and obtaining the current hit rate by dividing the number of hits by the number of hits in the current sampling period, using the number of hits as the numerator and the sum of the number of misses and hits as the denominator. The matching action can be implemented using a comparator, and the current matching results can be stored in FIFO format.
[0055] Specifically, in this embodiment, the group connection structure parameters of the directory working mode are adjustable. Therefore, the address mapping established by the group connection structure is a dynamically parsed address mapping, such as... Figure 2In the address mapping diagram shown, the address portion of a common request message has a total width of 40 bits. A dynamic address mapping method is used to determine the directory entry in the access message, where X>5. Bits [X:6] represent the index mapping portion, and this portion allows for adjustable mapping width, with the adjustable space complementing the Tag address bits. For the 64-byte 8-bit directory mode, the last 6 bits of the message address are the offset portion, used to determine the position of the 64-byte directory entry. In fact, in the 8-way set-associative cache line, the first 25 Data bits of the message address correspond to the Tag portion in the cache line, and the last 9 bits of the Tag portion correspond to the index of the cache line within the mapping group. For the variable directory cache configuration mode, the mapping widths of the Tag and Index portions in the cache line are dynamically adjusted to ensure correct matching of mapped messages in different modes.
[0056] Furthermore, during the tag matching process based on the address mapping rules in the current directory working mode, since the address bits of the tag are adjustable, it is necessary to perform a validity check on the message before matching. This validity check uses a flag bit to indicate whether the current directory working mode is available, providing a complete and feasible workflow for adjusting the group-connected structure parameters of the directory working mode in the following text, and avoiding mismatches that occur during the directory working mode switching process.
[0057] S3: Determine if the hit rate has reached the target hit rate;
[0058] S4: If not, adjust the group-linked structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode.
[0059] Understandably, if the hit rate reaches the target hit rate, that is, the current hit rate is greater than or equal to the target hit rate, then no adjustment will be made to the current directory working mode, and the remaining part of the corresponding request message can continue in the current directory working mode.
[0060] It is understandable that the hit rate is related to both the request message and the directory working mode. Under the same directory working mode, different request messages have different hit rates. When the hit rate is low, operations such as replacing or loading the missed data are required, which can cause cache access latency and lead to instability in the running speed of the upper-layer application. To reduce the possibility of this happening, this embodiment sets a target hit rate as the judgment standard. When the hit rate is lower than the target hit rate, the group-associative structure parameters of the current directory working mode are changed. The hit rate of the same request message when it is responded to changes with the group-associative structure parameters.
[0061] It is understood that the address mapping translation structure of the directory working mode in this embodiment is mainly a set-associative structure. For a set-associative structure, its necessary set-associative structure parameters include the number of rows and the number of groups. The number of rows and groups refers to the specification of the number of groups and the number of rows per group for cache lines in the cache. The number of rows and groups affects the frequency of cache line replacement and the cache hit rate. Generally speaking, increasing the number of groups can improve the cache line hit rate, and increasing the number of rows in the cache line can reduce the frequency of data replacement in the cache line, thereby improving the cache line hit rate. The specific settings for the number of groups and rows need to be determined based on the actual request message's read requirements for the cache.
[0062] Specifically, the unit capacity of a cache line is a fixed 256kb. For a 64-byte cache line, the total number of cache lines in a directly linked structure is 4096. For a cache line implementing an N-set linked structure, each cache line has 4096 / N lines. For directory operation modes with different numbers of sets and lines, the read / write addresses of the cache lines increment by N, starting from 0 to obtain the address of the first set 1, starting from 1 to obtain the address of the second set 2, and so on, until starting from N-1 to obtain the address of set N. Figure 3 As shown.
[0063] Furthermore, step S4, adjusting the group-associative structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode, includes:
[0064] First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
[0065] Understandably, in order to avoid the request message being responded to incorrectly during the adjustment of the group-association structure parameters, when adjusting the directory working mode, all cache lines are first set to an invalid state to avoid responding to request messages and retrieving data. Then, the group-association structure parameters are adjusted from the original parameters to the new target parameters. After re-enabling the buffer, the data in the cache lines is updated according to the adjusted directory working mode.
[0066] Understandably, after the group-linked structure parameters of the directory working mode change, all action parameters related to the group-linked structure parameters need to be adjusted accordingly to avoid data errors caused by inconsistencies in parameters between the two directory working modes.
[0067] Furthermore, the data replacement process in this embodiment is related to the group-associative structure parameters; therefore, the cache control method also includes:
[0068] Replace all cache lines using the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
[0069] Specifically, based on the adjustable directory working mode in this embodiment, the LRU (Least Recently Used) replacement algorithm can select a tree-structured variable replacement method, such as... Figure 4 As shown, the variable replacement algorithm uses a tree-structured algorithm, adjusting the leaf nodes in the selected tree structure based on the group-connected structure parameters of the current directory working mode. The tree-structured variable replacement algorithm is characterized by low hardware resource consumption. In implementing the algorithm, a binary tree structure that supports a maximum number of replacement paths is used. The maximum number of paths that can be replaced in the binary tree structure is L (L>=2), and the minimum number is 2. When data needs to be replaced, the algorithm increments from the root node L1 to the leaf nodes according to the current directory working mode. For example, when the number of groups in the group-connected structure changes to 2, nodes L2 and above are selected as the control nodes for the replacement algorithm; when the number of groups in the group-connected structure is 4, nodes L3 and above are selected, and so on. The replacement algorithm selects all node combinations applicable to the current directory working mode and their corresponding replacement algorithm rules, then dynamically adjusts them according to the group-connected structure parameters. When a replacement occurs, a swaying leaf node method is used to select nodes that have not been used recently, thus achieving the selection and replacement of cache line data.
[0070] This application discloses a cache control method, comprising: acquiring the current CPU request message; responding to the request message according to the current directory working mode and monitoring the hit rate of the request message; determining whether the hit rate reaches the target hit rate; if not, adjusting the group-associative structure parameters in the current directory working mode to respond to the remaining part of the request message according to the adjusted directory working mode. This application, by monitoring the hit rate of the request message during the response process and adjusting the group-associative structure parameters of target working modes with hit rates below the target hit rate, achieves the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost.
[0071] This invention discloses a specific cache control method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution.
[0072] In some specific embodiments, the action of adjusting the group-associative structure parameters of the directory working mode in this embodiment can be performed in advance according to the type of the request message when the request message is received. Specifically, after obtaining the request message of the current CPU in step S1, it includes:
[0073] Determine the group-associative structure parameters of the current directory working mode based on the type of the request message;
[0074] The types of request messages include contiguous memory read / write type and non-contiguous memory read / write type.
[0075] In some specific embodiments, the action of adjusting the group-associative structure parameters of the directory working mode in this embodiment can also be triggered by external mode instructions. The cache control method also includes:
[0076] Receive mode command;
[0077] Adjust the group-linked structure parameters in the current directory working mode according to the mode instructions, so as to respond to the remainder of the request message in accordance with the adjusted directory working mode.
[0078] In some specific embodiments, the action of adjusting the group-associative structure parameters of the directory working mode in this embodiment can also select a set of group-associative structure parameters with better performance based on the hit rate during the adjustment process. The cache control method also includes:
[0079] Monitor the hit rate of request messages when responding to request messages in the current directory working mode;
[0080] Determine if the hit rate has reached the target hit rate;
[0081] If not, perform the following actions until the hit rate reaches the target hit rate:
[0082] Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode.
[0083] Furthermore, cache control methods also include:
[0084] If the hit rate for all directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate will be selected from all directory working modes to respond to the remainder of the request message.
[0085] Understandably, when continuously adjusting the group-linked structure parameters of the directory working mode, the process can proceed according to the pre-set priority order. The directory working mode can be adjusted to the highest priority group-linked structure parameter, and then changed to a lower priority group-linked structure parameter, until the hit rate of the current directory working mode reaches the target hit rate. If the hit rate of all preset selectable group-linked structure parameters does not reach the target hit rate during implementation, the directory working mode with the highest hit rate is selected to run in order to respond to the remaining part of the request message.
[0086] It is understandable that, in addition to the three methods mentioned above for determining the directory working mode, other adjustment conditions can be set to determine the group-connected structure parameters. Specifically, these can be set according to the operating rules and working requirements of the upper-layer application, request messages, and cache, and are not restricted here.
[0087] Accordingly, embodiments of this application also disclose a cache control system, see [link to relevant documentation]. Figure 5 As shown, it includes:
[0088] Module 1 is used to obtain the request message of the current CPU;
[0089] Response module 2 is used to respond to the request message according to the current directory working mode and monitor the hit rate of the request message;
[0090] Module 3 is used to determine whether the hit rate has reached the target hit rate;
[0091] Action module 4 is used to adjust the group-connected structure parameters in the current directory working mode if the result of the judgment module is negative, so as to trigger the response module to respond to the remaining part of the request message according to the current directory working mode.
[0092] Understandably, if the hit rate reaches the target hit rate, that is, the current hit rate is greater than or equal to the target hit rate, then no adjustment will be made to the current directory working mode, and the remaining part of the corresponding request message can continue in the current directory working mode.
[0093] It is understandable that the hit rate is related to both the request message and the directory working mode. Under the same directory working mode, different request messages have different hit rates. When the hit rate is low, operations such as replacing or loading the missed data are required, which can cause cache access latency and lead to instability in the running speed of the upper-layer application. To reduce the possibility of this happening, this embodiment sets a target hit rate as the judgment standard. When the hit rate is lower than the target hit rate, the group-associative structure parameters of the current directory working mode are changed. The hit rate of the same request message when it is responded to changes with the group-associative structure parameters.
[0094] This application embodiment monitors the hit rate of request messages during the response process and adjusts the group-connected structure parameters of target working modes with hit rates below the target hit rate, thereby achieving the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost.
[0095] In some specific embodiments, the response module 2 is also used to monitor the hit rate of the request message when the current directory working mode responds to the request message;
[0096] The judgment module 3 is also used to determine whether the hit rate reaches the target hit rate;
[0097] If not, then action module 4 is triggered to perform the following actions until the hit rate reaches the target hit rate:
[0098] Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode.
[0099] In some specific embodiments, the action module 4 is also used for:
[0100] If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
[0101] In some specific embodiments, after obtaining the request message of the current CPU, the acquisition module 1 includes:
[0102] Based on the type of the request message, determine the group-connected structure parameters of the current directory working mode;
[0103] The types of the request messages include continuous memory read / write type and non-continuous memory read / write type.
[0104] In some specific embodiments, the action module 4 is also used for:
[0105] Receive mode command;
[0106] Adjust the group-connected structure parameters in the current directory working mode according to the mode instruction, so as to respond to the remainder of the request message according to the adjusted directory working mode.
[0107] It is understandable that, in addition to the three methods mentioned above for determining the directory working mode, other adjustment conditions can be set to determine the group-connected structure parameters. Specifically, these can be set according to the operating rules and working requirements of the upper-layer application, request messages, and cache, and are not restricted here.
[0108] In some specific embodiments, action module 4 is specifically used for:
[0109] First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
[0110] Understandably, in order to avoid the request message being responded to incorrectly during the adjustment of the group-association structure parameters, when adjusting the directory working mode, all cache lines are first set to an invalid state to avoid responding to request messages and retrieving data. Then, the group-association structure parameters are adjusted from the original parameters to the new target parameters. After re-enabling the buffer, the data in the cache lines is updated according to the adjusted directory working mode.
[0111] Understandably, after the group-linked structure parameters of the directory working mode change, all action parameters related to the group-linked structure parameters need to be adjusted accordingly to avoid data errors caused by inconsistencies in parameters between the two directory working modes.
[0112] In some specific embodiments, the action module 4 is also used for:
[0113] All cache lines are replaced according to the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
[0114] This application also discloses an electronic device, see [link to relevant documentation] Figure 6 As shown, it includes a processor 11 and a memory 12; wherein, when the processor 11 executes the computer program stored in the memory 12, it performs the following steps:
[0115] Get the request message for the current CPU;
[0116] Respond to the request message according to the current directory working mode, and monitor the hit rate of the request message;
[0117] Determine whether the hit rate has reached the target hit rate;
[0118] If not, adjust the group-connected structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode.
[0119] This application embodiment monitors the hit rate of request messages during the response process and adjusts the group-connected structure parameters of target working modes with hit rates below the target hit rate, thereby achieving the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost.
[0120] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0121] Monitor the hit rate of the request message when the current directory working mode responds to the request message;
[0122] Determine whether the hit rate reaches the target hit rate;
[0123] If not, then perform the following actions until the hit rate reaches the target hit rate:
[0124] Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode.
[0125] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0126] If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
[0127] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0128] Based on the type of the request message, determine the group-connected structure parameters of the current directory working mode;
[0129] The types of the request messages include continuous memory read / write type and non-continuous memory read / write type.
[0130] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0131] Receive mode command;
[0132] Adjust the group-connected structure parameters in the current directory working mode according to the mode instruction, so as to respond to the remainder of the request message according to the adjusted directory working mode.
[0133] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0134] First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
[0135] In some specific embodiments, when the processor 11 executes the computer subroutine stored in the memory 12, it may specifically implement the following steps:
[0136] All cache lines are replaced according to the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
[0137] Furthermore, the electronic device in this embodiment may also include:
[0138] Input interface 13 is used to acquire computer programs imported from external sources and save the acquired computer programs to the memory 12. It can also be used to acquire various instructions and parameters transmitted from external terminal devices and transmit them to the processor 11 so that the processor 11 can perform corresponding processing using the aforementioned instructions and parameters. In this embodiment, the input interface 13 may specifically include, but is not limited to, a USB interface, a serial interface, a voice input interface, a fingerprint input interface, a hard disk read interface, etc.
[0139] Output interface 14 is used to output various data generated by processor 11 to connected terminal devices, so that other terminal devices connected to output interface 14 can obtain various data generated by processor 11. In this embodiment, output interface 14 may specifically include, but is not limited to, USB interface, serial interface, etc.
[0140] The communication unit 15 is used to establish a remote communication connection between the electronic device and the external server, so that the electronic device can mount the image file to the external server. In this embodiment, the communication unit 15 may specifically include, but is not limited to, a remote communication unit based on wireless communication technology or wired communication technology.
[0141] Keyboard 16 is used to acquire various parameter data or commands input by the user through real-time keystrokes.
[0142] Display 17 is used to display relevant information about the cache control process in real time, so that users can understand the current cache control status in a timely manner.
[0143] Mouse 18 can be used to assist users in inputting data and simplify user operations.
[0144] Furthermore, embodiments of this application also disclose a computer-readable storage medium, which includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable hard disk, CD-ROM, or any other form of storage medium known in the art. The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the following steps:
[0145] Get the request message for the current CPU;
[0146] Respond to the request message according to the current directory working mode, and monitor the hit rate of the request message;
[0147] Determine whether the hit rate has reached the target hit rate;
[0148] If not, adjust the group-connected structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode.
[0149] This application embodiment monitors the hit rate of request messages during the response process and adjusts the group-connected structure parameters of target working modes with hit rates below the target hit rate, thereby achieving the effect of improving the overall hit rate of request messages and reducing the probability of access latency at a lower cost.
[0150] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0151] Monitor the hit rate of the request message when the current directory working mode responds to the request message;
[0152] Determine whether the hit rate reaches the target hit rate;
[0153] If not, then perform the following actions until the hit rate reaches the target hit rate:
[0154] Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode.
[0155] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0156] If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
[0157] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0158] Based on the type of the request message, determine the group-connected structure parameters of the current directory working mode;
[0159] The types of the request messages include continuous memory read / write type and non-continuous memory read / write type.
[0160] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0161] Receive mode command;
[0162] Adjust the group-connected structure parameters in the current directory working mode according to the mode instruction, so as to respond to the remainder of the request message according to the adjusted directory working mode.
[0163] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0164] First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
[0165] In some specific embodiments, when the computer subroutine stored in the computer-readable storage medium is executed by a processor, it can specifically perform the following steps:
[0166] All cache lines are replaced according to the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
[0167] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0168] The above provides a detailed description of a high-speed cache control method, system, and related components provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A cache control method, characterized in that, include: Get the request message for the current CPU; Respond to the request message according to the current directory working mode, and monitor the hit rate of the request message; Determine whether the hit rate has reached the target hit rate; If not, the group-connected structure parameters in the current directory working mode are adjusted to respond to the remaining part of the request message according to the adjusted directory working mode; wherein, the group-connected structure parameters of the directory working mode are adjustable, and the address mapping established by the group-connected structure is a dynamically split address mapping; the directory entry in the access message is determined by dynamically dividing the address mapping; the mapping bit width of the index mapping part is adjustable, and the adjustable space is complementary to the address bits of the tag part; in the variable directory cache configuration mode, the mapping bit width of the tag part and the mapping bit width of the index part in the cache line are dynamically adjusted to ensure that the mapped message can be matched normally in different modes; Correspondingly, it also includes: Monitor the hit rate of the request message when the current directory working mode responds to the request message; Determine whether the hit rate reaches the target hit rate; If not, then perform the following actions until the hit rate reaches the target hit rate: Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode; Correspondingly, it also includes: If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
2. The cache control method according to claim 1, characterized in that, After obtaining the request message for the current CPU, the following is included: Based on the type of the request message, determine the group-connected structure parameters of the current directory working mode; The types of the request messages include continuous memory read / write type and non-continuous memory read / write type.
3. The cache control method according to claim 1, characterized in that, Also includes: Receive mode command; Adjust the group-connected structure parameters in the current directory working mode according to the mode instruction, so as to respond to the remainder of the request message according to the adjusted directory working mode.
4. The cache control method according to any one of claims 1 to 3, characterized in that, The process of adjusting the group-associative structure parameters in the current directory working mode to respond to the remainder of the request message according to the adjusted directory working mode includes: First, invalidate all cache lines in the cache, adjust the group-associative structure parameters in the current directory working mode, and then re-enable and update the data of all cache lines according to the current directory working mode and the remaining part of the request message.
5. The cache control method according to claim 4, characterized in that, Also includes: All cache lines are replaced according to the LRU replacement algorithm corresponding to the group-associative structure parameters in the current directory working mode.
6. A high-speed cache control system, characterized in that, include: The acquisition module is used to acquire the request message of the current CPU; The response module is used to respond to the request message according to the current directory working mode and monitor the hit rate of the request message; The judgment module is used to determine whether the hit rate has reached the target hit rate; An action module is used to adjust the group-connected structure parameters in the current directory working mode if the judgment module result is negative, so as to trigger the response module to respond to the remaining part of the request message according to the current directory working mode. The group-connected structure parameters of the directory working mode are adjustable, and the address mapping established by the group-connected structure is a dynamically split address mapping. Dynamic address mapping is used to determine the directory entries in the access message. The index mapping part has an adjustable mapping bit width, and the adjustable space is complementary to the address bits of the tag part. In the variable directory cache configuration mode, the mapping bit width of the tag part and the mapping bit width of the index part in the cache line are dynamically adjusted to ensure that the mapped messages can be matched correctly in different modes. Correspondingly, it also includes: Monitor the hit rate of the request message when the current directory working mode responds to the request message; Determine whether the hit rate reaches the target hit rate; If not, then perform the following actions until the hit rate reaches the target hit rate: Adjust the group-connected structure parameters of the current directory working mode, and respond to the remainder of the request message according to the adjusted directory working mode; Correspondingly, it also includes: If the hit rate for all the directory working modes fails to reach the target hit rate, then the directory working mode with the highest hit rate is selected from all the directory working modes to respond to the remainder of the request message.
7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the cache control method as described in any one of claims 1 to 5 when executing the computer program.
8. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the cache control method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Directory cache method for node control chip in cache coherent non-uniform memory access (CC-NUMA) system
CN102708190A
Configurable cache system
CN106326147A