Page cache hot data aggregation method and device applied to key-value separation storage system

By using heat statistics tables and buffers to separate hot data and cold data in the key-value separation storage system, the problem of low hot data read throughput in the existing technology is solved, and the page cache hit rate and system performance are improved.

CN118312516BActive Publication Date: 2024-08-27HUAQIAO UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410726484.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-08-27
Estimated Expiration
2044-06-06

AI Technical Summary

Technical Problem

Under the Ziff distributed workload, the existing key-value separation storage system has low read throughput of hot key-value pairs. The reason is that the low page cache hit rate results in mixed storage of hot data and cold data, which reduces the system's Read performance.

Method used

Using the page cache hot data aggregation method, the data is divided into hot data and cold data through the heat statistics table, and hot buffers and cold buffers are used in the memory respectively. According to the write instructions and buffer status, the data is persisted to External memory improves the page cache hit rate of hot data.

Benefits of technology

It improves the hit rate of page cache, reduces memory access overhead, accelerates value acquisition, improves system read performance, and maintains optimal performance when memory space changes and workload changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312516B
    Figure CN118312516B
Patent Text Reader

Abstract

The present invention discloses a page cache hot data aggregation method and device applied to a key-value separation storage system, which relates to the field of data storage, including: if the write buffer is full and an operation instruction to write a key-value pair to be written into a value file is obtained, then query the heat statistics table; if the key in the key-value pair to be written is in the heat statistics table, it is determined to be hot data, and it is judged whether the hot buffer is full. If so, all key-value pairs in the hot buffer are persisted and then written into the hot buffer, otherwise, it is directly written into the hot buffer; if the key in the key-value pair to be written is not in the heat statistics table, it is determined to be cold data, and it is judged whether the cold buffer is full. If so, all key-value pairs in the cold buffer are persisted and then written into the cold buffer, otherwise, it is directly written into the cold buffer; the value address of the key-value pair to be written and the corresponding key are written into the LSM tree. This method can solve the problem that the hit rate of the page cache is low and affects the read performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data storage, and in particular to a page cache hot data aggregation method and device applied to a key-value separation storage system. Background Art

[0002] With the rise of the Internet in recent years, cloud computing and big data applications have become more and more widespread, and NoSQL databases have become increasingly prosperous. As a type of NoSQL, key-value storage has produced many successful commercial products, such as FaceBook's RocksDB and Google's LevelDB and BigTable.

[0003] At present, there are many ways to implement key-value storage systems. One of them is the key-value storage system based on the LSM tree, which is a popular key-value storage implementation. Compared with other implementation structures, the main advantage of the LSM tree is that it uses a sequential write mode, which fundamentally improves the write throughput. In order to support multi-key range queries and single-key point queries, the LSM tree maintains multiple ordered key ranges. The 0th layer of the LSM tree has multiple ordered key ranges, and each layer from the 1st to the nth layer has an ordered key range. To this end, the LSM tree uses a mechanism called inter-layer merging to sort multiple key-value pairs and recycle invalid key-value pairs. It should be pointed out that the inter-layer merging mechanism of the LSM tree will occupy more I / O bandwidth, causing bandwidth competition with the user's read and write operations, and the repeated writing of data after sorting will increase the life loss of the solid-state drive. In order to solve the problems of the LSM tree, the key-value separation storage system came into being. Its main method is to store the value in a value file using other methods to avoid the value being involved in the execution process of inter-layer merging, thereby significantly improving the throughput of the system.

[0004] However, there is still room for memory access optimization in key-value separation storage systems in different popular workloads. In real-world applications of key-value storage, many workloads have the characteristics of Zipf distribution. Zipf distribution means that a small number of key-value pairs receive most of the access requests. This situation makes some key-value pairs relatively hot data. However, the existing key-value separation storage system has low read throughput under this load due to the low page cache hit rate. In modern operating systems, when the data to be read from the external memory is smaller than the page size specified by the operating system (usually 4KiB), the entire data block containing the data will be read into the operating system's page cache. Therefore, when the key-value pair is less than 4KiB, when a hot key-value pair is obtained, the cold key-value pair may be read in together. This phenomenon will cause the page cache to be occupied by more low-frequency accessed key-value pairs, reducing the page cache hit rate of hot key-value pairs and seriously affecting the system's read performance.

