Method, device, and computer readable storage medium for computation

The method improves data similarity detection and redundancy elimination by scheduling threads based on data locality and frequency, using lock-free queues to enhance efficiency in data storage and transmission devices, addressing inefficiencies in existing technologies.

WO2024219988A1PCT designated stage expired Publication Date: 2024-10-24HUAWEI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/RU2023/000120
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-04-18
Publication Date
2024-10-24

AI Technical Summary

Technical Problem

Existing data storage and transmission devices face inefficiencies in data similarity detection and redundancy elimination, leading to suboptimal performance in deduplication and delta-compression processes due to lock contention and resource misallocation among threads.

Method used

A method involving a pipeline with multiple stages, where threads are scheduled based on data locality and frequency, using lock-free queues to enable parallel execution and efficient data transformation, similarity detection, and delta-compression, with CPU-bound and memory-bound computations handled separately to avoid lock contention.

Benefits of technology

This approach enhances the efficiency of data similarity detection and redundancy elimination by reducing lock contention and optimizing thread scheduling, leading to improved memory usage and processing speed through effective deduplication and delta-compression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure RU2023000120_24102024_PF_FP_ABST
    Figure RU2023000120_24102024_PF_FP_ABST
Patent Text Reader

Abstract

Example embodiments relate to methods, devices and a computer readable storage medium for computation. In an example method, a computation device creates a first queue for a first thread, wherein the first queue is a lock-free queue; determines, using the first thread, transformed data from input data and fingerprint from the transformed data or the input data; stores, using the first thread, the transformed data and the fingerprint into the first queue; reads, using a second thread from the first queue, the transformed data and the fingerprint; and delta-compresses, using the second thread, the transformed data based on the fingerprint. This way, CPU bound computation such as compression and fingerprint extraction, and memory bound computation such as similarity detection can be carried in different types of threads, and lock-free queue is used between the threads, so as to improve efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

METHOD, DEVICE, AND COMPUTER READABLE STORAGE MEDIUM FOR COMPUTATIONFIELD

[0001] Example embodiments of the present disclosure generally relate to the field of computation, and in particular, to a method, device and a computer readable storage medium for computation.BACKGROUND

[0002] Data similarity detection combined with data redundancy elimination are widely used in data storage, data transmission over network, plagiarism detection, web search, etc. Similarity detection combined with data redundancy elimination, when used in data storage or transmission devices, makes it possible to improve efficiency of these devices.SUMMARY

[0003] In general, example embodiments of the present disclosure provide a solution for data similarity detection combined with data redundancy elimination, done in parallel in a pipeline comprising several stages of data transformation.

[0004] In a first aspect, there is provided a method performed by a computation device. The method comprises:

[0005] creating a set of threads for each stage of the pipeline, where S >= 2 is the number of stages in the pipeline, s = [1 ...S] is index of a stage in the pipeline, T[s] is the number of threads in pipeline stage s; all the created threads are executed in parallel;

[0006] creating Q lock- free queues, where q = [1 ...Q] is index of a queue, and Q >= T[s] for any s = [1...S];

[0007] assigning each lock-free queue q to each thread, so that one thread at each stage can do push or pop (write or read) operation to one or more queues, while one queue at each stage can be pushed / popped (written / read) only by one thread;

[0008] taking input data by thread at stage 1, transforming it to produce transformed-data and pushing or writing the result to one of matched queues; the stage 1 transformations may include, but not limited to, input data compression, fingerprints calculation for compressed data as a whole or for parts of compressed data

[0009] popping (reading) transformed-datal by thread at any intermediate stage i = [2... S- 1] from one of matched queues, transforming it to produce transformed-data-i and pushing (writing) the result to one of matched queues; the stage i transformations may include, but not limited to, similarity detection of input data to any previously processed data

[0010] popping (reading) transformed-data-j, where j = S - 1 is the index of last but one stage of the pipeline, by thread at the last pipeline stage k = S, transforming the popped or read data and either storing the result on volatile or non-volatile media or transferring the result over network; the stage k transformations may include, but not limited to, deltacompression of transformed-data-j using a previously processed data as dictionary

[0011] In some embodiments of the present disclosure, threads doing computations with high data locality, fitting into LI (per core) CPU cache, are scheduled to cores with higher frequency (example of computations and threads but not limited to: threads at the stage 1, doing compression, hash or fingerprint calculation). Threads doing computations with average data locality, fitting into L2, L3 (per cluster) CPU cache, are scheduled to cores with average to higher frequency (example of threads and computations but not limited to: threads at the last stage of the pipeline, doing delta-compression). Threads doing computations with low data locality, not fitting into CPU cache, are scheduled to cores with lower frequency (example of threads and computations but not limited to: second threads doing similarity detection by comparing compressed input data with candidates for similarity among already processed data)

[0012] In some embodiments of the present disclosure, determining the transformed-data from input data comprises: compressing the input data into the transformed-data with one of a plurality of compression ratios (CRs), wherein the CRs, together with other fingerprints, are used for determining a similarity result. For example, non-compressible data will be compared for similarity with previously processed non-compressible data and never compared for similarity with previously processed data that was successfully compressed. This way, the similarity result can be determined more rapidly with CRs.

[0013] In some embodiments of the present disclosure, the method further comprises: determining, using the threads at some stage of the pipeline, the similarity result based on the fingerprints of the transformed-data from the first queue and fingerprints of stored transformed data.

[0014] In some embodiments of the present disclosure, determining the similarity result comprises: using the fingerprints of transformed-data from the first queue as a key to lookup at least one key-value store of the stored transformed-data. In a case that the look-up is not successful, the transformed-data will be determined as unique. In a case that the look-up is successful, determine the similarity result as duplicate or similar or unique, based on comparison between the transformed-data from the first queue and the stored transformed- data.

