Search method based on disk-level cache data redirection
By introducing deletable bloom filters and hash value judgment mechanisms into the disk-level cache, the problem of long metadata retrieval delays in single concurrency scenarios is solved, efficient and accurate data retrieval and fast scanning are achieved, and the system is improved. Response speed.
Patent Information
- Application Number
- PCT/CN2023/142734
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-14
- Filing Date
- 2023-12-28
- Publication Date
- 2024-10-17
AI Technical Summary
When the existing technology processes a large amount of metadata and there is very little dirty data, the disk-level cache data retrieval delay is long. Especially in a single concurrency scenario, it is difficult to ensure the accuracy and efficiency of retrieval.
Design a disk-level Cache data redirection retrieval method based on Deletable Bloom Filter (DlBF), map elements to arrays through hash functions, realize insertion, query and deletion of elements, and optimize false positives through mathematical probability models And the ability to remove elements, combined with SHA-1 hash value to determine whether the data has been processed, quickly scan the metadata tree to reduce latency.
It improves the retrieval efficiency and accuracy in single concurrent scenarios, and significantly reduces the latency. Especially when the amount of dirty data is small and the amount of metadata is large, it can quickly scan the metadata tree and avoid searching for the full metadata tree. performance bottleneck.
Smart Images

Figure CN2023142734_17102024_PF_FP_ABST
Abstract
Description
A retrieval method based on disk-level cache data redirection Technical Field
[0001] The present invention relates to the technical field of computer storage, and in particular to a retrieval method based on disk-level cache data redirection. Background Art
[0002] Computer storage is an electronic device made using semiconductor technology, used to store data. The data in electronic circuits is stored in binary form. Each storage unit of the memory is called a memory element. The computer memory can be divided into the following types: Memory (cache / temporary storage): data is stored in the memory and in the hard disk (persistent / permanent storage), Hard disk (persistent / permanent storage): data is stored in the hard disk, ROM: Read-Only Memory (ROM) works in a non-destructive read mode and can only read but not write information. Once the information is written, it is fixed and will not be lost even if the power is cut off, so it is also called fixed memory, RAM: Information can be written (stored) or read (retrieved) from any specified address at any time during operation. The biggest difference between it and ROM is the volatility of the data, that is, the stored data will be lost once the power is cut off.
[0003] Disk-level cache uses the storage space of the memory to temporarily store information in some disk blocks read from the disk, thereby improving the disk IO speed. This technology is different from the small-capacity high-speed memory between the CPU and the memory in the usual sense. Instead, it uses the storage space of the memory to temporarily store information in some disk blocks read from the disk. Therefore, the disk-level cache logically belongs to the disk, but physically is the disk block residing in the memory.
[0004] Bloom filters are primarily used to determine whether an element x exists in a set S. They are currently widely used in production and research, such as spam filtering and data deduplication. Bloom filters consist of a one-dimensional array of 0-1 values and a set of random mapping functions, transforming complex memory and computational operations into set membership problems. While Bloom filters offer advantages such as high query efficiency, minimal memory usage, and a simple structure, they suffer from significant false positive rates (data may not necessarily exist when a Bloom filter determines it exists) and the inability to delete elements. To reduce the overhead of data retrieval in the bcache, this design first uses a Bloom filter to check whether the query content exists in the cache, then sends the request to the metadata tree for scanning. Finally, the query and its results are used to update the filter (deleting queries according to the first-in, first-out principle). Based on these requirements, we chose the Deletable Bloom Filter (DlBF) algorithm, which ensures both high query accuracy and the ability to delete and update partial queries in a timely manner.
[0005] Summary of the Invention
[0006] The purpose of the present invention is to design and implement a retrieval method based on disk-level cache data redirection. DlBF is an improved version of the Bloom filter, which can not only meet the retrieval accuracy but also delete and update part of the retrieval in time, solving the problem of large latency when there is a large amount of metadata but little dirty data. In particular, the improvement effect is obvious in single-concurrency scenarios. According to the inferred business model, a deletable Bloom filter is added. At the same time, in order to cope with the scenario where the amount of dirty data is small but the amount of metadata is large, the invalidated metadata is replaced by invalidated metadata with a certain number of invalidated dirty data to achieve the purpose of quickly scanning the metadata tree and reducing latency.
[0007] In order to achieve the above effect, the present invention provides the following technical solution: a retrieval method based on disk-level cache data redirection, comprising the following steps:
[0008] S1. Initialization: Create an empty array of size (called buckets) and set the number of hash functions (num_hashes).
[0009] S2. Insert elements: Apply num_hashes hash functions to the elements to get num_hashes hash values. Check whether there are vacancies in the buckets corresponding to these hash values. If there are vacancies, put the element into the vacancies and return True. If there are no vacancies, randomly select a bucket corresponding to the hash value and replace the element in it with the element to be inserted. Repeat the above process for the evicted elements until a vacancies is found or the maximum number of retries is reached.
[0010] S3. Query element: Apply num_hashes hash functions to the element, get num_hashes hash values, check whether there is an element equal to the query element in the buckets corresponding to these hash values, if so, return True (the element may be in the set), otherwise return False (the element is definitely not in the set).
[0011] S4. Delete elements: Apply num_hashes hash functions to the elements to obtain num_hashes hash values. Check whether there are elements equal to the elements to be deleted in the buckets corresponding to these hash values. If so, set them to None and return True (deletion successful). If not, return False (deletion failed, the element does not exist).
[0012] Furthermore, the following steps are included: the element removal is only probabilistic, so a key design issue is to design a selected value r and quantify its impact on (1) the ability to remove elements and (2) false positive behavior (before and after element removal). First, a mathematical probability model of element removal is given, and then the false positive penalty is estimated.
[0013] Further, the following steps are included: Consider a bit array of size m′=mr, each region has r bit cells, and the probability of at least one collision in a given cell is p c =1-p0-p1.
[0014] Furthermore, the method includes the following steps: p0 represents the probability that a given cell is set to 0, and p1 represents the probability that a given cell is set to 1 only once after n elements are inserted.
[0015] Further, the following steps are included:
[0016] Formulas (3-1) and (3-2) represent the probability formulas for p0 and p1.
[0017] Furthermore, the following steps are included: the probability that no conflict occurs in each area of the second part of the DIBF is (1-p c )m / r .
[0018] Further, the following steps are included:
[0019] When r≥k and m≥k, the probability that an element can be deleted can be approximated by formula (3-3): d =(1-(1-p c m′ / r )) k (3-3).
[0020] Furthermore, the following steps are included: the probability formula of the false positive is (3-4):
[0021] Compared to a standard Bloom filter, the false positive probability increases only with m / r.
[0022] Furthermore, the following steps are included: the data will pass through DIBF before entering the cache, and in the data redirection retrieval path, the SHA-1 hash value of the block in the incoming DIBF is checked to determine whether the same hash value exists in the bitmap hash table to determine whether the data has been processed.
[0023] Furthermore, the method includes the following steps: the method is used to track the locations where conflicts occur when inserting elements, and the m-bit binary vector is divided into two parts: the first part is a collision area with r bits, each bit is used to determine whether a position in a region of the latter part is set to 1 multiple times. The second part is divided into regions, each region containing bits.
[0024] The present invention provides a retrieval method based on disk-level cache data redirection, which has the following beneficial effects:
[0025] DlBF is an improved version of the Bloom filter. It can not only meet the accuracy of retrieval but also delete and update some retrievals in a timely manner. It solves the problem of high latency when there is a large amount of metadata but little dirty data. The improvement is particularly significant in single-concurrency scenarios. Based on the inferred business model, a deletable Bloom filter is added. At the same time, to cope with scenarios with a small amount of dirty data but a large amount of metadata, the invalid metadata is replaced by invalidating a certain amount of dirty data to invalidate a certain amount of metadata to achieve the goal of quickly scanning the metadata tree and reducing latency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] FIG1 is a flow chart of a retrieval method based on disk-level cache data redirection according to the present invention;
[0027] FIG2 is a schematic diagram of a data redirection retrieval process of a retrieval method based on disk-level cache data redirection according to the present invention;
[0028] FIG3 is a schematic diagram of a deletable Bloom filter of a retrieval method based on disk-level cache data redirection according to the present invention;
[0029] FIG4 is a schematic diagram of flushing dirty data in a retrieval method based on disk-level cache data redirection according to the present invention;
[0030] FIG5 is a schematic diagram of the upgraded single concurrent latency of a retrieval method based on disk-level cache data redirection according to the present invention;
[0031] FIG6 is a first schematic diagram of iops data according to an embodiment of a retrieval method based on disk-level cache data redirection of the present invention;
[0032] FIG7 is a second schematic diagram of iops data according to an embodiment of a retrieval method based on disk-level cache data redirection of the present invention. DETAILED DESCRIPTION
[0033] The following will clearly and completely describe the technical solutions of the present invention in conjunction with the embodiments. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0034] It should be noted that in the description of the present invention, the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They do not indicate or imply that the devices or components referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limitations on the present invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0035] It should be noted that, in the description of the present invention, the terms "connect" and "install" should be understood broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can be directly connected or connected through an intermediate medium; and they can be mechanically connected or electrically connected. Those skilled in the art will understand the specific meanings of these terms in the present invention based on specific circumstances.
[0036] Example 1, referring to Figures 1-7, a retrieval method based on disk-level cache data redirection includes the following steps:
[0037] Step 1: Initialization
[0038] Create an empty array of size (called buckets ) and set the number of hash functions ( num_hashes ).
[0039] Step 2: Insert elements
[0040] Apply num_hashes hash functions to the elements, get num_hashes hash values, check whether there are vacancies in the buckets corresponding to these hash values, if so, put the element into the vacant position and return True, if not, randomly select a bucket corresponding to the hash value, replace the element in it with the element to be inserted, and repeat the above process for the evicted elements until a vacancy is found or the maximum number of retries is reached.
[0041] Step 3: Query elements
[0042] Apply num_hashes hash functions to the elements, obtaining num_hashes hash values. Check whether there are elements in the buckets corresponding to these hash values that are equal to the query element. If so, return True (the element may be in the set); otherwise, return False (the element is definitely not in the set).
[0043] Step 4: Delete elements:
[0044] Apply num_hashes hash functions to the elements, get num_hashes hash values, check whether there is an element equal to the element to be deleted in the buckets corresponding to these hash values, and if so, set it to None and return True (deletion successful), otherwise return False (deletion failed, the element does not exist).
[0045] Since element removal is only probabilistic, a key design issue is to design a value r and quantify its impact on (1) the ability to remove elements and (2) false positive behavior (before and after element removal). First, a mathematical probability model of element removal is given, and then the false positive penalty is estimated.
[0046] Consider a bit array of size m′=mr, with r bit cells in each region, and the probability of at least one collision in a given cell is p c =1-p0-p1, where p0 represents the probability that a given cell is set to 0, and p1 represents the probability that a given cell is set to 1 only once after n elements are inserted.
[0047] Formulas (3-1) and (3-2) represent the probability formulas of p0 and p1. For each area in the second part of DlBF, the probability of no conflict is (1-pc ) m / r , when r≥k and m≥k, the probability that an element can be deleted can be approximated by formula (3-3): p d =(1-(1-p c m′ / r )) k (3-3)
[0048] The false positive probability formula is (3-4):
[0049] Compared with the standard Bloom filter, the increase in its false positive probability is only related to m / r, indicating that its impact on false positives is controllable.
[0050] The data redirection retrieval steps are shown in the figure. Before entering the cache, the data will first pass through the DIBF. In the data redirection retrieval path, the SHA-1 hash value of the block in the incoming DIBF is checked to determine whether the same hash value exists in the bitmap hash table to determine whether the data has been processed.
[0051] The core idea of DlBF is to track the locations where conflicts occur when inserting elements, so it divides the m-bit binary vector into two parts: the first part is a collision area with r bits, and each bit is used to determine whether a position in an area of the latter part is set to 1 multiple times; the second part is divided into r areas, each area contains m / r bits, as shown in Figure 5-2. The example of DlBF is m=32, r=4, and the three elements x, y, and z are mapped to the areas shown in the figure through three random mapping functions. The first part of DlBF marks the conflicting areas. For example, if one of the positions of x and z is mapped to 15, the second area of the second part is marked as the conflicting area. The mark of this area cannot be deleted, and element deletion can only be performed in the conflict-free area to avoid false negatives.
[0052] When flushing dirty data to the HDD, the invalid metadata will replace the invalidated dirty data with the invalidated metadata. This allows for quick retrieval of the metadata tree even when the amount of dirty data is small, thus avoiding the performance bottleneck caused by searching the entire metadata tree and improving response speed.
[0053] Example 2, referring to Figures 1-7, a retrieval method based on disk-level cache data redirection includes the following steps:
[0054] Step 1: First, we created a DlBF of size 1000 using 3 hash functions. Then, we inserted two elements ("bcache" and "metadata") and queried whether they were in the filter. Next, we queried a non-existent element ("test"), and the result was False. Finally, we deleted the element "bcache" and queried again whether it was in the filter, and the result was False.
[0055] Step 2: To solve the problem of high latency when the amount of metadata is large and the amount of dirty data is small, first use fio to run billions of metadata on a single disk.
[0056] Step 3. Wait for it to automatically flush the disk (bcache to clean state). The "clean" state usually means that an object or system has no impurities, dirt or defects. In some cases, it can also mean that an object or system is running normally without errors or failures. However, in computer science, the "clean" state is usually used to describe a special state, that is, the data has no errors, anomalies or missing after being processed or cleaned. This state usually occurs in the process of data analysis and processing, where the data may need to go through a series of processing steps to ensure its accuracy and completeness. In this case, the "clean" state can be This status can mean that the data has been processed to remove any unnecessary or invalid data and only contains valid and accurate information. This status can also mean that the data has been verified and validated to ensure that it meets the expected standards and specifications. Bcache states include "clean", "dirty", and "inconsistent". The "clean" status indicates that the cache set has no dirty data and the cache set is synchronized with the backend device. The "dirty" status indicates that the cache set contains dirty data that has not yet been written to the backend device. The "inconsistent" status indicates that the backend device has dirty data after being forced to run by the user, and the cache set is unavailable.
[0057] Step 4: Use fio to run a small io command on a single disk with single concurrency to check the latency (the latency is very high and the iops is very low).
[0058] Step 5. Turn on the setting switch and then perform the above steps to find that the latency is reduced and the iops is increased.
[0059] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A retrieval method based on disk-level cache data redirection, It is characterized in that The following steps are involved: S1. Initialization: Create an empty array of size and set the number of hash functions num_hashes; S2. Insert elements: Apply num_hashes hash functions to the elements to get num_hashes hash values. Check whether there are vacancies in the buckets corresponding to these hash values. If there are vacancies, put the element into the vacancies and return True. If there are no vacancies, randomly select a bucket corresponding to the hash value and replace the element in it with the element to be inserted. Repeat the above process for the evicted elements until a vacancies are found or the maximum number of retries is reached. S3. Query element: Apply num_hashes hash functions to the element, get num_hashes hash values, check whether there are elements equal to the query element in the buckets corresponding to these hash values, if yes, return True, otherwise return False; S4. Delete elements: Apply num_hashes hash functions to the elements to get num_hashes hash values. Check whether there are elements equal to the elements to be deleted in the buckets corresponding to these hash values. If so, set them to None and return True. If not, return False.
2. A retrieval method based on disk-level cache data redirection according to claim 1, It is characterized in that The following steps are involved: The element removal is only probabilistic, so a key design issue is to design a selected value r and quantify its impact on the ability to remove elements and the false positive behavior. First, a mathematical probability model for the element being removable is given, and then the false positive penalty is estimated.
3. A retrieval method based on disk-level cache data redirection according to claim 2, It is characterized in that The following steps are involved: Consider a bit array of size m′=mr, with r bit cells in each region, and the probability of at least one collision in a given cell is p c =1-p 0 -p 1 .
4. A retrieval method based on disk-level cache data redirection according to claim 3, It is characterized in that The following steps are involved: The p 0 represents the probability of setting a given cell to 0, p 1 represents the probability that a given cell insertion will set 1 only once after n elements have been inserted.
5. A retrieval method based on disk-level cache data redirection according to claim 4, It is characterized in that The following steps are involved: Said The formula represents p 0 and p 1 The probability formula of .
6. A retrieval method based on disk-level cache data redirection according to claim 5, It is characterized in that The following steps are involved: For each region in the second part of the DIBF, the probability of no conflict is (1-p c ) m / r .
7. A retrieval method based on disk-level cache data redirection according to claim 6, It is characterized in that The following steps are involved: When r≥k and m≥k, the probability that an element can be deleted can be approximated by the formula: p d =(1-(1-p c m / r )) k 。 8. A retrieval method based on disk-level cache data redirection according to claim 7, It is characterized in that The following steps are involved: The probability formula of the false positive is: Compared to a standard Bloom filter, the increase in false positive probability is only related to m / r.
9. A retrieval method based on disk-level cache data redirection according to claim 8, It is characterized in that The following steps are involved: The data will pass through DIBF before entering the cache. In the data redirection retrieval path, the SHA-1 hash value of the block in the incoming DIBF is checked to determine whether the same hash value exists in the bitmap hash table to determine whether the data has been processed.
10. A retrieval method based on disk-level cache data redirection according to claim 9, It is characterized in that The method comprises the following steps: the method is used to track the position where the conflict occurs when inserting an element, and the m-bit binary vector is divided into two parts: the first part is a collision area with r bits, and each bit is used to determine whether a position in an area of the latter part is set to 1 multiple times; the second part is divided into regions, each region contains bits.
Citation Information
Patent Citations
Design method for bloom filter supporting deletion
CN112818188A
Retrieving a replica of an electronic document in a computer network
CN1795448A
Memory-efficient caching methods and systems
US20130173853A1
Solid state drive (SSD) memory cache occupancy prediction
US20160147446A1
Data processing method and apparatus, and server
WO2021008024A1