[0005] Therefore, it is necessary to design a page cache hot data aggregation method for key-value separation storage system, which aggregates hot values ​​in a data block of a page unit in the value file to improve the hit rate of the page cache while avoiding obvious impact on other performance of the system. Summary of the invention

[0006] The purpose of this application is to propose a page cache hot data aggregation method and device applied to a key-value separation storage system in response to the above-mentioned technical problems.

[0007] In a first aspect, the present invention provides a page cache hot data aggregation method applied to a key-value separation storage system, wherein the key-value separation storage system comprises an LSM tree, a memory and an external memory, wherein the memory stores a write buffer, a heat statistics table, a hot buffer and a cold buffer, and the external memory stores a value file, wherein the value file stores data grouped by key ranges corresponding to the hot buffer and the cold buffer, comprising the following steps:

[0008] In response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file, querying the heat statistics table;

[0009] In response to determining that the key in the key-value pair to be written is in the heat statistics table, determining that the key-value pair to be written is hot data, determining whether the hot buffer is full, and if so, persisting all key-value pairs in the hot buffer to the corresponding key range group, and then writing the key-value pair to be written to the hot buffer, otherwise directly writing the key-value pair to be written to the hot buffer;

[0010] In response to determining that the key in the key-value pair to be written is not in the heat statistics table, it is determined that the key-value pair to be written is cold data, and whether the cold buffer is full is determined. If so, all key-value pairs in the cold buffer are persisted to the corresponding key range group, and then the key-value pair to be written is written to the cold buffer; otherwise, the key-value pair to be written is directly written to the cold buffer;

[0011] Write the value address and corresponding key of the key-value pair to be written into the LSM tree.

[0012] Preferably, the strategy adopted by the heat statistics table includes a least frequently used algorithm and is implemented based on an LFU cache, wherein the LFU cache includes a hash table, a red-black tree, and a plurality of bidirectional circular linked lists.

[0013] Preferably, the elements of the hash table include a key and its corresponding number of accesses, a predecessor pointer and a successor pointer, each node on the bidirectional circular linked list is an element corresponding to a key with the same number of accesses in the hash table, and each node on the bidirectional circular linked list is connected by a predecessor pointer and a successor pointer, each bidirectional circular linked list has a header node and a tail node, the address of the tail node is stored in the tail pointer, and each element of the red-black tree is the number of accesses and its corresponding tail pointer.

[0014] As a preferred method, query the heat statistics table, specifically including:

[0015] The key in the key-value pair to be written is queried in the hash table. If the key in the key-value pair to be written is found in the hash table, it is determined that the key in the key-value pair to be written is in the heat statistics table, the number of accesses in the element of the hash table corresponding to the key-value pair to be written is increased by 1, and the index relationship of the bidirectional circular linked list where the element of the hash table corresponding to the key-value pair to be written is located and the addition and deletion of nodes and the tail pointer of the element of the red-black tree are adjusted;

[0016] If it is found that the key in the key-value pair to be written is not in the hash table, it is determined that the key in the key-value pair to be written is not in the heat statistics table, and the element corresponding to the key-value pair to be written is recorded in the hash table, where the number of accesses in the element corresponding to the key-value pair to be written is 1, and a node corresponding to the element corresponding to the key-value pair to be written is added to the bidirectional circular linked list corresponding to the number of accesses 1, and its index relationship and the tail pointer in the element of the red-black tree are adjusted.

[0017] As a preferred embodiment, the heat statistics table uses a heat identification method to define data as hot data or cold data. The process of the heat identification method is as follows:

[0018] Arrange the data from most to least access times. The data with the most access times is at the 0th percentile, and the data with the least access times is at the 100th percentile. Define the data below the identified percentile p as hot data and record it in the heat statistics table. The rest of the data is defined as cold data. The identified percentile p is calculated using the following formula:

[0019] ;

[0020] Among them, S cache is the actual page cache space, and S file is the size of the value file;

[0021] The upper limit N of elements in the heat statistics table table The calculation is done using the following formula:

[0022] ;

[0023] Among them, Nfile is the total number of key-value pairs stored in the value file;

[0024] According to the changes in the actual page cache space, the heat identification process is dynamically adjusted and the heat statistics table is trimmed. The trimming of the heat statistics table occurs during the garbage collection process of the corresponding group and occupies a background thread.

[0025] Preferably, each key range group corresponds to a pair of hot buffer and cold buffer, the sizes of the hot buffer and the cold buffer are equal to the page unit, and the heat statistics table is initialized to empty.

[0026] In a second aspect, the present invention provides a page cache hot data aggregation device applied to a key-value separation storage system, wherein the key-value separation storage system includes an LSM tree, a memory and an external memory, wherein the memory stores a write buffer, a heat statistics table, a hot buffer and a cold buffer, and the external memory stores a value file, wherein the value file stores data grouped by key ranges corresponding to the hot buffer and the cold buffer, including:

[0027] A query module is configured to query a heat statistics table in response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file;

[0028] The hot data writing module is configured to, in response to determining that the key in the key-value pair to be written is in the heat statistics table, determine that the key-value pair to be written is hot data, determine whether the hot buffer is full, and if so, persist all the key-value pairs in the hot buffer to the corresponding key range group, and then write the key-value pair to be written into the hot buffer, otherwise, directly write the key-value pair to be written into the hot buffer;

[0029] The cold data writing module is configured to determine that the key in the key-value pair to be written is cold data in response to determining that the key in the key-value pair to be written is not in the heat statistics table, and judge whether the cold buffer is full. If so, persist all the key-value pairs in the cold buffer to the corresponding key range group, and then write the key-value pair to be written into the cold buffer; otherwise, directly write the key-value pair to be written into the cold buffer;

[0030] The value address writing module is configured to write the value address and the corresponding key of the key-value pair to be written into the LSM tree.

[0031] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0032] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0033] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0034] Compared with the prior art, the present invention has the following beneficial effects:

[0035] (1) The page cache hot data aggregation method applied to the key-value separation storage system proposed in the present invention improves the hit rate of the page cache, reduces the memory access overhead, and accelerates the acquisition of values ​​by aggregating hot data in the cache page.

[0036] (2) The page cache hot data aggregation method applied to the key-value separation storage system proposed in the present invention uses a heat recognition adjustment mechanism to enable the system to have better performance when the memory space changes and the workload changes, thereby improving the adaptability of the system.

[0037] (3) The page cache hot data aggregation method applied to the key-value separation storage system proposed in the present invention can fully utilize the high-speed access characteristics of the page cache and improve the read performance of the key-value separation storage system. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] Figure 1 A schematic diagram of a process of a page cache hot data aggregation method applied to a key-value separation storage system according to an embodiment of the present application;

[0040] Figure 2 A system structure diagram of a key-value separation storage system for a page cache hot data aggregation method applied to a key-value separation storage system according to an embodiment of the present application;

[0041] Figure 3 A structural diagram of an LFU cache implementation of a page cache hot data aggregation method applied to a key-value separation storage system according to an embodiment of the present application;

[0042] Figure 4 A schematic diagram of a data writing process of a page cache hot data aggregation method applied to a key-value separation storage system according to an embodiment of the present application;

[0043] Figure 5 A schematic diagram of a page cache hot data aggregation device applied to a key-value separation storage system according to an embodiment of the present application;

[0044] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] Figure 1 A page cache hot data aggregation method applied to a key-value separation storage system provided by an embodiment of the present application is shown. The key-value separation storage system includes an LSM tree, a memory and an external memory. The memory stores a write buffer, a heat statistics table, a hot buffer and a cold buffer. The external memory stores a value file. The value file stores data grouped by key ranges corresponding to the hot buffer and the cold buffer. The method includes the following steps:

[0047] S1, in response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file, querying a heat statistics table.

[0048] In a specific embodiment, each key range group corresponds to a pair of hot buffer and cold buffer, the sizes of the hot buffer and the cold buffer are equal to the page unit, and the heat statistics table is initialized to empty.

[0049] In a specific embodiment, the strategy adopted by the heat statistics table includes a least frequently used algorithm and is implemented based on an LFU cache, wherein the LFU cache includes a hash table, a red-black tree, and a plurality of bidirectional circular linked lists.

[0050] In a specific embodiment, the elements of the hash table include a key and its corresponding number of accesses, a predecessor pointer and a successor pointer. Each node on the bidirectional circular linked list is an element corresponding to a key with the same number of accesses in the hash table, and each node on the bidirectional circular linked list is connected by a predecessor pointer and a successor pointer. Each bidirectional circular linked list has a header node and a tail node. The address of the tail node is stored in the tail pointer. Each element of the red-black tree is the number of accesses and its corresponding tail pointer.

[0051] In a specific embodiment, querying the heat statistics table specifically includes:

[0052] The key in the key-value pair to be written is queried in the hash table. If the key in the key-value pair to be written is found in the hash table, it is determined that the key in the key-value pair to be written is in the heat statistics table, the number of accesses in the element of the hash table corresponding to the key-value pair to be written is increased by 1, and the index relationship of the bidirectional circular linked list where the element of the hash table corresponding to the key-value pair to be written is located and the addition and deletion of nodes and the tail pointer of the element of the red-black tree are adjusted;

[0053] If it is found that the key in the key-value pair to be written is not in the hash table, it is determined that the key in the key-value pair to be written is not in the heat statistics table, and the element corresponding to the key-value pair to be written is recorded in the hash table, where the number of accesses in the element corresponding to the key-value pair to be written is 1, and a node corresponding to the element corresponding to the key-value pair to be written is added to the bidirectional circular linked list corresponding to the number of accesses 1, and its index relationship and the tail pointer in the element of the red-black tree are adjusted.

[0054] In a specific embodiment, the heat statistics table uses a heat identification method to define data as hot data or cold data. The process of the heat identification method is as follows:

[0055] Arrange the data from most to least access times. The data with the most access times is at the 0th percentile, and the data with the least access times is at the 100th percentile. Define the data below the identified percentile p as hot data and record it in the heat statistics table. The rest of the data is defined as cold data. The identified percentile p is calculated using the following formula:

[0056] ;

[0057] Among them, S cache is the actual page cache space, and S file is the size of the value file;

[0058] The upper limit N of elements in the heat statistics table table The calculation is done using the following formula:

[0059] ;

[0060] Among them, N file is the total number of key-value pairs stored in the value file;

[0061] According to the changes in the actual page cache space, the heat identification process is dynamically adjusted and the heat statistics table is trimmed. The trimming of the heat statistics table occurs during the garbage collection process of the corresponding group and occupies a background thread.

[0062] Specifically, for a key-value pair to be written, it needs to be written into the hot buffer and cold buffer corresponding to each key range group. When these hot buffers and cold buffers are full, a 4KiB buffer is used as the writing unit, and the key-value pair is divided into cold and hot persistence to the key range group of the external memory.