[0015] In some embodiments of the present disclosure, the method further comprises: determining a number of key-value stores based on range of CRs. Non-compressible data will go into key-value store for non-compressible data. Highly compressible data will go into key-value store for highly-compressible data. Data with average CR will go into keyvalue store for data with average CR, etc. This way, it is more efficient to determine the similarity result by looking-up the proper key -value stores for transformed-data.

[0016] In some embodiments of the present disclosure, determining the similarity result as duplicate or similar or unique comprises one or more items in the following. In a case that all bytes are the same at the same positions of the transformed-data from the first queue and the stored transformed-data, determine the similarity result as duplicate. In a case that the number of sub-strings or number of equal bytes in the transformed-data from the first queue and the stored transformed-data is above or equal to a threshold, determine the similarity result as similar. In a case that the number of sub-strings or number of equal bytes in the transformed- data from the first queue and the stored transformed-data is below a threshold, determine the similarity result as unique. This way, the similarity result can be determined efficiently.

[0017] In some embodiments of the present disclosure, delta-compressing the transformed- data comprises: delta-compressing the transformed-data based on the similarity result from the fingerprint comparisons. This way, delta-compression can be achieved efficiently.

[0018] In some embodiments of the present disclosure, delta-compressing the transformed- data based on the similarity result further comprises: in a case that the similarity result is duplicate, freeing a space occupied by the transformed-data from the first queue; creating a metadata entry for the stored transformed-data; and increasing a reference count of the stored transformed-data to reflect deduplication. This way, memory space can be saved, and efficiency of data reduction can be improved.

[0019] In some embodiments of the present disclosure, delta-compressing the transformed- data based on the similarity result further comprises: in a case that the similarity detection result is similar, delta-compressing the transformed-data from the first queue; freeing a space occupied by the transformed-data from the first queue; updating the metadata entry with result of delta-compression; and increasing the reference count of the stored transformed- data to reflect delta-compression. This way, memory space can be saved, and efficiency of data reduction can be improved.

[0020] In some embodiments of the present disclosure, delta compressing the transformed- data based on the similarity result further comprises: in case that the similarity detection result is unique, updating the at least one key-value store with fingerprints of the transformed-data from the first queue, based on the CR of the transformed-data from the first queue. This way, efficiency of data reduction can be improved.

[0021] In some embodiments of the present disclosure, a thread at some stage of the pipeline is a central processing unit (CPU) bound thread, and a thread at some other stage of the pipeline is a memory bound thread. This way, CPU bound computation such as compression can be put in a CPU bound thread, and memory bound computation such as similarity detection can be put in a memory bound thread, to improve the efficiency of the whole scheme.

[0022] In some embodiments of the present disclosure, the fingerprint comprises one or more of the following items: a hash value of the input data or the transformed-data; metadata of the transformed-data; or metadata entry for the transformed-data. This way, fingerprint can be obtained for determining similarity result and delta-compression, thus improve efficiency of the whole scheme.

[0023] In some embodiments of the present disclosure, the hash value and the metadata entry form a key-value. This way, it is convenient for looking-up the key-value stores.

[0024] In some embodiments of the present disclosure, the input data comprises at least one block or page in a random access memory (RAM) or a cache, and the transformed-data has size not bigger than at least one block or page in the RAM or the cache.

[0025] In some embodiments of the present disclosure, the method further comprises: creating a plurality of first queues according to plurality of threads at each stage of the pipeline, wherein the number of the plurality of first queues is the same with or larger than the number of the plurality of threads at any stage of the pipeline. One queue is assigned ormatched to one thread, so that one thread at each stage can do push or pop (write or read) operation to one or more queues, while one queue at each stage can be pushed or popped (written or read) only by one thread. This way, locking can be avoided in the queue, to improve efficiency of the whole scheme.

[0026] In some embodiments of the present disclosure, the method further comprises: in a case that the input data is compressed to the transformed-data, discarding the input data at the first thread. This way, memory space can be saved.

[0027] In a second aspect, there is provided a device. The device comprising: at least one processor; and a memory coupled to the at least one processor and storing programming instructions. The programming instructions are for: creating queues for threads in the pipeline to exchange data, wherein the created queues are a lock-free queues; producing, using the threads at the first stage of pipeline, transformed-data from input data and fingerprints from the transformed-data or the input data; storing, using the threads at the first stage of the pipeline, the transformed-data and the fingerprints into the first queue; reading, using a second thread from the assigned queue, the transformed-data and the fingerprints; deltacompressing, using the thread at some stage of the pipeline, the transformed-data based on the similarity detection result. This way, compression and similarity detection can be carried in different types of threads, and lock-free queue is used to pass data among the threads, to improve hardware (HW) efficiency.

[0028] In a third aspect, there is provided a computer-readable storage medium having instructions stored thereon that, when executed by one or more processors of a computing device, cause the computing device to perform at least the method in the first, second, third, fourth, and fifth aspects.

[0029] It is to be understood that the summary section is not intended to identify key or essential features of embodiments of the present disclosure, nor is it intended to be used to limit the scope of the present disclosure. Other features of the present disclosure will become easily comprehensible through the following description.BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Some example embodiments will now be described with reference to the accompanying drawings, in which:

[0031] FIG. 1 illustrates an example of a memory in which some example embodiments of the present disclosure may be implemented;

[0032] FIG. 2 illustrates an example of ZRAM pipeline with one queue in the present disclosure;

[0033] FIG. 3 illustrates an example of a process flow with the first thread and the second thread in which some example embodiments of the present disclosure may be implemented;

