A data processing method, device, equipment and storage medium
By selecting compression algorithms and dividing granularity according to business scenarios, the data in the all-flash system is appropriately compressed, solving the problem of compression ratio and compression performance balance, improving storage efficiency and access performance, and reducing storage costs.
Patent Information
- Application Number
- CN201910697041.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-30
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-04-18
AI Technical Summary
When all-flash systems pursue high compression rates, compression performance decreases, making it difficult to achieve a balance between compression rate and compression performance.
Determine the target compression algorithm according to the business scenario, compress the target data, and select an appropriate compression rate threshold when writing to ensure that the compression rate or compression performance is sacrificed in different scenarios to achieve a balance.
By selecting compression algorithms and division granularity for different business scenarios, effective data compression in all-flash memory systems is achieved, storage efficiency and access performance are improved, and storage costs are reduced.
Smart Images

Figure CN112306974B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a data processing method, device, equipment and storage medium. Background Art
[0002] With the rapid development of computer technology and Internet technology, the amount of business data in various industries continues to grow, and the demand for storage capacity in data centers continues to increase. At the same time, real-time interactive applications such as cloud computing, online payment, and mobile social networking have increasingly higher requirements for the access performance and latency of data center storage systems. As a result, data centers have gradually changed from using traditional mechanical hard disks to build storage systems to using all-flash solutions. All-flash systems can provide higher IOPS (Input / Output Operations Per Second), lower IO (Input / Output) access latency, and higher access throughput, and are often used in scenarios such as financial securities, online transactions, e-commerce, and online ticket purchases.
[0003] However, all-flash systems also face disadvantages such as high price, small capacity and limited write / erase cycles. Therefore, in all-flash systems, data is usually compressed before storage to save storage space and reduce the actual cost per GB. However, the current pursuit of high compression rates has reduced the compression performance of some data. Summary of the invention
[0004] The object of the present invention is to provide a data processing method, device, equipment and storage medium to achieve a balance between compression rate and compression performance.
[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0006] A data processing method, comprising:
[0007] When the trigger condition for writing the target data is met, the current business scenario is determined;
[0008] Determining a target compression algorithm for the target data according to the business scenario;
[0009] Using the target compression algorithm, compressing the target data to obtain the data to be written corresponding to the target data;
[0010] The data to be written is written into the target log file.
[0011] In a specific implementation of the present invention, the use of the target compression algorithm to compress the target data to obtain the data to be written corresponding to the target data includes:
[0012] Using the target compression algorithm, compressing the target data to obtain a compression result;
[0013] According to the compression processing result, the to-be-written data corresponding to the target data is determined.
[0014] In a specific implementation of the present invention, determining the data to be written corresponding to the target data according to the compression processing result includes:
[0015] Determining a compression ratio of the target data according to the compression processing result;
[0016] If the compression rate is higher than a preset first compression rate threshold, the compressed data obtained after compressing the target data is determined as the data to be written;
[0017] Otherwise, the target data is determined as data to be written.
[0018] In a specific embodiment of the present invention, it also includes:
[0019] When a data block to be read is to be read, querying the physical address of the data block to be read;
[0020] Read the data block to be read in the corresponding log file according to the physical address obtained by querying, wherein the header of each data block in each log file at least includes a compression parameter field;
[0021] According to the compression parameter field contained in the header of the data block to be read, the data block to be read is decompressed to obtain regular data corresponding to the data block to be read.
[0022] In a specific implementation of the present invention, the target data is initially written data, and the target data is compressed using the target compression algorithm, including:
[0023] Determining a first division granularity for dividing the target data according to the data volume of the target data;
[0024] Dividing the target data into a plurality of first data blocks using the first division granularity;
[0025] The target compression algorithm is used to compress each of the first data blocks.
[0026] In a specific implementation of the present invention, after using the target compression algorithm to compress each of the first data blocks respectively, the method further includes:
[0027] If the compression rate of each of the first data blocks is not higher than a preset second compression rate threshold, dividing the target data block into a plurality of second data blocks using a second division granularity, where the second division granularity is smaller than the first division granularity;
[0028] Each of the second data blocks is compressed using the target compression algorithm.
[0029] In a specific implementation of the present invention, when the trigger condition for writing the target data is reached, before determining the current business scenario, it also includes:
[0030] When the garbage collection triggering condition is met, the log files to be recycled are determined;
[0031] Determine whether each valid data block in the log file to be recovered is cold data;
[0032] The valid data blocks determined to be cold data are used as the target data.
[0033] In a specific implementation of the present invention, after determining the log file to be recycled when the garbage collection triggering condition is met, the method further includes:
[0034] Each of the valid data blocks determined as hot data in the log file to be recycled is written into a new log file.
[0035] In a specific implementation of the present invention, when the garbage collection triggering condition is met, determining the log file to be recycled includes:
[0036] When the garbage collection triggering condition is met, the log file whose ratio of the data amount of the invalid data block to the valid data block is greater than the set ratio threshold is determined as the log file to be recycled.
[0037] In a specific embodiment of the present invention, it also includes:
[0038] When there is an update to the third data block in the target log file, writing the updated third data block into a new log file;
[0039] The third data block in the target log file is marked as an invalid data block.
[0040] A data processing device, comprising:
[0041] A business scenario determination module, used to determine the current business scenario when the trigger condition for writing the target data is met;
[0042] A compression algorithm determination module, used to determine a target compression algorithm for the target data according to the business scenario;
[0043] A data acquisition module, used to compress the target data using the target compression algorithm to obtain the data to be written corresponding to the target data;
[0044] The data writing module is used to write the data to be written into the target log file.
[0045] A data processing device, comprising:
[0046] Memory for storing computer programs;
[0047] A processor is used to implement the steps of any of the above-mentioned data processing methods when executing the computer program.
[0048] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned data processing methods are implemented.
[0049] By applying the technical solution provided by the embodiment of the present invention, when the trigger condition for writing the target data is met, the current business scenario is determined, and according to the business scenario, the target compression algorithm for the target data is determined, and the target data is compressed using the target compression algorithm to obtain the data to be written corresponding to the target data, and write it into the target log file. Different compression algorithms are selected for different business scenarios to compress the data to be written. For some data, the compression rate can be sacrificed to ensure the compression performance, and for some data, the compression performance can be sacrificed to ensure the compression rate, so that a balance between the compression rate and the compression performance can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art 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.
[0051] Figure 1 A schematic diagram of a data processing system according to an embodiment of the present invention;
[0052] Figure 2 is an implementation flow chart of a data processing method in an embodiment of the present invention;
[0053] Figure 3 is a structural schematic diagram of a data processing device in an embodiment of the present invention;
[0054] Figure 4The figure is a schematic diagram of the structure of a data processing device in an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The core of the present invention is to provide a data processing method, which can be adapted to an all-flash memory system, and of course, can also be adapted to other storage systems. In an embodiment of the present invention, based on the current business scenario, a target compression algorithm for the target data to be written is determined, the target data is compressed using the target compression algorithm, and the actual data to be written is determined, and the data to be written is written into the target log file. Based on the business scenario, a compression method suitable for the data currently to be written to the log file is selected to compress the data. For some data, the compression rate can be sacrificed to ensure compression performance, and for some data, the compression performance can be sacrificed to ensure the compression rate, so as to achieve a balance between the compression rate and the compression performance.
[0056] The so-called All-Flash-Array System (AFA) refers to an independent storage array or device composed entirely of solid-state storage media (usually NAND Flash), without a hard disk drive (HDD). It can be used to enhance the performance of an environment that may contain a disk array, or to replace all traditional hard disk storage arrays. All-Flash systems can provide higher IOPS performance, lower latency, and higher throughput. NAND flash faces the challenges of high price per GB and limited write / erase cycles. Therefore, all-flash systems can use data reduction technologies such as data deduplication, automatic thin provisioning, and data compression to ensure the smooth operation of all-flash systems and reduce the actual cost per GB. Generally speaking, all-flash systems can perform data deduplication to eliminate duplicate data, and then further compress non-duplicate data at the byte level. The scenarios that require compression in all-flash systems are mainly: the scenario where data first enters the storage system (real-time write operation) and the scenario where cold data is stored during garbage collection.
[0057] The log file system provides efficient random write performance for all-flash systems. The log file system is also called a log-structured file system. It is a log-type storage system that supports redirection on write. Business data is written to the system in the form of append writes. The address mapping from logical address to physical address is added or updated in the metadata center, and the address mapping points to valid data. Data not pointed to by the address mapping is marked as invalid data and recycled through the background garbage collection mechanism to release storage space. In the log-structured file system, the basic unit of data storage is the log file, or data segment. When storage space is insufficient, the log files can be sorted according to their utilization, the log files with low utilization can be recycled, and the available data can be copied to new log files.
[0058] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0059] like Figure 1 As shown, it is a schematic diagram of the overall framework of a data processing system in an embodiment of the present invention. The data processing system may include a metadata center 110, a metadata cache center 120, a compression engine 130 and a log storage center 140.
[0060] Among them, the metadata center 110 is used to store metadata information and provide indexing and addressing services for data read and write requests. The metadata cache center 120 can be used to cache metadata information to reduce the overhead of accessing the metadata center. The compression engine 130 includes a compression buffer unit, a business scenario identification unit, a variable-length granularity division unit, a compression format output unit and a compression pipeline. When there is data to be written, the data first arrives at the compression buffer unit, the current business scenario is identified by the business scenario identification unit, the compression algorithm is determined, the data is divided by the variable-length granularity division unit, and the divided data blocks are compressed by the compression pipeline using the determined compression algorithm. The compressed data is added to the header containing the set compression parameter field by the compression format output unit, and then written to the log file of the log storage center 140, and the file attribute information, such as the size of the compressed data, etc., can be updated. The access frequency and storage time of each data block in the system can be recorded in the log storage center 140 later.
[0061] The compression pipeline can provide batch compression services, data block compression / decompression operation context, improve throughput, maximize the use of limited computing resources and reduce compression time overhead.
[0062] The data compressed by the compression pipeline and the original data are organized into a set fixed format. For example, compression parameters such as the algorithm name, compression length, and compressed data identifier are written into the header, which can ensure that other systems or work units are unaware of whether the data in the log file is compressed data.
[0063] The compressed data can be batch sorted and stored on disk, and the storage request is pushed to the metadata cache center 120 to record the metadata information. After the relevant metadata information is updated to the metadata cache center 120, a write success message can be returned, and then the metadata cache center 120 can update the address mapping information to the metadata center 110 in the background.
[0064] The entire compression engine 130 and the metadata cache center 120 are all running in the memory. The log storage center 140 may include a log header area and a log data area, which are stored in the underlying solid-state storage SSD. The log header area can store data self-description information, and the log data area stores compressed or uncompressed data.
[0065] See also Figure 2 FIG. 1 is a flowchart of a data processing method according to an embodiment of the present invention. The method may include the following steps:
[0066] S210: When a trigger condition for writing target data is met, determine a current business scenario.
[0067] During the business process, there may be a need to write data, such as new data to be written or data to be migrated. When a write request for target data is received from a user or other system, it can be considered that the trigger condition for writing the target data is met.
[0068] When the trigger condition for writing the target data is reached, the current business scenario can be determined. As described above, there are two main business scenarios, one is the real-time writing scenario, and the other is the cold data storage scenario during garbage collection. Of course, more scenarios can be distinguished according to actual needs.
[0069] S220: Determine a target compression algorithm for the target data according to the business scenario.
[0070] Different business scenarios have different requirements for data access latency, compression rate, etc. For example, in real-time write scenarios, the data is new data when it enters for the first time, and the probability of being accessed later is relatively high. The compression rate can be appropriately sacrificed, and a compression algorithm with high compression and decompression performance can be used to minimize the impact on read and write operation latency. For example, compression algorithms such as LZ4, Snappy, ZSTD, and Intel I-SAL can be selected. In cold data storage scenarios during garbage collection, the frequency of data access is reduced, and the compression and decompression speed can be appropriately sacrificed. A compression algorithm with a high compression rate can be selected, such as zlib deflate-6, Def9_128_SW, etc., to minimize storage overhead.
[0071] S230: compressing the target data using a target compression algorithm to obtain data to be written corresponding to the target data.
[0072] After determining the target compression algorithm for the target data, the target compression algorithm can be used to compress the target data to obtain the data to be written corresponding to the target data.
[0073] In a specific implementation of the present invention, step S230 may include the following steps:
[0074] Step 1: Use the target compression algorithm to compress the target data and obtain the compression result;
[0075] Step 2: According to the compression processing result, determine the data to be written corresponding to the target data.
[0076] For ease of description, the above two steps are combined for illustration.
[0077] After determining the target compression algorithm, the target data is compressed using the target compression algorithm to obtain compressed data and a compression processing result. The compression processing result may include information such as the amount of compressed data and the compression ratio of the target data. According to the compression processing result, the data to be written corresponding to the target data may be determined.
[0078] Specifically, the compression rate of the target data can be determined according to the compression processing result. The compression rate of the target data can be represented by the ratio of the data volume of the target data to the data volume of the compressed data. If the compression rate is higher than the preset first compression rate threshold, it indicates that the compression effect is good, and the compressed data obtained after the target data is compressed can be determined as the data to be written. If the compression rate is not higher than the first compression rate threshold, it indicates that the compression effect is average, and the target data can be determined as the data to be written.
[0079] The first compression rate threshold may be set and adjusted according to actual conditions, and the embodiment of the present invention does not limit this.
[0080] In general, a best-effort compression strategy is adopted. If the compression rate is too low, the original data is kept to improve access efficiency. Otherwise, the compressed data is written to save storage space.
[0081] S240: Writing the data to be written into the target log file.
[0082] After obtaining the data to be written corresponding to the target data, the data to be written can be written into the target log file. The size of a single log file can be configured, such as 64M. When the log file is full, a new log file is created for writing. That is, if all the current log files are full, the target log file is created first, and then the data to be written is written. If there are still log files that are not full, the unfilled log file is determined as the target log file and the data to be written is written.
[0083] By applying the method provided by the embodiment of the present invention, when the trigger condition for writing the target data is met, the current business scenario is determined, and according to the business scenario, the target compression algorithm for the target data is determined, and the target data is compressed using the target compression algorithm to obtain the data to be written corresponding to the target data, and write it into the target log file. Different compression algorithms are selected for different business scenarios to compress the data to be written. For some data, the compression rate can be sacrificed to ensure the compression performance, and for some data, the compression performance can be sacrificed to ensure the compression rate, so that a balance between the compression rate and the compression performance can be achieved.
[0084] In practical applications, when using a target compression algorithm to compress target data, the target data may be first divided into multiple data blocks, and each data block may be compressed separately. For each data block, if the compression rate of the data block is small, the data block may be directly written; if the compression rate of the data block is large, the compressed data block obtained after the data block is compressed may be written into a log file. Specifically, the compression rate may be determined by comparing the compression rate with a compression rate threshold.
[0085] In a specific implementation of the present invention, the target data is the first written data, and step S230 may include the following steps:
[0086] The first step: determining the first partitioning granularity for partitioning the target data according to the data volume of the target data;
[0087] The second step: using the first partitioning granularity to divide the target data into a plurality of first data blocks;
[0088] The third step: using the target compression algorithm to compress each first data block respectively.
[0089] For ease of description, the above three steps are combined for description in this embodiment of the present invention.
[0090] After determining the target compression algorithm, the first partitioning granularity for partitioning the target data can be determined according to the data volume of the target data. Specifically, the largest partitioning granularity can be selected from the selectable partitioning granularities. For example, all the partitioning granularities are: 32KB, 24KB, 16KB, 8KB. If the selectable partitioning granularities are: 32KB, 24KB, 16KB, 8KB according to the data volume of the target data, then 32KB can be determined as the first partitioning granularity. If the selectable partitioning granularities are: 24KB, 16KB, 8KB according to the data volume of the target data, then 24KB can be determined as the first partitioning granularity.
[0091] Using the first division granularity, the target data can be divided into multiple first data blocks, and then the target compression algorithm is used to compress each first data block. According to the compression processing result, the data to be written can be determined. For example, each compressed first data block is determined as the data to be written, or each original first data block before compression is determined as the data to be written.
[0092] In one embodiment of the present invention, after each first data block is compressed using the target compression algorithm, if the compression rate of each first data block is not higher than a preset second compression rate threshold, the target data may be divided into a plurality of second data blocks using a second division granularity, and each second data block may be compressed using the target compression algorithm. The second division granularity is smaller than the first division granularity.
[0093] After each first data block is compressed, if the compression rate of each first data block is not higher than the preset second compression rate threshold, it indicates that the compression effect is average. In this case, the second partitioning granularity can be selected, and the target data can be divided into multiple second data blocks using the second partitioning granularity, and each second data block can be compressed using the target compression algorithm. Of course, if the compression rate of each second data block is not higher than the preset second compression rate threshold, a third partitioning granularity can also be selected, and the third partitioning granularity is smaller than the second partitioning granularity, and the target data is divided using the third partitioning granularity, and then each divided data block is compressed using the target compression algorithm.
[0094] In practical applications, a partition granularity set may be preset, and the partition granularity set may contain N partition granularities, and the N partition granularities are arranged in the partition granularity set in order of size. For example, the partition granularity set is {32KB, 24KB, 16KB, 8KB}, where 32KB, 24KB, 16KB, and 8KB are all partition granularities, and are arranged in the partition granularity set in order of decreasing size.
[0095] When compressing the target data, you can also perform the following steps:
[0096] The first step: according to the amount of target data, determine the i-th partitioning granularity in the partitioning granularity set as the target partitioning granularity, the partitioning granularity set includes N partitioning granularities that decrease in sequence, and i and N are both positive integers;
[0097] The second step: divide the target data into multiple target data blocks according to the target partition granularity;
[0098] The third step: Use the target compression algorithm to compress each target data block separately.
[0099] After determining the target compression algorithm, the i-th partitioning granularity in the partitioning granularity set can be determined as the target partitioning granularity according to the data volume of the target data. Specifically, the partitioning granularity that is closest to the data volume of the target data can be selected, that is, large block partitioning is performed first, and the block length selection decreases with the actual length. For example, if the data volume of the target data is 128KB, the first partitioning granularity in the partitioning granularity set, that is, 32KB, is determined as the target partitioning granularity. If the data volume of the target data is 30KB, the second partitioning granularity in the partitioning granularity set, that is, 24KB, is determined as the target partitioning granularity.
[0100] According to the target division granularity, the target data is divided into multiple target data blocks, and then the target compression algorithm is used to compress each target data block. According to the compression processing result, the data to be written can be determined. For example, each compressed data block is determined as the data to be written.
[0101] In practical applications, the target data can be divided into multiple small data blocks using the minimum partitioning granularity. When a certain partitioning granularity is needed to partition the target data, a corresponding number of small data blocks can be taken to form a data block of the corresponding size of the partitioning granularity. For example, if the target data is divided into eight 8KB small data blocks using an 8KB partitioning granularity, when the target partitioning granularity is determined to be 32KB, the first four and last four 8KB small data blocks can be combined to form two 32KB data blocks.
[0102] Of course, after determining the target partition granularity, the target data may be segmented using the target partition granularity to be divided into a plurality of target data blocks.
[0103] In one embodiment of the present invention, after compressing each target data block respectively, if the compression ratio of the compression processing of each target data block is not higher than the preset second compression ratio threshold, let i=i+1, and repeat the step of determining the i-th division granularity in the division granularity set as the target division granularity until i=N or the compression ratio of the compression processing of each target data block is higher than the second compression ratio threshold.
[0104] After each target data block is compressed, if the compression rate of each target data block is not higher than the preset second compression rate threshold, it indicates that the compression effect is average, and then i=i+1 can be set, the next partitioning granularity is selected, and the steps of determining the partitioning granularity as the target partitioning granularity is repeated, dividing the target data into multiple target data blocks according to the target partitioning granularity, and using the target compression algorithm to compress each target data block respectively are performed. Until i=N, the last partitioning granularity is selected, which is also the minimum partitioning granularity, and the partitioning granularity is determined as the target partitioning granularity. According to the target partitioning granularity, the target data is divided into multiple target data blocks, and the target compression algorithm is used to compress each target data block respectively. If the compression rate of each target data block is still not higher than the preset second compression rate threshold, the compression of each target data block can be abandoned, and the target data block can be directly written into the target log file as the data to be written.
[0105] Of course, in any process of repeated execution, if the compression rate of each target data block is higher than the preset second compression rate threshold, the division, compression and other operations using the next division granularity may no longer be performed, and the corresponding compressed data block may be written into the target log file as the data to be written.
[0106] The compression rate of each target data block can be represented by the average of each compression rate corresponding to the compression process of each target data block, or by the ratio of the data volume of the target data to the data volume of the compressed data block obtained after the compression process of each target data block. The second compression rate threshold can be set and adjusted according to actual conditions, and can be the same as or different from the first compression rate threshold.
[0107] In one embodiment of the present invention, when the trigger condition for writing the target data is met, before determining the current business scenario, the method may further include the following steps:
[0108] Step 1: When the garbage collection triggering condition is met, the log files to be recycled are determined;
[0109] Step 2: Determine whether each valid data block in the log file to be recovered is cold data;
[0110] Step 3: Use the valid data blocks determined to be cold data as target data.
[0111] For ease of description, the above three steps are combined for explanation.
[0112] In actual applications, as the business progresses, more and more log files are generated, and more and more storage space is occupied. When the storage space occupancy rate reaches the set occupancy rate threshold, it can be considered that the garbage collection trigger condition has been met. Or when a garbage collection instruction is received, it can be considered that the garbage collection trigger condition has been met. Or when the set time interval is reached, it can be considered that the garbage collection trigger condition has been met.
[0113] When the garbage collection triggering condition is reached, the log files to be recycled can be determined. The log files to be recycled can be manually specified, or determined based on the data situation in the log files. Specifically, when the garbage collection triggering condition is reached, the log files whose data volume ratio of invalid data blocks to valid data blocks is greater than a set ratio threshold can be determined as log files to be recycled. That is, for each log file, if the data volume ratio of invalid data blocks to valid data blocks in the log file is greater than a set ratio threshold, the log file can be determined as a log file to be recycled.
[0114] The invalid data blocks in the log file can be manually specified, or when the third data block in the target log file is updated, the updated third data block is written into a new log file, and the third data block in the target log file is marked as an invalid data block.
[0115] It is understandable that there may be both invalid data blocks and valid data blocks in the log file to be recovered. The valid data blocks still have use value and cannot be recovered. For each valid data block in the log file to be recovered, it can be determined whether the valid data block is cold data or hot data. That is, the data blocks in the log file to be recovered are separated into cold data and hot data, and each valid data block in the log file to be recovered is determined to be cold data.
[0116] Specifically, for valid data blocks, the survival time and access frequency of valid data blocks can be counted, and hot and cold data can be separated accordingly. The compression engine can record the time when each data block enters the system, and also record the number of accesses to the data block. For data blocks whose storage time exceeds a set time threshold, such as 15 days or 30 days, the data blocks can be sorted according to the number of accesses or the access frequency of the data blocks. Data with low access times or low access frequencies are cold data. The ratio of hot and cold data can be adjusted, such as 20% is hot data and 80% is cold data.
[0117] The valid data block determined as cold data can be used as the target data. That is, for each valid data block, if the valid data block is determined to be cold data, the valid data block can be determined as the target data, and it is determined that the trigger condition for writing the target data is currently met, and the operations of step S210 to step S240 are continued. That is, during data migration, the cold data will be further compressed using a compression algorithm with a high compression rate and written into the target log file to save storage space. In this case, the target log file can be a newly created log file.
[0118] When the garbage collection triggering condition is met, after the log file to be recycled is determined, each valid data block determined as hot data in the log file to be recycled can be written into a new log file. That is, for each valid data block in the log file to be recycled, if the valid data block is determined to be hot data, the valid data block can be written into the new log file.
[0119] For updates involving the data storage location, after the update, the metadata information of the data block needs to be updated in the metadata center.
[0120] After the valid data blocks in the log file to be recovered are migrated, the log file to be recovered can be recovered. If it is stored in a set location, after the set retention period is reached, the log file to be recovered is deleted so that it can be restored within the retention period when it needs to be restored, or it can be deleted directly.
[0121] In one embodiment of the present invention, the method may further include the following steps:
[0122] The first step: when a data block to be read is to be read, the physical address of the data block to be read is queried;
[0123] The second step: read the data block to be read in the corresponding log file by using the physical address obtained by querying, and the header of each data block in each log file contains at least a compression parameter field;
[0124] The third step: decompress the data block to be read according to the compression parameter field contained in the header of the data block to be read, and obtain the regular data corresponding to the data block to be read.
[0125] For ease of description, the above three steps are combined for explanation.
[0126] In the embodiment of the present invention, the header of each data block in each log file includes at least a compression parameter field, such as a compression algorithm field, a compression length field, a compressed data identification field, etc. The data block in the log file can be a compressed data block or an uncompressed data block.
[0127] When a data block to be read is to be read, the physical address of the data block to be read can be queried first. Specifically, the corresponding physical address can be queried in the metadata cache center according to the logical address of the data block to be read. If the physical address is not found, the metadata center is queried.
[0128] By querying the obtained physical address, it is possible to determine in which log file the data block to be read is located, and the data block to be read can be read in the corresponding log file. According to the compression parameter field contained in the header of the data block to be read, the data block to be read is decompressed to obtain the regular data corresponding to the data block to be read.
[0129] When a request to read data is received, the data block corresponding to the data can be determined first, and each data block is read using the above method. After decompression, the corresponding multiple regular data are combined and returned to the requesting party.
[0130] In an embodiment of the present invention, by performing business scenario-aware variable-length compression on data in an all-flash memory system, business read and write network traffic and storage traffic can be reduced, thereby reducing the storage cost per GB of the all-flash memory.
[0131] Corresponding to the above method embodiment, the embodiment of the present invention further provides a data processing device. The data processing device described below and the data processing method described above can refer to each other.
[0132] See also Figure 3 As shown, the device comprises:
[0133] A business scenario determination module 310, for determining the current business scenario when a trigger condition for writing target data is met;
[0134] A compression algorithm determination module 320 is used to determine a target compression algorithm for target data according to a business scenario;
[0135] The data acquisition module 330 is used to compress the target data using the target compression algorithm to obtain the data to be written corresponding to the target data;
[0136] The data writing module 340 is used to write the data to be written into the target log file.
[0137] By using the device provided by the embodiment of the present invention, when the trigger condition for writing the target data is met, the current business scenario is determined, and according to the business scenario, the target compression algorithm for the target data is determined, and the target data is compressed using the target compression algorithm to obtain the data to be written corresponding to the target data, and write it into the target log file. Different compression algorithms are selected for different business scenarios to compress the data to be written. For some data, the compression rate can be sacrificed to ensure the compression performance, and for some data, the compression performance can be sacrificed to ensure the compression rate, so that a balance between the compression rate and the compression performance can be achieved.
[0138] In a specific implementation of the present invention, the data acquisition module 330 is specifically used to:
[0139] Using a target compression algorithm, compressing the target data to obtain a compression result;
[0140] According to the compression processing result, the data to be written corresponding to the target data is determined.
[0141] In a specific implementation of the present invention, the data acquisition module 330 is specifically used to:
[0142] Determine the compression rate of the target data according to the compression processing result;
[0143] If the compression rate is higher than a preset first compression rate threshold, the compressed data obtained after compressing the target data is determined as the data to be written;
[0144] Otherwise, the target data is determined as the data to be written.
[0145] In a specific implementation of the present invention, the target data is the first written data, and the data acquisition module 330 is specifically used to:
[0146] Determining a first partitioning granularity for partitioning the target data according to the data volume of the target data;
[0147] Dividing the target data into a plurality of first data blocks using a first division granularity;
[0148] Each first data block is compressed using a target compression algorithm.
[0149] In a specific embodiment of the present invention, the data acquisition module 330 is further used to:
[0150] If the compression rate of each first data block is not higher than a preset second compression rate threshold, the target data block is divided into a plurality of second data blocks using a second division granularity, where the second division granularity is smaller than the first division granularity;
[0151] Each second data block is compressed using a target compression algorithm.
[0152] In a specific embodiment of the present invention, a data determination module is further included, which is used to:
[0153] When the trigger condition for writing the target data is reached, before determining the current business scenario, when the garbage collection trigger condition is reached, determine the log file to be recycled;
[0154] Determine whether each valid data block in the log file to be recovered is cold data;
[0155] The valid data blocks determined to be cold data are used as target data.
[0156] In a specific implementation of the present invention, the data writing module 340 is further used to:
[0157] When the garbage collection triggering condition is met, after the log file to be recycled is determined, each valid data block determined as hot data in the log file to be recycled is written into a new log file.
[0158] In a specific implementation of the present invention, the data determination module is specifically used to:
[0159] When the garbage collection triggering condition is met, the log file whose ratio of the data amount of the invalid data block to the valid data block is greater than the set ratio threshold is determined as the log file to be recycled.
[0160] In a specific embodiment of the present invention, a data marking module is also included, which is used to:
[0161] When there is an update to the third data block in the target log file, writing the updated third data block into the new log file;
[0162] The third data block in the target log file is marked as an invalid data block.
[0163] In a specific embodiment of the present invention, a data reading module is also included, which is used to:
[0164] When a data block to be read is to be read, the physical address of the data block to be read is queried;
[0165] Read the data block to be read in the corresponding log file according to the physical address obtained by querying, and the header of each data block in each log file includes at least a compression parameter field;
[0166] According to the compression parameter field contained in the header of the data block to be read, the data block to be read is decompressed to obtain regular data corresponding to the data block to be read.
[0167] Corresponding to the above method embodiment, the embodiment of the present invention also provides a data processing device, such as Figure 4 As shown, the device includes:
[0168] Memory 410, used for storing computer programs;
[0169] The processor 420 is used to implement the steps of the above data processing method when executing a computer program.
[0170] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above data processing method are implemented.
[0171] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0172] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0173] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0174] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the technical solution and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, the present invention can also be improved and modified without departing from the principles of the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A data processing method, It is characterized in that include: When the trigger condition for writing the target data is met, the current business scenario is determined; Determining a target compression algorithm for the target data according to the business scenario; Using the target compression algorithm, compressing the target data to obtain the data to be written corresponding to the target data; The data to be written is written into the target log file; wherein: The target data is data written for the first time; and the target data is compressed using the target compression algorithm to obtain data to be written corresponding to the target data, including: According to the data volume of the target data, the i-th partitioning granularity in the partitioning granularity set is determined as the target partitioning granularity; the partitioning granularity set includes N partitioning granularities that decrease in sequence, and i and N are both positive integers; Dividing the target data into a plurality of target data blocks according to the target division granularity; Using a target compression algorithm, compressing each of the target data blocks respectively; If the compression rate of the compression process for each of the target data blocks is not higher than the preset second compression rate threshold, let i=i+1, return to the step of determining the i-th division granularity in the division granularity set as the target division granularity, until i=N or the compression rate of the compression process for each of the target data blocks is higher than the second compression rate threshold, and when the compression rate of the compression process for each of the target data blocks is higher than the preset second compression rate threshold, take the corresponding compressed data block as the data to be written; In the case of i=N, if the compression rate of the compression process performed on each of the target data blocks is still not higher than the preset second compression rate threshold, the target data block is directly used as the data to be written.
2. The method according to claim 1, It is characterized in that Also includes: When a data block to be read is to be read, querying the physical address of the data block to be read; Read the data block to be read in the corresponding log file according to the physical address obtained by querying, wherein the header of each data block in each log file at least includes a compression parameter field; According to the compression parameter field contained in the header of the data block to be read, the data block to be read is decompressed to obtain regular data corresponding to the data block to be read.
3. The method according to any one of claims 1 to 2, It is characterized in that When the trigger condition for writing the target data is reached, before determining the current business scenario, the method further includes: When the garbage collection triggering condition is met, the log files to be recycled are determined; Determine whether each valid data block in the log file to be recovered is cold data; The valid data blocks determined to be cold data are used as the target data.
4. The method according to claim 3, It is characterized in that After determining the log file to be recycled when the garbage collection triggering condition is met, the method further includes: Each of the valid data blocks determined as hot data in the log file to be recycled is written into a new log file.
5. The method according to claim 4, It is characterized in that When the garbage collection triggering condition is met, determining the log file to be recycled includes: When the garbage collection triggering condition is met, the log file whose ratio of the data amount of the invalid data block to the valid data block is greater than the set ratio threshold is determined as the log file to be recycled.
6. The method according to claim 5, It is characterized in that Also includes: When there is an update to the third data block in the target log file, writing the updated third data block into a new log file; The third data block in the target log file is marked as an invalid data block.
7. A data processing device, It is characterized in that include: A business scenario determination module, used to determine the current business scenario when the trigger condition for writing the target data is met; A compression algorithm determination module, used to determine a target compression algorithm for the target data according to the business scenario; A data acquisition module, used to compress the target data using the target compression algorithm to obtain the data to be written corresponding to the target data; The data writing module is used to write the data to be written into the target log file; wherein: The target data is the first written data, and the data acquisition module is specifically used for: According to the data volume of the target data, the i-th partitioning granularity in the partitioning granularity set is determined as the target partitioning granularity; the partitioning granularity set includes N partitioning granularities that decrease in sequence, and i and N are both positive integers; Dividing the target data into a plurality of target data blocks according to the target division granularity; Using a target compression algorithm, compressing each of the target data blocks respectively; If the compression rate of the compression process for each of the target data blocks is not higher than the preset second compression rate threshold, let i=i+1, return to the step of determining the i-th division granularity in the division granularity set as the target division granularity, until i=N or the compression rate of the compression process for each of the target data blocks is higher than the second compression rate threshold, and when the compression rate of the compression process for each of the target data blocks is higher than the preset second compression rate threshold, take the corresponding compressed data block as the data to be written; In the case of i=N, if the compression rate of the compression process performed on each of the target data blocks is still not higher than the preset second compression rate threshold, the target data block is directly used as the data to be written.
8. A data processing device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the data processing method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
A data compression method and apparatus
CN102291773A
Data processing method, data processing device and data processing system
CN102609360A
Data object processing method and device
CN105051724A
Storage data compression method and device for all-flash memory array and readable storage medium
CN108427538A
Method and device for compressing storage, method and apparatus for decompressing download
CN109325006A