[0063] refer to Figure 2 The strategy adopted by the heat statistics table is the least frequently used (LFU) algorithm, which is essentially based on the LFU cache, that is, the heat statistics table implemented by the LFU cache, and the heat statistics table is the LFU cache. The elements stored in the LFU cache are keys, which can keep the keys with higher access times in the heat statistics table and kick out the keys with lower access times and not put them in the heat statistics table. Reference Figure 3 , the LFU cache is composed of a hash table, a red-black tree, and several bidirectional circular linked lists. However, the bidirectional circular linked list is not an independent structure, but is implemented by multiple elements of the hash table. In fact, multiple elements of the hash table are connected to form a formal bidirectional circular linked list, and there are multiple bidirectional circular linked lists. Each element of a hash table contains a pair of predecessor pointers and successor pointers, each of which points to other elements, so that each element can be linked into a bidirectional circular linked list. Each bidirectional circular linked list records keys with the same number of accesses, that is, each node in a bidirectional circular linked list is an element in the hash table corresponding to a key with the same number of accesses. Each element of the red-black tree stores the tail pointer of each bidirectional circular linked list. In order to make this strategy better adapt to the actual application environment, an additional heat recognition adjustment mechanism is proposed. Heat refers to the number of accesses to data, and data with higher heat is defined as hot data, and data with lower heat is defined as cold data. Therefore, it is necessary to apply appropriate rules to identify the hotness and coldness of data. This recognition process is called heat recognition. Specifically, the data needs to be arranged from most to least according to the number of accesses. If the data with the most accesses is at the 0th percentile, and the data with the least accesses is at the 100th percentile, then the data below the specific percentile is called hot data and is recorded in the heat statistics table (i.e., LFU cache). Among them, the specific percentile is called the recognized percentile p. The recognized percentile p is related to the actual page cache space and the value file size. After the heat identification is completed and the recognized percentile p is determined, the upper limit of the number of elements in the heat statistics table (i.e., LFU cache) needs to be determined accordingly to limit the amount of hot data recorded. The upper limit of the number of elements in the heat statistics table is N table It is related to the identified percentile p and the total number of key-value pairs stored in the value file.

[0064] As part of the server, the key-value store may be stored in the same server as other services, which may cause the space of the page cache to change due to various factors. In this case, the heat recognition should be adjusted dynamically according to the changes in the actual page cache space, and the capacity limit of the heat statistics table should be increased or decreased. When the page cache space is reduced, the space of the heat statistics table is correspondingly trimmed, a series of keys with lower access times are kicked out, and the keys with higher access times are identified as the keys corresponding to the hot data. This allows hotter key-value pairs to be in the same cache page. At the same time, the reduced heat statistics table can free up a certain amount of memory space for the page cache to use. The trimming of the heat statistics table occurs during the garbage collection process of the corresponding group and occupies a background thread.

[0065] Based on the above content, the embodiment of the present application introduces the following components, including:

[0066] 1) Heat statistics table: In the workload, all data will be separated into cold data or hot data. The heat statistics table is used to record hot key-value pairs (i.e. hot data). It is the basis of the page cache hot data aggregation strategy. It is implemented by the cache using the LFU algorithm and has a small memory overhead. Every time a key-value pair is obtained, an access is recorded in the heat statistics table. When performing a write operation, a key-value pair is written to the value file. Since the hot key-value pairs written need to be aggregated in the value file, the structure is queried to obtain the hot and cold information of the written key-value pairs.

[0067] 2) Hot buffer and cold buffer: This memory area is used to temporarily retain the written hot key-value pairs (i.e. hot data) and cold key-value pairs (i.e. cold data). In terms of space allocation, their sizes are equal to the page unit, which is 4KiB, and each key range group corresponds to a pair of hot buffer and cold buffer. When the operation of writing a key-value pair to the value file occurs, the hot key-value pair and the cold key-value pair will be stored in the hot buffer and the cold buffer respectively, and when they are filled or cannot accommodate the next key-value pair, the operation of writing the value file is triggered. At a certain moment, there is only one hot buffer or cold buffer that will trigger the operation, so hot and cold separation can be achieved.

[0068] S2, in response to determining that the key in the key-value pair to be written is in the heat statistics table, it is determined that the key-value pair to be written is hot data, and it is determined whether the hot buffer is full. If so, all key-value pairs in the hot buffer are persisted to the corresponding key range grouping, and then the key-value pairs to be written are written into the hot buffer; otherwise, the key-value pairs to be written are directly written into the hot buffer.