[0034] FIG. 4 illustrates an example of ZRAM pipeline with first thread and second thread with multiple queues in which some example embodiments of the present disclosure may be implemented;

[0035] FIG. 5 illustrates an example of a method process flow implemented at a computation device in accordance with some example embodiments of the present disclosure;

[0036] FIG. 6 illustrates a simplified block diagram of a computation device that is suitable for implementing some example embodiments of the present disclosure.

[0037] Throughout the drawings, the same or similar reference numerals represent the same or similar elements.DETAILED DESCRIPTION

[0038] Principle of the present disclosure will now be described with reference to some example embodiments. It is to be understood that these embodiments are described only for the purpose of illustration and help those skilled in the art to understand and implement the present disclosure, without suggesting any limitation as to the scope of the disclosure. The disclosure described herein can be implemented in various manners other than the ones described below.

[0039] In the following description and claims, unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skills in the art to which this disclosure belongs.

[0040] References in the present disclosure to “one embodiment”, “an embodiment” , “an example embodiment” , and the like indicate that the embodiment described may include a particular feature, structure, or characteristic, but it is not necessary that every embodiment includes the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, when a particular feature, structure,or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to affect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.

[0041] It shall be understood that although the terms “first” and “second” etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first element could be termed a second element, and similarly, a second element could be termed a first element, without departing from the scope of example embodiments. As used herein, the term “and / or” includes any and all combinations of one or more of the listed terms.

[0042] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments. As used herein, the singular forms “a”, “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “comprises”, “comprising”, “has”, “having”, “includes” and / or “including”, when used herein, specify the presence of stated features, elements, and / or components etc., but do not preclude the presence or addition of one or more other features, elements, components and / or combinations thereof.

[0043] Data similarity (resemblance) detection is widely used in data storage, data transmission over network, plagiarism detection, web search, etc. Similarity detection, when used in data storage and transmission devices, makes it possible to apply deduplication or delta-compression for similar data, thus further improve efficiency of these devices.

[0044] FIG. 1 illustrates an example of a memory in which some example embodiments of the present disclosure may be implemented.

[0045] In memory 100, a first data block 130 in random access memory (RAM) 110 can be compressed into a second data block 140 in zipped or compressed RAM (ZRAM) 120, to save memory space in RAM, for the use case such as SWAP in Linux or Android. The skilled in the art can understand that beside RAM, the data compression can also be used in cache, flash, hard disk, or communication devices, or in other use cases.

[0046] In some embodiments, to detect similarity so called chunking is used to divide data in chunks (blocks) of fixed or variable size. When chunking is defined by data content, it is called Content Defined Chunking (CDC). After chunking blocks are tested for similarity by comparing their fingerprints, where fingerprint is usually a number, e.g. hash, calculated forcontent of whole data block or for its part. The latter is also done by CDC. By definition of CDC data blocks with same fingerprints may have similar content. The more fingerprints of two data blocks are the same the bigger is chance that contents of these blocks are similar.

[0047] Popular approaches to match processed data blocks and incoming data blocks are to use key -value stores (hash-tables), bloom filters, or sorting. For example, let fingerprint and respective block, or block ID, or block metadata, form key-value pair. Then the key-value store is used to store the key-value pairs of processed blocks and to find blocks with the same keys, as those calculated for incoming data blocks.

[0048] In some embodiments, if for incoming data block, a similar data block is found, the similar data block can be used as a dictionary to delta-compress the incoming data block. In this way, only small part of incoming data, so-called delta or difference, need to be compressed and placed in data storage or transmitted over network. When previously processed data block and incoming data block are fully equal the delta or difference will be zero. In this case data deduplication, rather than delta-compression, can be applied to incoming data block.

[0049] Hashing effectively serves for deduplication of fully equal data blocks after data blocks are compressed. For example, in data storage devices, incoming data block is compressed first, then hash value is calculated for the compressed data. This hash value is used as key to look-up in hash table, where the hash table contains key- value pairs for already processed and compressed data blocks.

[0050] In some embodiments, a ZRAM module 120 exists in Linux or Android or Harmony Operating System (OS) kernel. The OS kernel creates RAM based block devices. Kernel pages written to these disks are compressed and stored in memory (RAM) 110 itself. ZRAM 120 supports multiple compression streams and multiple compression algorithms.

[0051] FIG. 2 illustrates an example of ZRAM pipeline with one queue in the present disclosure.

[0052] In some embodiments, in the threads deployment 200, ZRAM can allocate multiple operation system (OS) threads, such as thread 1-1 (210), thread 1-2 (220), , thread 1- (N-l) (230), thread 1-N (240), such as compression threads or compression streams. There can be one thread per online CPU. Thus ZRAM allows several concurrent compression operations. The number of allocated compression threads goes down when some of the CPUsbecome offline. There is no single-compression-stream mode anymore, unless ZAM is running a UP system or has only 1 CPU online.

[0053] ZRAM also creates one thread such as a worker thread 260 to process compressed pages further. ZRAM compression threads 210, 220, , 230, 240 and worker thread 260 are combined in ZRAM pipeline, comprising two stages as follows.

[0054] At the first stage, ZRAM compression threads 210, 220, , 230, 240 in parallel call ZRAM API to compress and deduplicate written 4KB pages. If no duplicate is found then results of compression are in parallel placed into a so called zram_table entry and index of the zram_table entry is returned as result. Before return, results of compression are placed into a single queue 250 to process these pages at the second stage of the ZRAM pipeline.

[0055] The second stage of the ZRAM pipeline in this embodiment comprises one or more worker threads 260. Worker threads wait or sleep until the respective queues 250 are filled up by ZRAM compression threads (210, 220, 230, 240) of the first stage. Each worker thread 260 checks similarity of each page in the queue 250 to already written pages. If similarity is found, then the worker thread 260 delta-compresses similar page, and stores result of deltacompression modifying content of respective zram_table entry. If no similarity is found then respective zram_table entry is left unmodified.

