Data block status acquisition method, device and electronic device
By using the shared cache to obtain data blocks and determine their status in a multi-level cache system, the problem of large consistency maintenance workload in a multi-level cache system is solved, the hit rate is improved, and cache waste is reduced.
Patent Information
- Application Number
- CN202411096640.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-12
AI Technical Summary
In a multi-level cache system, maintaining the consistency workload of private caches and shared caches of multiple processor cores is relatively large, resulting in a waste of storage resources and a low hit rate.
When a read fails in the first-level private cache and the second-level private cache, the shared cache is used to obtain the data block, and its status is determined based on the count value of the data block, thereby reducing the consistency maintenance workload and cache waste, and improving the hit rate.
It effectively reduces the consistency maintenance workload of the multi-level cache system, reduces the waste of cache capacity, and improves the hit rate of memory access requests.
Smart Images

Figure CN118626413B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device and electronic device for obtaining the status of a data block. Background Art
[0002] With the development of technology, the number of processor cores integrated on a chip is increasing. In order to enable the on-chip multi-level cache storage system to provide data to multiple processor cores at the same time, it is necessary to perform consistency maintenance on the multi-level cache system.
[0003] However, maintaining the consistency of storage information in private caches and shared caches on multiple processor cores is a heavy task and may lead to a waste of some storage resources in a multi-level cache system. Summary of the invention
[0004] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0005] To this end, a first aspect of the present application proposes a method for obtaining the status of a data block.
[0006] A second aspect of the present application provides a device for obtaining the status of a data block.
[0007] According to a third aspect of the present application, a data storage device of a multi-level cache system is provided.
[0008] A fourth aspect of the present application provides an electronic device.
[0009] A fifth aspect of the present application provides a computer-readable storage medium.
[0010] In a first aspect, the present application proposes a method for obtaining the status of a data block, the method comprising: in response to a first read request failing to read in a first-level private cache and a second-level private cache, obtaining a first data block returned by the first read request through a shared cache; obtaining a first count value of the first data block, and obtaining a first data block status of the first data block based on the first count value.
[0011] The second aspect of the present application proposes a data block status acquisition device, characterized in that the device includes: a first acquisition module, used to respond to a read failure of a first read request in a first-level private cache and a second-level private cache, and obtain a first data block returned by the first read request through a shared cache; a second acquisition module, used to obtain a first count value of the first data block, and obtain a first data block status of the first data block according to the first count value.
[0012] The third aspect of the present application proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for obtaining the status of a data block proposed in the first aspect above is implemented.
[0013] To achieve the above-mentioned purpose, the fourth aspect of the present application proposes a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for obtaining the status of a data block proposed in the first aspect above is implemented.
[0014] The data block status acquisition method, device and electronic device of the embodiment of the present application obtains the first data block of the first read request through the shared cache when the first read request fails to read in the first-level private cache and the second-level private cache, and obtains the first data block status of the first data block according to the first count value of the first data block. In the present application, when the first read request fails to read in the first-level private cache and the second-level private cache, the first data block is obtained through the shared cache, and the first data block status of the first data block is determined according to the first count value of the first data block, which reduces the workload of consistency maintenance of the multi-level cache system, thereby reducing the waste of cache capacity and improving the hit rate of memory access requests in the multi-level cache.
[0015] It should be understood that the contents described in this application are not intended to identify the key or important features of the embodiments of this application, nor are they intended to limit the scope of this application. Other features of this application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0017] Figure 1 A schematic diagram of a flow chart of a method for obtaining a state of a data block according to an embodiment of the present application;
[0018] Figure 2 A schematic diagram of a flow chart of a method for obtaining a state of a data block according to another embodiment of the present application;
[0019] Figure 3 A schematic diagram of a flow chart of a method for obtaining a state of a data block according to another embodiment of the present application;
[0020] Figure 4 This is a structural diagram of a device for acquiring the state of a data block according to an embodiment of the present application;
[0021] Figure 5 It is a structural schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0023] Figure 1 FIG. 1 is a flow chart of a method for obtaining the state of a data block according to an embodiment of the present application. Figure 1 As shown, the method includes:
[0024] S101 , in response to a first read request failing to read in a first-level private cache and a second-level private cache, obtaining a first data block returned by the first read request through a shared cache.
[0025] In an embodiment of the present application, a multi-level cache system may include multiple processor cores, wherein each processor core may be provided with multiple private caches.
[0026] As an example, in Figure 2 In the multi-level cache storage system shown in FIG. Figure 2 The first-level private cache, the second-level private cache, and the shared cache are shown, wherein: Figure 2 The first level private cache and the second level private cache shown are Figure 2 Two private caches on processor core 1 are shown.
[0027] It should be noted that in Figure 2 The scenario shown also includes a routing node, through Figure 2 The routing nodes shown can implement the first-level private cache, the second-level private cache, and Figure 2 The data interaction between the shared caches shown in the figure is then constructed. Figure 2 A multi-level cache storage system is shown.
[0028] In this example, the L2 private cache and the L1 private cache may maintain an inclusive relationship (Inclusive), not maintain an inclusive relationship (Non-Inclusive), or a non-inclusive relationship (Exclusive).
[0029] Among them, maintaining the inclusion relationship can be understood as that the data blocks in the first-level private cache all exist in the second-level private cache, not maintaining the inclusion relationship can be understood as that the data blocks in the first-level private cache may or may not exist in the second-level private cache, and the non-inclusion relationship can be understood as that the data blocks in the first-level private cache do not exist in the second-level private cache.
[0030] It should be noted that the inclusion relationship is not maintained between the first-level private cache and the second-level private cache on any processor core in the multi-level cache system proposed in the embodiments of the present application.
[0031] It can be understood that a data block in the first-level private cache on any processor core in the multi-level cache system proposed in the embodiment of the present application may or may not exist in the second-level private cache on the same processor core.
[0032] In the embodiment of the present application, an access request for reading a data block in a multi-level cache system may be marked as a first read request of the multi-level cache system.
[0033] Optionally, a multi-level cache system can be constructed based on a first-level private cache, a second-level private cache, and a shared cache. The first read request can access the first-level private cache. The first read request may miss the first-level private cache, and then it can be determined that the first read request fails in the first-level private cache.
[0034] In this scenario, the first-level private cache can send an access request corresponding to the first read request to the second-level private cache, where the access request may not hit in the second-level private cache, and then it can be determined that the first read request failed in the second-level private cache.
[0035] It can be understood that when the first read request does not hit in both the first-level private cache and the second-level private cache, it can be determined that the first read request fails to read in the first-level private cache and the second-level private cache.
[0036] In an embodiment of the present application, when the first read request fails in the first-level private cache and the second-level private cache, the shared cache in the multi-level cache system can be accessed and / or the private cache on other processor cores can be accessed through the shared cache and / or the memory can be accessed through the shared cache, thereby obtaining the access data block of the first read request in the multi-level cache system.
[0037] The data block may be marked as the first data block accessed by the first read request in the multi-level cache system.
[0038] S102: Acquire a first count value of a first data block, and acquire a first data block state of the first data block according to the first count value.
[0039] In the embodiment of the present application, the first data block has a corresponding storage state in the multi-level cache system, wherein the storage state of the first data block in the multi-level cache system can be marked as the first data block state of the first data block.
[0040] Optionally, the first data block has a count value, which may be marked as a first count value, wherein the first count value may be understood as a record value of the number of times the first data block is modified.
[0041] In this scenario, a preset count value analysis strategy may be obtained, and the first count value may be analyzed based on the strategy, so as to determine the first data block state of the first data block according to the analysis result.
[0042] It should be noted that the state of the first data block can be a shared state or an exclusive state.
[0043] Among them, in the scenario where the first data block state of the first data block is in a shared state, when a read request on other processor cores misses, the first data block can be used to effectively respond to the read request on the processor core that missed, thereby reducing the workload of consistency maintenance of the multi-level cache system to a certain extent.
[0044] Furthermore, when the first data block state of the first data block is in an exclusive state, the processing core to which it belongs can perform a write operation on it. When the processor core receives a write request for the first data block, it can directly hit it, thereby achieving the purpose of reducing the workload of consistency maintenance of the multi-level cache system to a certain extent.
[0045] The data block status acquisition method proposed in the present application obtains the first data block of the first read request through the shared cache when the first read request fails to read in the first-level private cache and the second-level private cache, and obtains the first data block status of the first data block according to the first count value of the first data block. In the present application, when the first read request fails to read in the first-level private cache and the second-level private cache, the first data block is obtained through the shared cache, and the first data block status of the first data block is determined according to the first count value of the first data block, which reduces the workload of consistency maintenance of the multi-level cache system, thereby reducing the waste of cache capacity and improving the hit rate of memory access requests in the multi-level cache.
[0046] In the above embodiment, regarding obtaining the first data block state of the first data block according to the first count value, it can be combined with Figure 3 Further understanding, Figure 3 FIG. 1 is a flow chart of a method for obtaining the state of a data block according to another embodiment of the present application. Figure 3 As shown, the method includes:
[0047] S301 , in response to a first read request failing to read in a first-level private cache and a second-level private cache, obtaining a first data block returned by the first read request through a shared cache.
[0048] Optionally, in response to a read failure of the first read request in the first-level private cache and the second-level private cache, a second read request is generated and sent to the shared cache.
[0049] In the embodiment of the present application, a preset invalidation determination strategy can be obtained, and based on the access status of the first read request in the first-level private cache, it is determined whether the first read request is invalidated in the first-level private cache.
[0050] In response to the first read request not hitting the first-level private cache, it is determined that the first read request fails to read the first-level private cache.
[0051] It can be understood that whether the first read request hits in the first-level private cache can be determined as an invalidation judgment strategy for determining whether the first read request has failed in the first-level private cache, wherein when the first read request does not hit in the first-level private cache, it can be determined that the first read request has failed in the first-level private cache.
[0052] Optionally, in response to the second data block existing in the first-level private cache and the second data block is not in an invalid state in the first-level private cache, it is determined that the first read request hits in the first-level private cache.
[0053] It can be understood that when the second data block that the first read request wants to access in the first-level private cache exists and is valid in the first-level private cache, it can be determined that the first read request can obtain the information of the second data block. In this scenario, it can be determined that the first read request hits the first-level private cache.
[0054] In the embodiment of the present application, there are multiple data block states for data blocks in the multi-level cache system, wherein the state of the data block in the multi-level cache system can be identified according to identification information on the state bit of the data block.
[0055] As an example, the identification information on the status bit of the data block is set to be one of an invalid status (INV) identification, a shared status (SHD) identification, and an exclusive status (EXC) identification.
[0056] In this example, when the identification information on the status bit of the second data block is INV identification information, it can be determined that the second data block is in an invalid state in the first-level private cache.
[0057] Furthermore, when the identification information on the status bit of the second data block is SHD identification information, it can be determined that the second data block is in a shared state in the first-level private cache.
[0058] Furthermore, when the identification information on the status bit of the second data block is EXC identification information, it can be determined that the second data block is in an exclusive state in the first-level private cache.
[0059] It can be understood that when the second data block that the first read request wants to access in the first-level private cache is in a state other than an invalid state in the first-level private cache, it can be determined that the first read request can obtain the information of the second data block. In this scenario, it can be determined that the first read request hits the first-level private cache.
[0060] In this scenario, the second data block can be used as the first data block of the first read request.
[0061] It should be noted that, in the scenario where the data block is in a shared state, when the processor core reads the block, a direct hit occurs, and a write failure occurs when writing the block. In the scenario where the data block is in an exclusive state, the processor directly hits when reading and writing the data block.
[0062] From this, it can be seen that the second data block accessed in the first-level private cache in response to the first read request does not exist in the first-level private cache, or the second data block is in an invalid state in the first-level private cache, and it is determined that the first read request does not hit in the first-level private cache.
[0063] Among them, the data block that the first read request wants to access in the first-level private cache can be marked as the second data block. In this scenario, when the second data block does not exist in the first-level private cache, it can be determined that the first read request does not hit in the first-level private cache.
[0064] Furthermore, when the second data block of the first read request is in an invalid state in the first-level private cache, it can be determined that the first read request does not hit in the first-level private cache.
[0065] In an embodiment of the present application, when a first read request fails in the first-level private cache, a third read request corresponding to the first read request can be generated based on an access request generation method in related technologies and sent to the second-level private cache.
[0066] It can be understood that the third read request is an access request generated by the first-level private cache and can convey the access requirement of the first read request to the second-level private cache.
[0067] Optionally, in response to a third read request corresponding to the first read request not hitting in the secondary private cache, it is determined that a first read request corresponding to the third read request is read invalid in the secondary private cache.
[0068] Among them, in response to the third read request, the third data block accessed in the secondary private cache does not exist in the secondary private cache, or the third data block is not in an exclusive state or a shared state in the secondary private cache, and it is determined that the first read request corresponding to the third read request does not hit in the secondary private cache.
[0069] In an embodiment of the present application, the data block that the third read request wants to access in the secondary private cache can be marked as the third data block. In this scenario, when the third data block does not exist in the secondary private cache, it can be determined that the third read request corresponding to the first read request is invalid in the secondary private cache.
[0070] Accordingly, the data block status of the third data block in the secondary private cache can be obtained. When the status of the third data block in the secondary private cache cannot support the access of the third read request, it can be determined that the third read request corresponding to the first read request is invalid in the secondary private cache.
[0071] The state in which the third data block cannot support the access of the third read request in the secondary private cache may include other data block states except the shared state and the exclusive state.
[0072] Optionally, in response to the third data block being in a shared state or an exclusive state in the secondary private cache, it is determined that the first read request corresponding to the third read request hits in the secondary private cache.
[0073] In this scenario, it can be determined that the third read request can read the required data block in the secondary private cache.
[0074] Further, it can be determined that the first read request corresponding to the third read request hits in the secondary private cache. In this scenario, the data block can be used as the first data block of the first read request corresponding to the third read request.
[0075] From this, it can be seen that when the third data block is not in an exclusive state or a shared state in the secondary private cache, it can be determined that the data block cannot be read by other private caches, and the data block cannot be used as the first data block of the first read request, and further it can be determined that the first read request did not hit in the secondary private cache.
[0076] Optionally, a second data block corresponding to the second read request is obtained through the shared cache as the first data block corresponding to the first read request.
[0077] In an embodiment of the present application, after the first read request fails in the first-level private cache and the second-level private cache, the first data block of the first read request can be queried and obtained from the shared cache, the private cache on other processor cores, or the memory through the shared cache of the multi-level cache system.
[0078] It should be noted that in an embodiment of the present application, when a first read request fails in the first-level private cache and the second-level private cache, before a second read request is generated and sent to the shared cache, the cache directory of the multi-level cache system can be accessed to determine the detailed information of the first data block required for the first read request in the multi-level cache system.
[0079] In an embodiment of the present application, there is a cache directory in the multi-level cache system, wherein an inclusion relationship is not maintained between the cache directory and a shared cache of the multi-level cache system.
[0080] Optionally, in response to a read failure of the first read request in the first-level private cache and the second-level private cache, a fourth read request is generated and sent to the cache directory of the multi-level cache system, and in response to the fourth read request missing the cache directory, a second read request is generated based on the fourth read request and sent to the shared cache.
[0081] In an embodiment of the present application, the read request of the cache directory of the multi-level cache system generated after the first-level private cache and the second-level private cache read failure can be marked as the fourth read request, wherein the fourth read request can be sent to the cache directory of the multi-level cache system to obtain detailed information of the first data block.
[0082] In this scenario, the directory information accessed by the fourth read request in the cache directory can be marked as access target information of the fourth read request, wherein, in response to the data block record status indicated in the access target information of the fourth read request in the cache directory being valid-dirty or valid-clean, it is determined that the fourth read request hits in the cache directory, and a write-back request is sent to the secondary private cache to which the data block corresponding to the data block record status belongs.
[0083] In an embodiment of the present application, when the access target information corresponding to the fourth read request in the cache directory indicates that the data block required to be accessed by the first read request is in a valid-dirty or valid-clean state in the multi-level cache system, it can be understood that the access target information of the fourth read request in the cache directory exists, and it can be known that the fourth read request hits in the cache directory.
[0084] In this scenario, when the data block record status indicated in the access target information is valid-dirty or valid-clean, it can be determined that the data block can be used as the first data block returned to the first read request. Furthermore, a write-back request can be sent to the secondary private cache to which the data block belongs to obtain the first data block of the first read request through the shared cache.
[0085] Accordingly, in response to the access target information of the fourth read request not existing in the cache directory, or the fourth data block corresponding to the fourth read request is recorded as invalid in the cache directory, it is determined that the fourth read request does not hit in the cache directory.
[0086] It can be understood that when the access target information of the fourth read request does not exist in the cache directory, it can be determined that the fourth read request did not obtain the required target information, and thus it can be determined that the fourth read request did not hit in the cache directory.
[0087] Correspondingly, when the operation data block corresponding to the fourth read request in the multi-level cache storage system is recorded as an invalid state in the corresponding directory record information in the cache directory, it can also be determined that the fourth read request did not hit in the cache directory, wherein the corresponding operation data block of the fourth read request in the multi-level cache storage system can be marked as the fourth data block.
[0088] Optionally, a first data block is obtained from a shared cache and / or memory, wherein, in response to the existence of a unique backup data block for the first data block, a second data block state of the first data block is determined to be a shared state.
[0089] In the embodiment of the present application, when the fourth read request does not hit in the cache directory, the corresponding data block can be obtained from the shared cache and / or memory of the multi-level cache storage system as the first data block.
[0090] Optionally, the first data block can be stored in the first-level private cache accessed by the first read request, and / or in the first-level private cache and the corresponding second-level private cache. In this scenario, the storage status of the first data block also needs to be determined, wherein the storage status of the first data block in this scenario can be marked as the second data block status.
[0091] The relevant state of the first data block may be identified, and when it is identified that the first data block has a unique backup data block in the multi-level cache storage system, the second data block state of the first data block may be marked as a shared state.
[0092] Optionally, in response to the first data block being written, a second count value of the first data block being written is acquired, and when the second count value is greater than or equal to a preset count value threshold, the second data block state of the first data block is adjusted to an exclusive state.
[0093] It can be understood that when a write operation occurs to the first data block in the shared state subsequently, the number of write operations can be recorded as the second count value, and whether the second data block state of the first data block needs to be adjusted can be determined based on the second count value.
[0094] When the second count value is less than a preset count value threshold, it can be determined that the second data block state can remain in a shared state without adjustment.
[0095] Correspondingly, when the second count value is greater than or equal to the preset count value threshold, it can be determined that the second data block state needs to be adjusted, and the second data block state of the first data block can be adjusted from a shared state to an exclusive state.
[0096] S302: Obtain a first count value of a first data block, and obtain a first data block state of the first data block according to the first count value.
[0097] In the embodiment of the present application, the first count value of the first data block can be obtained through a counter, wherein the threshold of the counter can be configured through software or set to a fixed value.
[0098] As an example, the counter can be further understood in conjunction with the following table.
[0099] Valid ID Valid ID (1 bit) (1 bit) Data block addressData block address (31 bits) (31 bits) Count valueCount value (4 digits) (4 digits) …… 1 0x0f75dde0 0x0 …… 1 0x1802d795 0xf …… 1 0x083c6200 0x7 …… 1 0x1f75da00 0xf …… …… …… …… ……
[0100] In the above table, the storage position of the data block counted by the counter in the multi-level cache system can be determined by the data block address shown in the table, the number of times the corresponding data block is modified can be determined by the count value shown in the table, and whether the corresponding data block is in a valid state can be determined by the valid identification bit shown in the table.
[0101] Taking the first data block as an example, the data block located in the fourth row in the above table is set as the first data block. It can be seen from the above table that the first data block is in a valid state, and the address information of the first data block in the multi-level cache system is "0x1f75da00", and the number of times the first data block is currently modified is "0xf". In this scenario, it can be determined that the first count value of the first data block is the corresponding value of "0xf".
[0102] Optionally, in response to the first count value being greater than or equal to a preset count value threshold, it is determined that the first data block state of the first data block is an exclusive state.
[0103] Among them, for the first data block on any processor core, when the first count value of the first data block is greater than or equal to the count value threshold, it can be determined that the number of write request accesses to the first data block on the processor core within the set historical time range may be greater than the number of accesses of other types of requests. In this scenario, the first data block state of the first data block can be determined as an exclusive state.
[0104] It should be noted that, in the scenario where the state of the first data block is adjusted to the exclusive state, when the processor core receives an access instruction of a write request for the first data block again, the instruction can be directly hit on the processor core.
[0105] Optionally, in response to the first count value being less than a count value threshold, it is determined that the first data block state of the first data block is a shared state.
[0106] When the first count value is less than the count value threshold, the information in the first data block does not meet the state adjustment condition for the processor core to exclusively occupy the data block, and the state of the first data block can be adjusted to a shared state.
[0107] It can be understood that if the number of write request accesses received by the first data block on the processor core within the set historical time range is small, the first data block state of the first data block can be marked as a shared state.
[0108] It should be noted that, in the scenario where the state of the first data block is marked as a shared state, when a read request for the first data block received on other processing cores does not hit, the first data block can be obtained from the processor core.
[0109] It should be noted that there is a preset clearing strategy for the first count value, wherein, in response to identifying that the first count value satisfies the preset clearing strategy, the value of the first count value is determined to be 0, and in response to the value of the first count value being 0, the state of the first data block is determined to be unchanged.
[0110] It can be understood that when the first count value satisfies the preset clearing strategy, the value of the first count value can be adjusted to 0. In this scenario, when the first data block state of the first data block is an exclusive state, the exclusive state remains unchanged, or when the first data block state of the first data block is a shared state, the exclusive state remains unchanged.
[0111] The data block status acquisition method proposed in the present application obtains the first data block through the shared cache when the first read request fails to read in the first-level private cache and the second-level private cache, and determines the first data block status of the first data block according to the first count value of the first data block, thereby reducing the workload of consistency maintenance of the multi-level cache system, thereby reducing the waste of cache capacity and improving the hit rate of memory access requests in the multi-level cache.
[0112] Corresponding to the data block status acquisition methods proposed in the above-mentioned embodiments, an embodiment of the present application also proposes a data block status acquisition device. Since the data block status acquisition device proposed in the embodiment of the present application corresponds to the data block status acquisition methods proposed in the above-mentioned embodiments, the implementation method of the above-mentioned data block status acquisition method is also applicable to the data block status acquisition device proposed in the embodiment of the present application, and will not be described in detail in the following embodiments.
[0113] Figure 4 FIG. 1 is a schematic diagram of a device for acquiring a state of a data block according to an embodiment of the present application. Figure 4As shown, the data block status acquisition device 400 includes a first acquisition module 41 and a second acquisition module 42, wherein:
[0114] The first acquisition module 41 is configured to acquire, through a shared cache, a first data block returned by the first read request in response to a read failure of the first read request in the first-level private cache and the second-level private cache.
[0115] The second acquisition module 42 is configured to acquire a first count value of the first data block, and acquire a first data block state of the first data block according to the first count value.
[0116] In the embodiment of the present application, the second acquisition module 42 is further used to: in response to the first count value being greater than or equal to a preset count value threshold, determine that the first data block state of the first data block is an exclusive state; in response to the first count value being less than the count value threshold, determine that the first data block state of the first data block is a shared state.
[0117] In the embodiment of the present application, the second acquisition module 42 is further used to: in response to identifying that the first count value satisfies a preset clearing strategy, determine that the value of the first count value is 0.
[0118] In the embodiment of the present application, the second acquisition module 42 is further used to: in response to the first count value being 0, determine that the state of the first data block is unchanged.
[0119] In the embodiment of the present application, the first acquisition module 41 is further used to: in response to the first read request failing to read in the first-level private cache and the second-level private cache, generate a second read request and send it to the shared cache, and obtain the second data block corresponding to the second read request through the shared cache as the first data block corresponding to the first read request.
[0120] In the embodiment of the present application, the first acquisition module 41 is further used to: in response to the first read request not hitting in the first-level private cache, determine that the first read request is read invalid in the first-level private cache. In response to the third read request corresponding to the first read request not hitting in the second-level private cache, determine that the first read request corresponding to the third read request is read invalid in the second-level private cache.
[0121] In an embodiment of the present application, the first acquisition module 41 is also used to: in response to the second data block accessed by the first read request in the first-level private cache not existing in the first-level private cache, or the second data block is in an invalid state in the first-level private cache, determine that the first read request does not hit in the first-level private cache.
[0122] In an embodiment of the present application, the first acquisition module 41 is also used to: in response to the third data block accessed by the third read request in the secondary private cache not existing in the secondary private cache, or the third data block is not in an exclusive state or a shared state in the secondary private cache, determine that the first read request corresponding to the third read request does not hit in the secondary private cache.
[0123] In the embodiment of the present application, the first acquisition module 41 is further used to: in response to the first read request failing to read in the first-level private cache and the second-level private cache, generate a fourth read request and send it to the cache directory of the multi-level cache system. In response to the fourth read request not hitting in the cache directory, generate a second read request according to the fourth read request and send it to the shared cache.
[0124] In the embodiment of the present application, the first acquisition module 41 is further used to: in response to the second data block existing in the first-level private cache and the second data block is not in an invalid state in the first-level private cache, determine that the first read request hits in the first-level private cache.
[0125] In the embodiment of the present application, the first acquisition module 41 is further used to: in response to the third data block being in a shared state or an exclusive state in the secondary private cache, determine that the first read request corresponding to the third read request hits in the secondary private cache.
[0126] In an embodiment of the present application, the first acquisition module 41 is also used to: in response to the fact that the access target information of the fourth read request in the cache directory does not exist, or the fourth data block corresponding to the fourth read request is recorded as an invalid state in the cache directory, determine that the fourth read request does not hit in the cache directory.
[0127] In an embodiment of the present application, the first acquisition module 41 is also used to: obtain a first data block from a shared cache and / or memory; in response to the existence of a unique backup data block for the first data block, determine that the second data block state of the first data block is a shared state; in response to the first data block being written, obtain a second count value of the first data block being written, and when the second count value is greater than or equal to a preset count value threshold, adjust the second data block state of the first data block to an exclusive state.
[0128] In an embodiment of the present application, the first acquisition module 41 is also used to: in response to the fourth read request indicating that the data block record status in the access target information in the cache directory is valid-dirty data (valid-dirty) or valid-clean data (valid-clean), determine that the fourth read request hits in the cache directory, and send a write-back request to the secondary private cache to which the data block corresponding to the data block record status belongs.
[0129] In the embodiment of the present application, the secondary private cache and the primary private cache do not maintain a containment relationship.
[0130] The data block status acquisition device proposed in the present application acquires the first data block of the first read request through the shared cache when the first read request fails to read in the first-level private cache and the second-level private cache, and acquires the first data block status of the first data block according to the first count value of the first data block. In the present application, when the first read request fails to read in the first-level private cache and the second-level private cache, the first data block is acquired through the shared cache, and the first data block status of the first data block is determined according to the first count value of the first data block, which reduces the workload of consistency maintenance of the multi-level cache system, thereby reducing the waste of cache capacity and improving the hit rate of memory access requests in the multi-level cache.
[0131] In order to implement the above embodiment, the present application embodiment also proposes an electronic device 500, such as Figure 5 As shown, the electronic device 500 may specifically include: a memory 51, a processor 52, and a computer program stored in the memory 51 and executable on the processor 52. When the processor 52 executes the program, the method for obtaining the status of the data block shown in the above embodiment is implemented.
[0132] In order to implement the above embodiment, the embodiment of the present application also proposes a computer-readable storage medium, on which a computer program is stored. The program is executed by a processor to implement the data block status acquisition method shown in the above embodiment.
[0133] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0134] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0135] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for obtaining the state of a data block, characterized in that: The method comprises: In response to a read failure of the first read request in the first-level private cache and the second-level private cache, a second read request is generated and sent to the shared cache, and a second data block corresponding to the second read request is obtained through the shared cache as a first data block returned by the first read request; Acquire a first count value of the first data block, and acquire a first data block state of the first data block according to the first count value, wherein the first data block state includes an exclusive state and a shared state, wherein if the first count value is greater than or equal to a preset count value threshold, then the first data block state of the first data block is determined to be the exclusive state, and if the first count value is less than the count value threshold, then the first data block state of the first data block is determined to be the shared state; The method also includes: in response to the first read request not hitting the first-level private cache, determining that the first read request has failed to read in the first-level private cache; in response to the third read request corresponding to the first read request not hitting the second-level private cache, determining that the first read request corresponding to the third read request has failed to read in the second-level private cache.
2. The method according to claim 1, characterized in that: The method further comprises: In response to identifying that the first count value satisfies a preset clearing policy, the value of the first count value is determined to be 0.
3. The method according to claim 2, characterized in that The method further comprises: In response to the first count value being 0, it is determined that the state of the first data block remains unchanged.
4. The method according to claim 1, characterized in that: In response to the first read request not hitting the first level private cache, determining that the first read request fails to read the first level private cache includes: In response to the second data block accessed by the first read request in the first-level private cache not existing in the first-level private cache, or the second data block is in an invalid state in the first-level private cache, it is determined that the first read request misses the first-level private cache.
5. The method according to claim 4, characterized in that In response to a third read request corresponding to the first read request not hitting in the secondary private cache, determining that the first read request corresponding to the third read request is read invalid in the secondary private cache includes: In response to the third data block accessed by the third read request in the secondary private cache not existing in the secondary private cache, or the third data block is not in an exclusive state or a shared state in the secondary private cache, it is determined that the first read request corresponding to the third read request does not hit in the secondary private cache.
6. The method according to claim 1, characterized in that The method of generating a second read request and sending the second read request to the shared cache in response to the first read request failing to read the first private cache and the second private cache comprises: In response to the first read request failing to read in the first level private cache and the second level private cache, generating a fourth read request and sending it to a cache directory of the multi-level cache system; In response to the fourth read request not hitting in the cache directory, generating the second read request according to the fourth read request and sending it to the shared cache.
7. The method according to claim 4, characterized in that The method further comprises: In response to the second data block existing in the first-level private cache and the second data block being in an invalid state in the first-level private cache, it is determined that the first read request hits in the first-level private cache.
8. The method according to claim 5, characterized in that The method further comprises: In response to the third data block being in a shared state or an exclusive state in the secondary private cache, it is determined that the first read request corresponding to the third read request hits in the secondary private cache.
9. The method according to claim 6, characterized in that The method further comprises: In response to the access target information of the fourth read request not existing in the cache directory, or the fourth data block corresponding to the fourth read request is recorded as invalid in the cache directory, it is determined that the fourth read request does not hit in the cache directory.
10. The method according to claim 9, characterized in that After determining that the fourth read request does not hit in the cache directory, the method further comprises: Acquire the first data block from a shared cache and / or memory; In response to the existence of a unique backup data block for the first data block, determining that a second data block state of the first data block is a shared state; In response to the first data block being written, a second count value of the first data block being written is acquired, and when the second count value is greater than or equal to a preset count value threshold, a second data block state of the first data block is adjusted to an exclusive state.
11. The method according to claim 9, characterized in that The method further comprises: In response to the fourth read request, when the data block record status in the access target information indicated in the cache directory is valid-dirty or valid-clean, it is determined that the fourth read request hits in the cache directory, and a write-back request is sent to the secondary private cache to which the data block corresponding to the data block record status belongs.
12. The method according to any one of claims 1 to 11, characterized in that The second-level private cache and the first-level private cache do not maintain a containment relationship.
13. A data block status acquisition device, characterized in that: The device comprises: A first acquisition module is used to generate a second read request in response to a read failure of the first read request in the first-level private cache and the second-level private cache, and send the second read request to the shared cache, and obtain a second data block corresponding to the second read request through the shared cache as the first data block returned by the first read request; a second acquisition module, configured to acquire a first count value of the first data block, and acquire a first data block state of the first data block according to the first count value, wherein the first data block state includes an exclusive state and a shared state, wherein if the first count value is greater than or equal to a preset count value threshold, then the first data block state of the first data block is determined to be the exclusive state, and if the first count value is less than the count value threshold, then the first data block state of the first data block is determined to be the shared state; The first acquisition module is also used to: in response to the first read request not hitting the first-level private cache, determine that the first read request has failed to read in the first-level private cache; in response to the third read request corresponding to the first read request not hitting the second-level private cache, determine that the first read request corresponding to the third read request has failed to read in the second-level private cache.
14. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 12 is implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Method for optimizing write performance of distributed block storage system by utilizing cache of gateway nodes
CN105872040A
Data caching method and data caching device
CN112905111A
Multiprocessor system
US20030115402A1
Access method and apparatus and data storage method and apparatus for multi-level cache system
WO2024066613A1