[0069] S3, in response to determining that the key in the key-value pair to be written is not in the heat statistics table, it is determined that the key-value pair to be written is cold data, and it is judged whether the cold buffer is full. If so, all key-value pairs in the cold buffer are persisted to the corresponding key range grouping, and then the key-value pairs to be written are written into the cold buffer; otherwise, the key-value pairs to be written are directly written into the cold buffer.

[0070] S4, write the value address and corresponding key of the key-value pair to be written into the LSM tree.

[0071] Specifically, the data writing process proposed in the embodiment of the present application is as follows: first, all key-value pairs will be written into the write buffer; secondly, when the write buffer is full, the key-value pairs will be diverted by key range and written into the hot buffer and cold buffer corresponding to each key range group. During this period, the heat statistics table will be queried, and according to the query results, the hot data will be written into the hot buffer, and the cold data will be written into the cold buffer; then, when any of these hot buffers and cold buffers is full, a 4KiB buffer will be used as a write unit to persist a batch of hot key-value pairs or cold key-value pairs into the key value range group of the external memory; finally, after the key-value pairs are persisted, the addresses of these key-value pairs will be recorded (i.e., the value address), and then the value address and the corresponding key will be inserted into the LSM tree together. The persistence of the hot buffer to the external memory will form a data block. When a hot key-value pair in this data block is read, the unique file system mechanism will read the entire data block into the page cache. In this way, multiple reads of hot key-value pairs can fill the page cache with as many hot key-value pairs as possible.

[0072] refer to Figure 4 , the writing process of the key-value pair to be written is as follows:

[0073] 101. The user sends a write request to the system, to 102.

[0074] 102. Query the heat statistics table. If the key-value pair to be written is hot data, go to 108; otherwise, go to 103.

[0075] 103. Determine whether the cold buffer is filled. If not, go to 105, otherwise go to 104.

[0076] 104. All key-value pairs in the cold buffer are persisted to the key value range group in the external memory, and the cold buffer is cleared to 105.

[0077] 105. Write the key-value pair to be written into the cold buffer, to 106.

[0078] 106. Write the value address and key of the key-value pair to be written into the LSM tree, to 107.

[0079] 107. Return the writing result.

[0080] 108. Determine whether the hot buffer is filled. If not, go to 110, otherwise go to 109.

[0081] 109. All key-value pairs in the persistent hot buffer are grouped into key-value ranges in the external memory, and the hot buffer is cleared, and the process goes to 110.

[0082] 110. Write the key-value pair to be written into the hot buffer, to 106.

[0083] The above steps S1-S4 do not necessarily represent the order between the steps, but are represented by step symbols, and the order between the steps can be adjusted.

[0084] Further references Figure 5 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a page cache hot data aggregation device applied to a key-value separation storage system. The device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0085] The embodiment of the present application provides a page cache hot data aggregation device applied to a key-value separation storage system. The key-value separation storage system includes an LSM tree, a memory, and an external memory. The memory stores a write buffer, a heat statistics table, a hot buffer, and a cold buffer. The external memory stores a value file. The value file stores data grouped by key ranges corresponding to the hot buffer and the cold buffer, including:

[0086] A query module 1 is configured to query a heat statistics table in response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file;

[0087] The hot data writing module 2 is configured to determine that the key in the key-value pair to be written is hot data in response to determining that the key in the key-value pair to be written is in the heat statistics table, and judge whether the hot buffer is full. If so, persist all the key-value pairs in the hot buffer to the corresponding key range group, and then write the key-value pair to be written into the hot buffer; otherwise, directly write the key-value pair to be written into the hot buffer;

[0088] The cold data writing module 3 is configured to determine that the key in the key-value pair to be written is cold data in response to determining that the key in the key-value pair to be written is not in the heat statistics table, and judge whether the cold buffer is full. If so, persist all the key-value pairs in the cold buffer to the corresponding key range group, and then write the key-value pair to be written into the cold buffer; otherwise, directly write the key-value pair to be written into the cold buffer;