[0056] ZRAM API functions use kernel page locking and page mapping while checking for page duplicates and for page similarity. Page locking guarantees only one thread uses or maps data of already written page, such as to compare incoming compressed page byte-by-byte with already written page. Lock contention may happen if the same already written page is accessed for duplicate check in different ZRAM compression threads (210, 220, 230, 240) or for similarity check in the worker thread 260.

[0057] In some embodiments, with the pipeline in FIG. 2, page compression combined with deduplication in one ZRAM compression thread decreases efficiency of dedicated CPU core LI cache, since compressor code and data would compete for LI cache with deduplicated code and data. Several ZRAM compression threads (210, 220, 230, 240) compete for lock to put results of compression into the single queue 250, impacting latency and throughput of ZRAM. Using the single queue 250 for pipeline processing with the worker thread 260 waiting for full queue decreases ZRAM block device efficiency, since the block device stores compressed and non-compressible pages as intermediate result until the worker thread 260 wakes up and processes respective pages in queue for similarity and delta-compression. Pagelock-to-map at the first and at the second stages of ZRAM pipeline may result in lock contention when the same already written page is checked for duplicate on the first stage and for similarity on the second stage. Lock contention decreases overall ZRAM performance.

[0058] In order to solve at least the technique problem, methods, devices and a computer readable storage medium for computation are proposed. In some embodiments, there is provided a method performed by a computation device. The method comprises: creating a first queue for a first thread, wherein the first queue is a lock-free queue; producing, using the first thread, transformed-data from input data and fingerprints from the transformed-data or the input data; storing, using the first thread, the transformed-data and the fingerprints into the first queue; reading, using a second thread from the first queue, the transformed-data and the fingerprints; and delta-compressing, using the second thread, the transformed-data based on the results of similarity detection. This way, CPU bound computation such as similarity detection and fingerprint extraction and memory bound computation such as deltacompression can be carried in different types of threads, and lock-free queue is used between the threads, to improve efficiency.

[0059] Some embodiments propose to schedule concurrent threads doing CPU bound computations and threads doing memory bound computations to different cores of Heterogeneous Multi-Processing (HMP) system, such as ARM. The HMP system comprises big and LITTLE cores, alternatively MEDIUM cores may be present. The threads doing CPU bound computations such as compression and hash calculation can be referred as first threads, or compression threads. The threads doing memory bound computation such as similarity detection and delta-compression can be referred as second threads, or similarity threads. Some embodiments schedule the CPU bound threads on HMP cores with higher frequencies and / or higher instructions-per-sec (IPC) to have faster execution. On the other hand, the embodiments schedule memory bound threads for similarity detection and delta-compression on other HMP cores with lower frequencies or lower IPC, which are different from CPU cores scheduled for the above CPU bound threads. In some embodiments, memory bound threads for similarity detection use more data for computations than LI cache and other caches are able to hold, so these threads anyway would not efficiently use LI cache and other caches. This way, CPU bound computation such as compression and hash calculation and memory bound computation such as similarity detection and delta-compression can be schedule in different threads, and in different cores, to improve the efficiency of the whole scheme.

[0060] Some embodiments use lock-free queues, with the same number of queues as number of CPU bound compression threads, to share data among concurrently running compression threads and similarity threads. Each compression thread pushes or writes result of compression in its own lock-free queue without any competition with other threads for queue writing, and therefore, without using locks. In turn, similarity threads, running in parallel with other threads pop or read result of compression from lock-free queues also without using locks. The similarity threads do not wait for lock-free queues to be full. The similarity threads do not wait for the queues to be full when they pop or read compression result from the queues. When a queue is empty, the similarity thread goes to wait or sleep until a compression thread fills the queue with some data and then the compression thread wake the similarity thread to continue processing. Number of similarity threads is less or equal than number of lock- free queues, and less or equal than number of compression threads. To balance queues reading, the similarity threads can select queues in interleaved order. An example of interleaved order is as follows. Some embodiments have configuration of 8 compression threads, 8 lock-free queues, one queue per one compression thread, and 2 similarity threads. Then first similarity thread pops or reads, and processes data from the first, third, fifth, and seventh queues, preferring queue with bigger number of slots available. The second similarity thread pops or reads, and processes data from the second, fourth, sixth, and eighth lock-free queues, preferring queue with bigger number of slots available. If there is single similarity thread then it pops or reads result of compression from any and all of lock free queues, preferring a queue with bigger number of slots available. This way, the compression thread and similarity thread can run without lock contention, to improve efficiency of the whole scheme. The skilled in the art can understand that the number of first threads can be less than the number of queues, which can also leads to lock free, thus improve efficiency of the whole scheme.

[0061] Some embodiments of the present disclosure propose to combine similarity detection and deduplication into single procedure and then combine this procedure with deltacompression into single similarity thread. One or more similarity threads run concurrently with the compression threads. As result, with small number of similarity threads, such as only one similarity thread, the embodiments effectively decreases or eliminates lock contention for page mapping in OS kernel while using lock-to-map in several cases. In one case, the same already stored page or block is checked for similarity with side-effect duplication, versus input page or block from the queue. In another case, the same already stored page orblock is used as dictionary in the course of delta-compression of input block or page from the queue. This way, the memory bound computation such as similarity detection, deduplication and delta-compression can be combined into similarity thread, which is different from the CPU bound computation in the compression thread, to improve efficiency of the whole scheme.