[0089] The value address writing module 4 is configured to write the value address and the corresponding key of the key-value pair to be written into the LSM tree.

[0090] Figure 6 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 6 As shown, the electronic device of this embodiment includes: a processor 601 and a memory 602; wherein the memory 602 is used to store computer-executable instructions; the processor 601 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0091] Optionally, the memory 602 may be independent or integrated with the processor 601 .

[0092] When the memory 602 is independently provided, the electronic device further includes a bus 603 for connecting the memory 602 and the processor 601 .

[0093] An embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the above method is implemented.

[0094] An embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by a processor, the above method is implemented.

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

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

[0097] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit. The above-mentioned module-composed unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0098] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.

[0099] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0100] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0101] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0102] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0103] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0104] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A page cache hot data aggregation method applied to a key-value separation storage system, wherein the key-value separation storage system comprises an LSM tree, a memory and an external memory, wherein the memory stores a write buffer, a heat statistics table, a hot buffer and a cold buffer, and the external memory stores a value file, wherein the value file stores data grouped by key ranges corresponding to the hot buffer and the cold buffer, characterized in that: The following steps are involved: In response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file, the heat statistics table is queried. The strategy adopted by the heat statistics table includes a least frequently used algorithm and is implemented based on an LFU cache. The LFU cache includes a hash table, a red-black tree, and several bidirectional circular linked lists. The elements of the hash table include a key and a number of accesses corresponding to the key, a predecessor pointer, and a successor pointer. Each node on the bidirectional circular linked list is an element corresponding to a key with the same number of accesses in the hash table, and each node on the bidirectional circular linked list is connected by the predecessor pointer and the successor pointer. Each of the bidirectional circular linked lists has a header node and a tail node. The address of the tail node is stored in the tail pointer. Each node of the red-black tree stores the number of accesses of the corresponding element on the bidirectional circular linked list and the tail pointer of the bidirectional circular linked list. The heat statistics table uses a heat recognition method to define data as hot data or cold data. The process of the heat recognition method is as follows: Arrange the data from most to least access times. The data with the most access times is at the 0th percentile, and the data with the least access times is at the 100th percentile. The data below the identified percentile p is defined as hot data and recorded in the heat statistics table. The rest of the data is defined as cold data. The identified percentile p is calculated using the following formula: p=S cache / S file ; Among them, S cache is the actual page cache space, and S file is the size of the value file; The upper limit N of the elements in the heat statistics table table The calculation is done using the following formula: N table =p×N file ; Among them, N file is the total amount of key-value pairs stored in the value file; According to the change of the actual page cache space, the heat identification process is dynamically adjusted, and the heat statistics table is trimmed. The trimming of the heat statistics table occurs during the garbage collection process of the corresponding group and occupies a background thread. In response to determining that the key in the key-value pair to be written is in the heat statistics table, determining that the key-value pair to be written is hot data, judging whether the hot buffer is full, if so, persisting all the key-value pairs in the hot buffer to the corresponding key range group, and then writing the key-value pair to be written into the hot buffer, otherwise directly writing the key-value pair to be written into the hot buffer; In response to determining that the key in the key-value pair to be written is not in the heat statistics table, determining that the key-value pair to be written is cold data, judging whether the cold buffer is full, if so, persisting all key-value pairs in the cold buffer to the corresponding key range group, and then writing the key-value pair to be written to the cold buffer, otherwise directly writing the key-value pair to be written to the cold buffer; The value address of the key-value pair to be written and the corresponding key are written into the LSM tree.

2. The page cache hot data aggregation method applied to a key-value separation storage system according to claim 1, characterized in that: The querying of the heat statistics table specifically includes: The key in the key-value pair to be written is queried in the hash table. If the key in the key-value pair to be written is found in the hash table, it is determined that the key in the key-value pair to be written is in the heat statistics table, the number of accesses in the element of the hash table corresponding to the key-value pair to be written is increased by 1, and the index relationship of the bidirectional circular linked list where the element of the hash table corresponding to the key-value pair to be written is located is adjusted, and nodes are added and deleted, and the tail pointer of the bidirectional circular linked list corresponding to the node of the red-black tree is adjusted; If it is found that the key in the key-value pair to be written is not in the hash table, it is determined that the key in the key-value pair to be written is not in the heat statistics table, and the element corresponding to the key-value pair to be written is recorded in the hash table, wherein the number of accesses in the element corresponding to the key-value pair to be written is 1, and a node corresponding to the element corresponding to the key-value pair to be written is added to the bidirectional circular linked list corresponding to the number of accesses of 1, and the index relationship of the bidirectional circular linked list and the tail pointer of the bidirectional circular linked list corresponding to the node of the red-black tree are adjusted.

3. The page cache hot data aggregation method applied to a key-value separation storage system according to claim 1, characterized in that: Each of the key range groups corresponds to a pair of hot buffer and cold buffer, the sizes of the hot buffer and the cold buffer are equal to the page unit, and the heat statistics table is initialized to be empty.

4. A page cache hot data aggregation device applied to a key-value separation storage system, the key-value separation storage system comprising an LSM tree, a memory and an external memory, the memory storing a write buffer, a heat statistics table, a hot buffer and a cold buffer, the external memory storing a value file, the value file storing data grouped by key ranges corresponding to the hot buffer and the cold buffer, characterized in that: include: The query module is configured to query the heat statistics table in response to determining that the write buffer is full and obtaining an operation instruction to write the key-value pair to be written into the value file. The strategy adopted by the heat statistics table includes a least frequently used algorithm and is implemented based on an LFU cache. The LFU cache includes a hash table, a red-black tree, and a plurality of bidirectional circular linked lists. The elements of the hash table include a key and a number of accesses corresponding to the key, a predecessor pointer, and a successor pointer. Each node on the bidirectional circular linked list is an element corresponding to a key with the same number of accesses in the hash table, and each node on the bidirectional circular linked list is connected by the predecessor pointer and the successor pointer. Each of the bidirectional circular linked lists has a header node and a tail node. The address of the tail node is stored in the tail pointer. Each node of the red-black tree stores the number of accesses of the corresponding element on the bidirectional circular linked list and the tail pointer of the bidirectional circular linked list. The heat statistics table uses a heat recognition method to define data as hot data or cold data. The process of the heat recognition method is as follows: Arrange the data from most to least access times. The data with the most access times is at the 0th percentile, and the data with the least access times is at the 100th percentile. The data below the identified percentile p is defined as hot data and recorded in the heat statistics table. The rest of the data is defined as cold data. The identified percentile p is calculated using the following formula: p=S cache / S file ; Among them, S cache is the actual page cache space, and S file is the size of the value file; The upper limit N of the elements in the heat statistics table table The calculation is done using the following formula: N table =p×N file ; Among them, N file is the total amount of key-value pairs stored in the value file; According to the change of the actual page cache space, the heat identification process is dynamically adjusted, and the heat statistics table is trimmed. The trimming of the heat statistics table occurs during the garbage collection process of the corresponding group and occupies a background thread. A hot data writing module is configured to, in response to determining that the key in the key-value pair to be written is in the heat statistics table, determine that the key-value pair to be written is hot data, judge whether the hot buffer is full, and if so, persist all the key-value pairs in the hot buffer to the corresponding key range group, and then write the key-value pair to be written into the hot buffer; otherwise, directly write the key-value pair to be written into the hot buffer; A cold data writing module is configured to, in response to determining that the key in the key-value pair to be written is not in the heat statistics table, determine that the key-value pair to be written is cold data, judge whether the cold buffer is full, and if so, persist all the key-value pairs in the cold buffer to the corresponding key range group, and then write the key-value pair to be written into the cold buffer; otherwise, directly write the key-value pair to be written into the cold buffer; The value address writing module is configured to write the value address and the corresponding key of the key-value pair to be written into the LSM tree.

5. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.

6. 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 3 is implemented.

7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.