[0062] FIG. 3 illustrates an example of a process flow 300 with the first thread and the second thread in which some example embodiments of the present disclosure may be implemented. Stage 1 is for initialization; stage 2 is processing with the first thread, or the compression thread; and stage 3 is processing with the second thread, or the similarity thread.

[0063] In the process flow 300, when a block device such as ZRAM 120 is created, the block device takes stage 1, or initialization. At 310, the block device creates one queue per each compression thread per CPU core, so that each kernel page or block written to the block device will be compressed by respective compression thread, and result of compression will be placed into dedicated ZRAM queue in lock-free maimer. The compression thread can be the first thread.

[0064] At 315, the block device creates one or more second threads, or similarity threads that will lock-freely pop or read results of compression from any or all queues. Each similarity thread will do similarity detection, with side-effect deduplication, and deltacompression for non-duplicate but similar compressed pages or blocks. This way, memory bound computation can be put into the similarity thread, which is different from the compression thread carrying CPU bound computation. The efficiency can be improved for the whole pipeline.

[0065] At 320, the block device creates one or more key-value stores or hash tables for similarity detection between incoming blocks or pages from the queue and already stored blocks or pages. Since result of compression may be either compressed or non-compressible page, the block device may have several key -value stores as in following example. 1) Key-value store for highly compressed pages if their compression ratio (CR) is above a threshold, such as CR >= 4. 2)Key-value store for averagely compressed pages, such as with CR > 1. 3) Key-value store with non-compressible pages with CR = 1. In this way, similarity detection and deduplication may be more efficient since input page or block from the queue is checked with known CR versus already stored pages with CRs in certain range, rather than checking input page versus any and all already stored pages or blocks. This way,the computation can be saved, to improve the efficiency of the similarity detection and deduplication.

[0066] In some embodiments, the number of key-value stores and their properties, such as range of CRs, that is assigned as property of key-value store or hash-table, are determined and changed by collecting statistics for input pages or blocks, either using test data or in runtime operation. So the key value stores and CRs can match the statistic property of the input pages or blocks, to improve efficiency of the whole scheme. The embodiments make combination of similarity detection and deduplication into one procedure more efficiently as compared to the approach having single key-value store or hash table for all pages.

[0067] In some embodiments, in stage 2, as effect of any write operation to block device, at 325, the first thread or compression thread gets or receives input block or page, and compresses the input block or page. In some embodiments, the input block or page may be non-compressible.

[0068] At 330, the compression thread allocates metadata table or zram_table entry, stores compression result in block device, and fills metadata with offset on block device. The compression result or non-compressible block or page can be transformed-data. The transformed-data can be put into the queue. The compression thread can also put the address of the transformed-data into the queue, to save data copy in the memory. The metadata table can contain information about each page, used by OS kernel and applications, such as page is used or unused, written ( “dirty” ), is it plain 4KB, compressed, duplicate, pattern, etc. If and when page is placed in ZRAM, metadata contains its address in ZRAM.

[0069] At 335, the compression thread extracts fingerprints of the input block or page, such as calculates hashes, either for original uncompressed, or for compressed block or page. These fingerprints or hashes will be used later in the second thread, or the similarity thread to detect similarity between input block or page such as from the queue, and already stored blocks or pages. The input block or page from the queue can be transformed-data from the queue, and the already stored blocks or pages can be stored transformed-data. The hash value, the metadata and the metadata entry can be fingerprint.

[0070] At 340, the compression thread pushes or writes the metadata entry index or pointer and fingerprints or hashes of the input block or page into dedicated lock-free queue. The data in the queue may be placed either by value or by pointer to value.

[0071] At 345, the compression thread returns index or pointer of the metadata or zram_table entry as result of compression to caller so that at 350, source page or block can be immediately discarded and re-used. Since that moment the result of compression can be used instead of the source page or block. So the memory space can be saved.

[0072] This way, the compression and fingerprint extraction can be achieved in the first thread. The first thread can be CPU bound thread, and run in the core with high frequency or high IPC, thus improve the efficiency of compression.

[0073] In stage 3, the second thread, or the similarity thread runs in parallel with the first thread in stage 2. At 355, the second thread pops or reads lock-free compression result of compression and respective fingerprints of input block or page from one of the queues. The second thread can also reads non-compressible data from the queue.

[0074] At 360, using the read fingerprints, the second thread checks respective compressed or non-compressible input page or block from the queue for similarity with side-effect deduplication, to one of pages or blocks stored in block device via the key-value stores or hash tables. The key -value stores or hash tables are created in stage 1. The fingerprints or hashes can be used as keys to look-up these key-value stores, to improve the efficiency of looking-up the key-value stores. The compressed or non-compressible input page or block from the queue can be the transformed-data.

[0075] In some embodiments, if the look-up is not successful, or no value returned after look-up, then input block or page from the queue is considered as unique and it cannot be deduplicated or delta-compressed versus stored page or block. The stored page or block can be stored transformed-data.

[0076] In some embodiments, if the look-up is successful then value returned after the lookup would be pointer or offset of metadata entry with already stored page or block, with the same fingerprint such as hash. In this case similarity check can be done between input page or block from the queue and already stored page or block. For example, the similarity check can be comparing sub-strings of bytes with pages or blocks from the queue and already stored.

[0077] If all bytes at the same positions of the input and stored pages or blocks are equal, then these pages or blocks are 100% similar or duplicates. If number of equal substrings, or number of equal bytes in input and stored pages or blocks is above threshold, then these pages or blocks are considered plain similar, or less than 100%. If number of equal substrings, or number of equal bytes in input and stored pages or blocks is below threshold then input pageor block is considered unique. This way, the second thread can improve the efficiency in similarity detection and the following delta-compression.

[0078] At 365, the second thread checks whether the input block or page from the queue is similar with the already stored blocks or pages. The already stored blocks or pages can be called referenced page. If the result of 365 is “YES”, goes to 370. At 370, the second thread checks whether the input block or page from the queue is duplicated to already stored blocks or pages.

[0079] If the result of 370 is “YES”, for 100% similarity or duplicate, at 385, the second thread updates corresponding metadata or zram_table entry, frees space occupied by compressed or non-compressible data of the page. The second thread also makes the entry to point to the referenced page, and increments ref-count of the reference page to reflect the fact of deduplication. Then the second thread goes back to 355. This way, memory space can be saved in the case of duplicate.

[0080] If the result of 370 is “NO”, at 375, the second thread delta-compresses the input page or block of the second thread. The second thread modifies corresponding metadata or zram_table entry, frees space occupied by compressed or non-compressible data of the page. The second thread also updates the entry with result of delta-compression, increments ref- count of the reference page to reflect the fact of delta-compression. This way, memory space can be saved in the case of similar.

[0081] If the result of 365 is “NO”, such as if the respective input page or block read from queue is unique, or not similar to any of stored pages, at 380, the second thread updates the key-value stores or hash-tables created in the stage 1, with the extracted fingerprints of input page or block for future similarity detection. To update the key-value stores, the second thread combines each fingerprint as key and pointer or index of corresponding metadata as value. The second thread uses this <key, value> pair to update the key-value stores or hashtables according to CR of the input page or block from the queue. That is, if CR =1 for the input page or block, then the second thread updates the key-value store or hash table containing non-compressible pages or blocks. If CR of the input page or block from the queue is high, then the second thread updates the key-value store or hash table containing highly compressible pages or blocks. This way, more data can be provided for the future similarity detection and delta-compression.

[0082] In some embodiments, the third stage can be divided into several stages, or several threads, such as a third thread for similarity detection, kv stores updating in 355, 360, 365, 380, and the second thread for delta-compression and metadata entry updating in 370, 375, and 385. There are also other lock-free queues between the second thread and the third thread. The skilled in the art can understand that the while pipeline can also be divided into more threads.

[0083] FIG. 4 illustrates an example of ZRAM pipeline with first thread and second thread with multiple queues in which some example embodiments of the present disclosure may be implemented.

[0084] In the pipeline 400, there are N OS threads: thread 2-1 (410), thread 2-2 (415), , thread 2-(N-l) (420), and thread 2-N (425). There areN queues according to the N OS threads: queue 1 (430), queue 2 (435), queue N-l (440), queue N (445). The OS threads put input data into the queues without lock contention. There are 2 first threads, or compression threads, first thread 1 (450) and first thread 2 (455). The first threads read input data from the queues alternatively. For example, the first thread 1 (450) reads input data from queue 1 (430), , queue N-l (440), compresses into compressed data, then puts the compressed data into the queue 1 (430), , queue N-l (440). If the input data cannot be compressed, the input data can be kept unchanged in the queue. The compressed data or non-compressible data can be transformed-data. The first thread 1 (450) can calculate CRs for the input data. The first thread 1 (450) also create fingerprint such as hash value, metadata and metadata entry for the input data or compressed data. The first thread 1 (450) can also create key-value based on the hash and metadata, then update key-value stores according to the CR. The first thread 1 (450) can write the fingerprint into queue 1 (430), , queue N-l (440). The functionality of first thread 2 (455) is the same with the first thread 1 (450), while reads input data from queue 2 (435), > , queue N (445) and write back. The second thread (460) or similarity thread extracts fingerprint from queue 1 (430), queue 2 (435), , queue N-l (440), queue N (445), looks-up the key-value stores and determines similarity result as unique, similar or duplicate. Then the second thread (460) makes delta-compression based on the similarity result. CPU bound computation such as compression and fingerprints calculation can be put into the first thread, and carried by cores with high frequency or high IPC. Memory bound computation such as similarity detection and delta-compression can be put into the second thread, and carried by core with low frequency or low IPC. This way, the efficiency of the whole ZRAM scheme can be improved.

[0085] In some embodiments, the second thread 460 can also be divided into several threads, such as the third thread for similarity detection, and the second thread for delta-compression. The first thread can be with high data locality, fitting into LI (per core) CPU cache, and be scheduled to a core with higher frequency. The third thread can be with low data locality, not fitting into CPU cache, and be scheduled to a core with lower frequency. The second thread can be with average data locality, fitting into L2, L3 (per cluster) CPU cache, and be scheduled to a core with average to higher frequency.

[0086] Queue 1 (430), queue 2 (435), , queue N-l (440), and queue N (445) can be the buffers between the second thread and the third thread. There can also be other lock-free queues between the second thread and the third thread. The skilled in the art can understand that the while pipeline can also be divided into more threads.

[0087] FIG. 5 illustrates an example of a method process flow implemented at a computation device in accordance with some example embodiments of the present disclosure.

[0088] In the method process flow 500, at 510, the computation device creates a first queue for a first thread, wherein the first queue is a lock-free queue.

[0089] At 520, the computation device determines, using the first thread, transformed-data from input data and fingerprint from the transformed-data or the input data.

[0090] At 530, the computation device stores, using the first thread, the transformed-data and the fingerprints into the first queue.

[0091] At 540, the computation device reads, using a second thread from the first queue, the transformed-data and the fingerprints.

[0092] At 550, the computation device delta-compresses, using the second thread, the transformed-data based on the similarity detection result.

[0093] In some embodiments, a frequency of a core carrying the first thread is greater than a frequency of a core carrying the second thread, or an instruction per cycle (IPC) of the core carrying the first thread is greater than a IPC of the core carrying the second thread.

[0094] In some embodiments, determining the transformed-data from input data comprises: compressing the input data into the transformed-data with one of a plurality of compression ratios (CRs), wherein the CRs are used for determining a similarity result.

[0095] In some embodiments, the computation device further determines, using the second thread, the similarity result based on the fingerprints of the transformed-data from the first queue and fingerprints of stored transformed-data.

[0096] In some embodiments, determining the similarity result comprises: using the fingerprint of transformed-data from the first queue as a key to look-up at least one key -value store of the stored transformed-data. In a case that the look-up is not successful, the computation device determines the similarity result as unique; and in a case that the look-up is successful, determines the similarity result as duplicate or similar or unique, based on comparison between the transformed-data from the first queue and the stored transformed- data.

[0097] In some embodiments, the computation device further determines a number of keyvalue stores based on range of CRs. In some embodiments, determining the similarity result as duplicate or similar or unique comprises one or more of the following items. In a case that all bytes are the same at the same positions of the transformed-data from the first queue and the stored transformed-data, the computation device determines the similarity result as duplicate. In a case that the number of sub-strings or number of equal bytes in the transformed-data from the first queue and the stored transformed-data is above or equal to a threshold, the computation device determines the similarity result as similar. In a case that the number of sub-strings or number of equal bytes in the transformed-data- 1 from the first queue and the stored transformed-data is below a threshold, the computation device determines the similarity result as unique.

[0098] In some embodiments, delta-compressing the transformed-data comprises: deltacompressing the transformed-data based on the similarity detection result.

[0099] In some embodiments, delta-compressing the transformed-data based on the similarity detection result further comprises: in a case that the similarity result is duplicate, freeing a space occupied by the transformed-data from the first queue; creating a metadata entry for the stored transformed-data; and increasing a reference count of the stored transformed-data to reflect deduplication.

[0100] In some embodiments, delta-compressing the transformed-data based on the similarity detection result further comprises: in a case that the similarity result is similar, delta-compressing the transformed-data from the first queue; freeing a space occupied by the transformed-data from the first queue; updating the metadata entry with result of delta-compression; and increasing the reference count of the stored transformed-data to reflect delta-compression.

[0101] In some embodiments, delta compressing the transformed-data based on the similarity detection result further comprises: in case that the similarity result is unique, updating the at least one key-value store with fingerprint from the transformed-data from the first queue, based on the CR of the transformed-data from the first queue.

[0102] In some embodiments, the first thread is a central processing unit (CPU) bound thread. Additionally or alternatively, the second thread is a memory bound thread.

[0103] In some embodiments, the fingerprint comprises one or more in the following items: a hash value of the input data or the transformed-data; metadata of the transformed-data; or metadata entry of the metadata.

[0104] In some embodiments, the hash value and the metadata entry form a key- value. In some embodiments, the input data comprises at least one block or page in a random access memory (RAM) or a cache. Additionally or alternatively, the transformed-data comprises not more than at least one block or page in the RAM or the cache.

[0105] In some embodiments, the computation device further creates a plurality of first queues according to plurality of first threads. The number of the plurality of first queues is the same with or larger than the number of the plurality of first threads, and a number of plurality of second threads is less or equal than the number of the plurality of first queues.

[0106] In some embodiments, in a case that the input data is compressed to the transformed- data, the computation device further discards the first data at the first thread.

[0107] In some embodiments, the computation device further determines, using the third thread, the similarity result based on the fingerprint of the transformed data from the first queue and fingerprint of stored transformed data.

[0108] In some embodiments, the computation device further stores, using the third thread, the similarity result into a second queue; and reads, using the second thread from the second queue, the similarity result.

[0109] In some embodiments, the first thread is with at least one of: high data locality, fitting into LI CPU cache, or scheduled to a core with high frequency. Additionally, or alternatively, the third thread is with at least one of: low data locality, not fitting into CPU cache, or scheduled to a core with low frequency. Additionally, or alternatively, the secondthread is with at least one of: average data locality, fitting into L2, L3 CPU cache, or scheduled to a core with average to high frequency.

[0110] FIG. 6 illustrates a simplified block diagram of a computation device 600 that is suitable for implementing some example embodiments of the present disclosure. As shown in FIG. 6, the computation device 600 includes one or more processors 610, and one or more memories 620. The processor 610 may be of any type suitable to the local technical network and may include one or more of the following: general purpose computers, special purpose computers, microprocessors, digital signal processors (DSPs) and processors based on multicore processor architecture, as non-limiting examples. The computation device 600 may have multiple processors, such as an application specific integrated circuit chip that is slaved in time to a clock which synchronizes the main processor.

[0001] The memory 620 may include one or more non-volatile memories and one or more volatile memories. Examples of the non-volatile memories include, but are not limited to, a Read Only Memory (ROM), an electrically programmable read only memory (EPROM), a flash memory, a hard disk, a compact disc (CD), a digital video disk (DVD), and other magnetic storage and / or optical storage. Examples of the volatile memories include, but are not limited to, a random access memory (RAM) and other volatile memories that will not last in the power-down duration.

[0002] The processor 610 is configured to invoke the computer program from the memory 620 and run the computer program, so that the computation device 600 is enabled to perform a corresponding procedure and / or operation in various embodiments of the computation methods in this application.

[0111] A person of ordinary skill in the art may be aware that, in combination with units and algorithm steps of the examples described in the embodiments disclosed in this specification, this application may be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.

[0112] It may be clearly understood by a person skilled in the art that, for convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit,refer to a corresponding process in the foregoing method embodiments, and details are not described herein again.

[0113] In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented by using some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.

[0114] The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve the objectives of the solutions of the embodiments.

[0115] In addition, functional units in the embodiments of this application may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.

[0116] When the functions are implemented in the form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

[0117] The foregoing descriptions are merely specific implementations of this application, but are not intended to limit the protection scope of this application. Any variation orreplacement readily figured out by a person skilled in the art within the technical scope disclosed in this application shall fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.

Claims

WHAT IS CLAIMED IS:

1. A method for computation, comprising: creating a first queue for a first thread, wherein the first queue is a lock-free queue; determining, using the first thread, transformed data from input data and fingerprint from the transformed data or the input data; storing, using the first thread, the transformed data and the fingerprint into the first queue; reading, using a second thread from the first queue, the transformed data and the fingerprint; and delta-compressing, using the second thread, the transformed data based on the fingerprint.

2. The method of claim 1 , wherein at least one of: a frequency of a core carrying the first thread is greater than a frequency of a core carrying the second thread, or an instruction per cycle (IPC) of the core carrying the first thread is greater than a IPC of the core carrying the second thread.

3. The method of any one of claims 1-2, wherein determining the transformed data from input data comprises: compressing the input data into the transformed data with one of a plurality of compression ratios (CRs), wherein the CRs are used for determining a similarity result.

4. The method of any one of claims 3, further comprising: determining, using the second thread, the similarity result based on the fingerprint of the transformed data from the first queue and fingerprint of stored transformed data.

5. The method of any claims 4, wherein determining the similarity result comprises: using the fingerprint of transformed data from the first queue as a key to look-up at least one key-value store of the stored transformed data; in a case that the look-up is not successful, determining the similarity result as unique; andin a case that the look-up is successful, determining the similarity result as duplicate or similar or unique, based on comparison between the transformed data from the first queue and the stored transformed data.

6. The method of claim 5, further comprising: determining a number of key -value stores based on range of CRs.

7. The method of claim 5, wherein determining the similarity result as duplicate or similar or unique comprises at least one of: in a case that all bytes are the same at the same positions of the transformed data from the first queue and the stored transformed data, determining the similarity result as duplicate; in a case that the number of sub-strings or number of equal bytes in the transformed data from the first queue and the stored transformed data is above or equal to a threshold, determining the similarity result as similar; or in a case that the number of sub-strings or number of equal bytes in the transformed data from the first queue and the stored transformed data is below a threshold, determining the similarity result as unique.

8. The method of any one of claims 1-7, wherein delta-compressing the transformed data based on the fingerprint comprises: delta-compressing the transformed data based on the similarity result from the fingerprint.

9. The method of claim 8, wherein delta-compressing the transformed data based on the similarity result further comprises: in a case that the similarity result is duplicate, freeing a space occupied by the transformed data from the first queue; creating a metadata entry for the stored transformed data; and increasing a reference count of the stored transformed data to reflect deduplication.

10. The method of claim 8, wherein delta-compressing the transformed data based on the similarity result further comprises:in a case that the similarity result is similar, delta-compressing the transformed data from the first queue; freeing a space occupied by the transformed data from the first queue; updating the metadata entry with result of delta-compression; and increasing the reference count of the stored transformed data to reflect deltacompression.

11. The method of claim 8, wherein delta compressing the transformed data based on the similarity result further comprises: in case that the similarity result is unique, updating the at least one key-value store with fingerprint from the transformed data from the first queue, based on the CR of the transformed data from the first queue.

12. The method of any one of claims 1-11, wherein at least one of: the first thread is a central processing unit (CPU) bound thread, or the second thread is a memory bound thread.

13. The method of any one of claims 1-12, wherein the fingerprint comprises at least one of: a hash value of the input data or the transformed data; metadata of the transformed data; or metadata entry of the metadata.

14. The method of claim 13, wherein the hash value and the metadata entry form a key- value.

15. The method of any one of claims 1-14, wherein at least one of: the input data comprises at least one block or page in a random access memory (RAM) or a cache, or the transformed data comprises at least one block or page in the RAM or the cache.

16. The method of any one of claims 1-15, further comprising: creating a plurality of first queues according to plurality of first threads,wherein the number of the plurality of first queues is the same with or larger than the number of the plurality of first threads, and a number of plurality of second threads is less or equal than the number of the plurality of first queues.

17. The method of any one of claims 1-5, further comprising: in a case that the input data is compressed to the transformed date, discarding the first data at the first thread.

18. The method of any one of claims 1-3, further comprising: determining, using the third thread, the similarity result based on the fingerprint of the transformed data from the first queue and fingerprint of stored transformed data.

19. The method of claim 18, further comprising: storing, using the third thread, the similarity result into a second queue; and reading, using the second thread from the second queue, the similarity result.

20. The method of claim 18 or 19, wherein at least one of: the first thread is with at least one of: high data locality, fitting into LI CPU cache, or scheduled to a core with high frequency, the third thread is with at least one of: low data locality, not fitting into CPU cache, or scheduled to a core with low frequency, or the second thread is with at least one of: average data locality, fitting into L2, L3 CPU cache, or scheduled to a core with average to high frequency.

21. A device comprising: at least one processor; and a memory coupled to the at least one processor and storing programming instructions for: creating a first queue for a first thread, wherein the first queue is a lock-free queue; determining, using the first thread, transformed data from input data and fingerprint from the transformed data or the input data;storing, using the first thread, the transformed data and the fingerprint into the first queue; reading, using a second thread from the first queue, the transformed data and the fingerprint; and delta-compressing, using the second thread, the transformed data based on the fingerprint.

22. A computer-readable storage medium having instructions stored thereon that, when executed by one or more processors of a computing device, cause the computing device to perform the method of any of claims 1-20.

Citation Information

Patent Citations

  • Method and system of similarity-based deduplication

    EP3539218A1

  • Facilitating communication within shared memory environments using lock-free queues

    US20050283577A1