NVM external sorting method, device and NVM memory

By dividing the big data files into small files in the database system, and using NVM's read and write performance and loser tree algorithm to merge data, the problem of excessive I/O load in traditional external sorting methods is solved, and the problem of excessive I/O load in traditional external sorting methods is improved The algorithm efficiency and extends the service life of external memory devices.

CN114816258BActive Publication Date: 2024-11-22NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210467757.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2024-11-22
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

In database systems, frequent data updates lead to out-of-order data. Traditional external sorting methods require frequent I/O operations, affecting algorithm performance and shortening the service life of external memory devices.

Method used

By dividing big data files into small files, using NVM's read and write performance, using ordered interval retrieval and loser tree to merge data, reducing the number of write operations, designing an external sorting method based on NVM, and using index table optimization Data merging process.

Benefits of technology

It effectively reduces the number of write operations to external memory, improves the execution efficiency of external sorting, extends the service life of external memory devices, and makes full use of the storage characteristics of NVM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816258B_ABST
    Figure CN114816258B_ABST
Patent Text Reader

Abstract

The present application relates to an external sorting method, device and computer storage medium of NVM. The method includes: obtaining the ordered interval of the small file in the input cache read into the memory, and sorting the unordered data in the input cache to obtain the first ordered intermediate result, and writing the first ordered intermediate result back to the NVM; the small file is obtained by segmenting the large data file; obtaining the position information of the ordered interval on the NVM, establishing an index table according to the position information, and storing the index table in the memory; when merging data, merging data according to the loser tree, the index table and the first ordered intermediate result. The use of this method can solve the I / O load problem of traditional external merge sorting and extend the service life of external memory devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of novel non-volatile storage technology, and in particular to an NVM external sorting method, device and NVM memory. Background Art

[0002] The rise and development of new non-volatile storage technologies. New non-volatile memories have read and write performance close to that of dynamic random access memory (DRAM), while providing high-density, large-capacity data storage. They are also non-volatile like mechanical hard disks (HDD) and solid-state drives (SSD), and can store data persistently. With the explosive growth of data volume, the demand for new non-volatile storage in high-performance computing and database management systems has increased dramatically. In database systems, a common scenario is that originally ordered data becomes disordered due to local updates of data. If all data is re-sorted after each local update, the overhead is relatively large. Especially in the case of large-scale data volume, the internal memory and external memory will frequently exchange data during the external sorting process, generating a large number of I / O operations, affecting the algorithm performance and the service life of the external memory device. NVM (Non-Volatile memory) has a read and write speed close to that of DRAM, and can persist data like HDD and SSD. Optane DC PMM is a real NVM product launched by Intel. Optane DC PMM is a byte-addressable non-volatile memory. We can make full use of the performance advantages of Optane DC PMM to design and optimize external sorting algorithms. With the development and rise of new non-volatile memories, research on external sorting methods based on NVM has also become a hot topic.

[0003] At present, NVM has powerful functions, but it also has the following two problems. First, the overhead of write operation is greater than that of read operation, and it can be accessed randomly, so in the algorithm design process, additional read operations can be added to reduce write operations; second, the service life is limited, and frequent write operations will affect the service life of NVM. Summary of the invention

[0004] Based on this, it is necessary to provide a method, device and NVM memory for external sorting of NVM that can solve the problem of large I / O load of external sorting in order to solve the above technical problems.

[0005] A method for external sorting of NVM, the method comprising:

[0006] Obtaining an ordered interval of a small file in an input cache read into the memory, and sorting the unordered data in the input cache to obtain a first ordered intermediate result, and writing the first ordered intermediate result back to the NVM; the small file is obtained by segmenting the large data file;

[0007] Acquire location information of the ordered interval on the NVM, establish an index table according to the location information, and store the index table in a memory;

[0008] When data merging is performed, data merging is performed according to the loser tree, the index table, and the first ordered intermediate result.

[0009] In one of the embodiments, it also includes: obtaining a small file to be detected in the input cache read into the memory; traversing the data in the input cache, and when the number of continuous ordered data exceeds a threshold, obtaining an ordered interval of the small file.

[0010] In one of the embodiments, the method further includes: when the number of continuous ordered data is less than a threshold, storing the continuous ordered data in an unordered data bucket in a memory.

[0011] In one of the embodiments, the further step includes: when the number of data in the unordered data bucket exceeds a threshold, sorting the data in the unordered data bucket to obtain a second ordered intermediate result of the ordered data.

[0012] In one of the embodiments, the method further includes: writing the second ordered intermediate result back to the NVM, recording the location information of the second ordered intermediate result rewritten to the NVM, and adding the location information to the index table.

[0013] In one of the embodiments, the method further includes: storing the unordered data in the input buffer in an unordered interval array, and sorting the data in the unordered interval array when the amount of data in the unordered interval array reaches a threshold.

[0014] In one of the embodiments, it also includes: searching for location information of the ordered interval on the NVM according to the index table; reading the header of the ordered interval and the first ordered intermediate result into the memory and using them as leaf nodes of the loser tree, obtaining the minimum value in the header, and writing the minimum value to the output cache; iteratively retrieving the minimum value in the remaining data of the ordered interval and the first ordered intermediate result in turn, and writing the retrieval result to the output cache; after the data in the output cache is full, writing the data in the output cache back to the NVM, and obtaining an ordered data file in the NVM.

[0015] In one of the embodiments, the method further includes: when the maximum value of an ordered interval is less than the minimum value of another ordered interval; merging the two ordered intervals to obtain a merged ordered interval; and updating the index table according to the position information of the merged ordered interval.

[0016] An external sorting device for NVM, the device comprising:

[0017] An ordered interval retrieval module is used to obtain the ordered intervals of the small files in the input cache read into the memory, and sort the unordered data in the input cache to obtain a first ordered intermediate result, and write the first ordered intermediate result back to the NVM; the small files are obtained by segmenting the large data files;

[0018] An index table building module, used for obtaining the position information of the ordered interval on the NVM, building an index table according to the position information, and storing the index table in a memory;

[0019] The data merging module is used to merge the data according to the loser tree, the index table and the first ordered intermediate result when merging the data.

[0020] A NVM memory having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following steps:

[0021] Obtaining an ordered interval of a small file in an input cache read into the memory, and sorting the unordered data in the input cache to obtain a first ordered intermediate result, and writing the first ordered intermediate result back to the NVM; the small file is obtained by segmenting the large data file;

[0022] Acquire location information of the ordered interval on the NVM, establish an index table according to the location information, and store the index table in a memory;

[0023] When data merging is performed, data merging is performed according to the loser tree, the index table, and the first ordered intermediate result.

[0024] The above-mentioned NVM external sorting method, device and NVM memory divide a large input file into multiple small files that can be accommodated in the memory space, read each small file into the input cache of the memory in turn, retrieve the ordered intervals in the small files, sort the disordered data in the memory, and write the sorted data back to the external memory device NVM. The ordered data written back to the external memory device is called the first ordered intermediate result. The position information of the ordered interval on the NVM is recorded in the index table in the memory. According to the loser tree, the index table and the first ordered intermediate result, multiple merge iterations are performed to obtain an ordered output file. It can make full use of the storage characteristics of NVM, redesign the external sorting algorithm, reduce the number of write operations to the external memory, speed up the execution of external sorting, solve the I / O load problem of traditional external merge sorting, and extend the service life of the external memory device. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1is a flow chart of an external sorting method of NVM in one embodiment;

[0026] Figure 2 is a schematic flow chart of a data merging step in an embodiment;

[0027] Figure 3 A schematic diagram of a RunMerge optimization strategy in an embodiment;

[0028] Figure 4 Schematic diagram of the effect of disorder ratio on the performance of NVMSort under large-scale data in one embodiment;

[0029] Figure 5 It is a schematic diagram of NVMOrt performance comparison with different total amounts of data under large-scale data in another embodiment;

[0030] Figure 6 A schematic diagram of the effect of different continuous and ordered thresholds on the performance of an algorithm in one embodiment;

[0031] Figure 7 FIG. 4 is a structural block diagram of an external sorting device of NVM in one embodiment. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. For the convenience of explanation, an external sorting method based on NVM is referred to as NVMSort below. The test mentioned below is implemented on the real NVM product Optane DC PMM launched by Intel.

[0033] In one embodiment, Figure 1 As shown, a method for external sorting of NVM is provided, comprising the following steps:

[0034] Step 102, obtaining the ordered intervals of the small files in the input cache read into the memory, and sorting the unordered data in the input cache to obtain a first ordered intermediate result, and writing the first ordered intermediate result back to the NVM.

[0035] Small files are obtained by segmenting large data files. The size of small files does not exceed the size of memory. When the input data file is relatively large, due to limited memory space, it is impossible to read all the data into the memory at one time. The large data file needs to be segmented into multiple small files that can be accommodated in the memory; ordered intervals refer to continuous ordered data sorted in ascending order. The head is the minimum value of the ordered interval, and the tail is the maximum value of the ordered interval. It is the originally ordered data in the large data file; unordered data refers to data segments that are not sorted in ascending order. It is the originally unordered data in the large data file. The unordered data is stored in the unordered interval array in the memory. When the amount of data in the unordered array reaches a set threshold, the part of the unordered data is sorted to obtain the first ordered intermediate result. The sorting process includes quick sorting or other memory sorting algorithms, and the first ordered intermediate result is written back to NVM. The first ordered intermediate result will be merged with the ordered data to obtain an ordered large data file.

[0036] Step 104, obtaining the position information of the ordered interval on the NVM, establishing an index table according to the position information, and storing the index table in the memory.

[0037] The main function of the index table is to record the starting and ending positions of all ordered data intervals in the external memory file according to the starting offset and ending offset of the ordered intervals, so as to facilitate reading data in the merging stage. The index table is expressed in the form of ITable. The function of ITable is to record the position index information of the ordered intervals. By recording the position information of the ordered intervals, the corresponding data can be read into the memory according to the index table information in the data merging stage for merge comparison.

[0038] Step 106, when merging data, merge the data according to the loser tree, the index table and the first ordered intermediate result.

[0039] Data merging is mainly completed using a loser tree, which is a complete binary tree. The loser tree has a relatively high search efficiency and can retrieve the maximum value within the time complexity of log(n). The loser tree is equivalent to screening out the final winner through multiple rounds of competition, that is, the minimum value in the value. In the loser tree, the larger of the two numbers is defined as the loser, and the smaller of the two numbers is defined as the winner. According to the position index information of the index table, the corresponding data of the ordered interval is read into the input cache of the memory, and sorted with the first ordered intermediate result through the loser tree to obtain an ordered big data file. Because NVM can be byte-addressed, the detected ordered interval can be of variable length. The merging stage can read from NVM to DRAM at a fine-grained level. The minimum unit of reading data is 4KB, so the read amplification problem can be reduced. In addition, in fine-grained data reading, NVMSort can be used to detect partially ordered intervals in the original data, which can greatly reduce the amount of data written back to NVM, improve algorithm execution performance, and speed up external sorting processing and response time.

[0040] In the above-mentioned NVM external sorting method, a large input file is divided into a plurality of small files that can be accommodated in the memory space, each small file is read into the input cache of the memory in turn, the ordered intervals in the small files are retrieved, the disordered data in the memory is sorted, and the sorted data is written back to the external memory device NVM. The ordered data written back to the external memory device is called the first ordered intermediate result, and the position information of the ordered interval on the NVM is recorded in the index table in the memory. According to the loser tree, the index table and the first ordered intermediate result, multiple merge iterations are performed to obtain an ordered output file. The embodiment of the present invention can make full use of the storage characteristics of NVM, redesign the external sorting algorithm, reduce the number of write operations to the external memory, speed up the execution of the external sorting, solve the I / O load problem of the traditional external merge sorting, and extend the service life of the external memory device.

[0041] In one embodiment, obtaining an ordered interval of small files in an input cache read into a memory includes: obtaining small files to be detected in the input cache read into the memory; traversing the data in the input cache, and when the number of continuous ordered data exceeds a threshold, obtaining an ordered interval of small files.

[0042] In this embodiment, the ordered intervals whose number of data exceeds the threshold do not need to be re-sorted or re-written back to the external memory device, which can avoid the re-sorting and writing of the ordered data back to the external memory and reduce the amount of data written back; if the number of ordered intervals detected is relatively large, when merging data, it is necessary to reserve input cache for each ordered interval in the memory, which results in relatively large memory usage overhead. Setting the ordered threshold of continuous ordered data to divide the ordered intervals can reduce the number of ordered intervals, thereby reducing the input cache overhead in the merging stage. Because DRAM space is limited, the input cache needs to reserve data space for each ordered interval to participate in data merging, so by reducing the number of ordered intervals, the memory utilization rate can be improved, and the input cache can reserve a larger space for each ordered interval, thereby improving the read and write granularity in the merging stage and improving the algorithm execution efficiency.

[0043] In one of the embodiments, it further includes: when the number of continuous ordered data is less than a threshold, the continuous ordered data is stored in an unordered data bucket in the memory. In this embodiment, if the total number of detected ordered data intervals is less than the threshold, the data in the interval is stored in an unordered data bucket in the memory, and needs to be sorted before being written back to the external memory. The unordered data bucket is used to store ordered intervals with a number of data less than the threshold. This step is mainly to control the number of retrieved ordered intervals. Longer continuous ordered data intervals should be recorded as much as possible, rather than recording a large number of short ordered data intervals.

[0044] In one of the embodiments, it also includes: when the number of data in the unordered data bucket exceeds a threshold, the data in the unordered data bucket is sorted to obtain a second ordered intermediate result of the ordered data. In this embodiment, the threshold refers to a limiting parameter for the number of data in the unordered data bucket. The data in the unordered data bucket, i.e., the ordered interval whose number of data is less than the ordered threshold, is part of the ordered data of the large data file. Sorting the data in the unordered data bucket can reduce the number of ordered intervals with shorter lengths, and can reduce the input cache overhead when merging data. The generated second ordered intermediate result is written back to the NVM, and the re-written position information will be recorded in the index table. This embodiment can also reduce the memory overhead of the index table, because the memory overhead of the index table is proportional to the number of ordered intervals.

[0045] In one of the embodiments, the method further includes: writing the second ordered intermediate result back to the NVM, recording the position information of the second ordered intermediate result rewritten back to the NVM, and adding the position information to the index table.

[0046] In one of the embodiments, the method further includes: storing the disordered data in the input buffer in the disordered interval array, and sorting the data in the disordered interval array when the amount of data in the disordered interval array reaches a threshold. In this embodiment, the threshold refers to a limiting parameter for the amount of disordered data in the disordered interval array, the disordered interval array is stored in the memory, and the result after sorting the disordered data in the disordered array is the first ordered intermediate result, which will be written back to the NVM.

[0047] In one of the embodiments, when performing data merging, the data merging is performed according to the loser tree, the index table and the ordered intermediate results, including: searching for the location information of the ordered interval on the NVM according to the index table; reading the header of the ordered interval and the first ordered intermediate result into the memory and using them as the leaf nodes of the loser tree, obtaining the minimum value in the header, and writing the minimum value to the output cache; iteratively retrieving the minimum value in the remaining data of the ordered interval and the first ordered intermediate result in turn, and writing the retrieval result to the output cache; after the data in the output cache is full, writing the data in the output cache back to the NVM, and obtaining an ordered data file in the NVM.

[0048] In the present embodiment, the minimum value is retrieved by the loser tree for data iteration, and an ordered data file is obtained. Each leaf node of the loser tree records a value, and each intermediate node is equivalent to a game, and the values ​​of the two child nodes of the intermediate node are compared. In the loser tree, each layer is equivalent to a round of competition, and the intermediate node records the loser in this game, that is, the subscript of the node with a larger value. In the loser tree, the loser of the game of its left and right child nodes is recorded by the parent node, that is, the larger value of the two numbers involved in the comparison, and the data with a smaller value, that is, the winner continues to participate in the next round of competition. The root node of the loser tree records the larger value of the last round of competition, and an additional node is also needed to record the minimum value of the whole game, which is also the final winner. The search efficiency of the loser tree is better, and the most value can be found within the log (n) time complexity. Therefore, when updating the leaf nodes, the loser tree can also be reconstructed in a relatively fast time to maintain the structure of the tree.

[0049] In a specific embodiment, Figure 2 As shown, a schematic flow chart of a data merging step is provided, where (5, 7, 8, 10, 12, 15) and (6, 9, 10) are originally ordered data intervals, and the NVM also stores the first ordered intermediate results (12, 12, 18, 20) and (7, 8, 10, 10). Figure 2In the above, the four groups of ordered data are merged into an ordered data file. The merging process is implemented using a loser tree. The head of each group of ordered data is read into the memory in turn and used as the leaf node of the loser tree. The winner is recorded in the internal node ls[·]. The first batch of minimum values ​​is (12, 7, 5, 6). The leaf nodes of the loser tree are compared in pairs. 12 is greater than 7, so 12 is the loser. The parent node records the position of the loser b1, and 7 is the winner. The comparison continues upwards. 6 is greater than 5, so 6 is the loser. The parent node records the position of the loser b4, and 5 is the winner. The comparison continues upwards. In the last round of comparison, 7 is greater than 5, so 7 is the loser and 5 is the final winner, so the minimum value of this round of comparison is 5. The minimum value is written to the output cache. When the data in the output cache is full, the data in the output cache is written back to NVM. In each round of competition, the minimum value in the loser tree can be retrieved, and the next value is added. The structure of the loser tree continues to be adjusted, the properties of the loser tree are maintained, and the minimum value is continued to be iteratively retrieved until all data is processed and a complete ordered data file is obtained.

[0050] In one of the embodiments, the method further includes: when the maximum value of an ordered interval is less than the minimum value of another ordered interval; merging two ordered intervals to obtain a merged ordered interval; and updating the index table according to the position information of the merged ordered interval.

[0051] In this embodiment, a RunMerge optimization strategy is provided, which can be used in step 102 to merge the ordered intermediate results with non-overlapping values ​​into one ordered interval, which can reduce the memory usage, record the start offset and end offset of several ordered intervals in each ordered interval after the merger, and then update the index table, logically merging multiple non-overlapping ordered intervals into one ordered interval. Figure 3 As shown in the figure, 6 ordered intervals are taken as an example for optimization, where run represents the ordered interval, and ID represents the number of the ordered interval. Run 2, run 3, and run 6 can be merged because the maximum value (Run_max) of run 2 is 43, which is less than the minimum value (Run_min) of run 3, 48. At the same time, the maximum value of run 3 is 94, which is less than the minimum value of run 6, 200. According to the RunMerge optimization strategy, these three runs are merged into one run, and run 4 and run 5 are merged into one run because the values ​​of these two ordered intervals do not overlap. The initial 6 runs are merged into 3 runs after RunMerge optimization. After the merger, the index table ITabel needs to be updated.

[0052] In a specific embodiment, the Persistent Memory Development Kit (PMDK) is used in the programming process. The PMDK is a growing collection of libraries and tools. These libraries are built on the DAX function of the operating system and allow applications to access persistent memory mapped files. The Libpmem library of the PMDK is used in the implementation. The Libpmem library is a low-level persistent memory library. By calling the pmem_map_file(·) function, a persistent memory file can be created and mapped to obtain a pointer to the file. If the address is a single variable pointing to persistent memory, the pmem_persist(·) function can be called to perform persistence operations. The pmem_unmap(·) function can be called to release the mapping relationship. Due to the limited DRAM memory, large data files need to be divided into multiple small files, and data is read from persistent memory to DRAM in batches.

[0053] In this embodiment, the data in the input buffer is first traversed, and an array is used to store the read data. The position and value size of the start of traversal are recorded. If the latter value of two adjacent values ​​is not less than the former value, then the traversal continues. If the latter value of two adjacent values ​​is less than the former value, then it stops to determine whether the length of the current continuous ordered interval exceeds the threshold. If the data length of the continuous ordered interval exceeds the threshold, the position information of this ordered interval is recorded and added to the index table. If the length does not exceed the threshold, this part of the data is copied to the unordered data bucket. Each time unordered data is retrieved, it is copied to the unordered interval array unorderData. A fixed length is set for the unordered data bucket and unorderData. When the data is full, the stored data is sorted and stored in the Optane A new file is created on the DC to obtain the first ordered intermediate result and the second ordered intermediate result. The index information of the second ordered intermediate result, including the minimum value and position offset information, is recorded. When merging data, a loser tree is first created and initialized. The loser tree is essentially implemented using an array. When initializing the loser tree, the structure of the loser tree needs to be adjusted. A data cache area is reserved in the memory for each ordered interval and the first ordered intermediate result. The header of each ordered data segment is read into the cache, and the minimum value of the cache area is added to the loser tree for comparison. A minimum value is obtained in each round of comparison. After the minimum value is added to the output cache, the data needs to be updated and the structure of the loser tree adjusted to maintain the characteristics of the loser tree. When the data in the input cache is processed, the next batch of data is read from the NVM for comparison until all data is processed and a complete ordered data file is obtained.

[0054] In another embodiment, Figure 4As shown, a schematic diagram of the performance impact of the disorder ratio on NVMSort under large-scale data is provided. The present invention tests the algorithm processing time comparison of 100GB data under different disorder ratios. The traditional external merge sort algorithm is represented by Baseline. When the disorder ratio of 100GB test data is 1%, the Baseline algorithm takes 266 minutes, and it takes about 4.43 hours to sort 100GB of partially ordered data. NVMSort can make full use of the local ordered distribution characteristics of the test data. When the disorder ratio is 1%, it only takes 18 minutes to sort 100GB of data. This is because when the proportion of disordered data in the test data is 1%, NVMSort can effectively reduce the total amount of data written back by retrieving the partially ordered intervals in the test data, and improve the algorithm execution performance. Especially in larger-scale test data, NVMSort can show more obvious performance advantages.

[0055] In one embodiment, if Figure 5 As shown, a schematic diagram of NVMSort performance comparison of different total amounts of data under large-scale data is provided. The present invention mainly tests the performance comparison of two algorithms under larger-scale data sets. The traditional external merge sort algorithm is represented by Baseline. 10GB, 50GB, 100GB, 150GB and 180GB data sets are tested respectively. When the proportion of disordered data is 1%, the execution time of the NVMSort algorithm and the traditional external merge sort algorithm can be seen. When the test data size is 150GB, the Baseline algorithm takes 6.63 hours, but the NVMSort algorithm only takes 29 minutes; when the test data size is 180GB, the execution time of the Baseline algorithm is 472 minutes, that is, 7.87 hours, but the NVMSort algorithm only takes 35 minutes. When the proportion of data disorder is 1%, the performance of the NVMSort algorithm for large-scale test data sets with different total amounts of data is improved by more than 92%, and the NVMSort algorithm can play a better performance in large-scale locally ordered data. The 100GB test data was originally completely ordered. Due to local data updates, some data became disordered. However, the test data as a whole still showed a partially ordered distribution. When the disorder ratio was 1%, about 1GB of the 100GB test data was randomly updated, causing the original data to become disordered. The NVMOrt algorithm retrieved partially ordered intervals of the test data and reduced the generation of intermediate results, thereby improving the execution efficiency of the algorithm. It only took 18.4 minutes to make the 100GB test data completely ordered.

[0056] In one embodiment, if Figure 6As shown, a schematic diagram of the performance impact of different continuous ordered thresholds on the algorithm is provided. The setting of the continuous ordered threshold is to control the number of retrieved ordered intervals. The continuous ordered data intervals with longer lengths should be recorded as much as possible, rather than recording a large number of short ordered data intervals. The size of the continuous ordered threshold has an important impact on NVMSort. The present invention sets an experiment to compare the algorithm processing time of NVMSort and the traditional external merge sort, including the time to read and write files. The traditional external merge sort algorithm is represented by Baseline. The total test data volume is 100M partially ordered data, and the data disorder ratio is set to 1%. The continuous ordered threshold is set to 2KB, 4KB, 6KB, 8KB, 12KB, 14KB and 16KB respectively, and other parameters are set to be consistent. As the ordered threshold increases, the processing time of the NVMOrt algorithm gradually increases. When the ordered threshold is set relatively small, the length requirement for the ordered interval is not so strict, so more continuous ordered data intervals can be detected in the ordered interval detection stage, which can reduce the number of data write-back operations, but at the same time it also increases the memory consumption of the record index, but the record index memory overhead accounts for a small proportion; as the ordered threshold increases, when detecting ordered intervals, only longer continuous ordered intervals exceeding the threshold are recorded, and shorter ordered intervals below the threshold are not recorded, so the number of detected ordered intervals decreases, and the number of ordered data decreases, resulting in an increase in the amount of data written back to NVM by NVMSort, which prolongs the processing time of the algorithm.

[0057] It should be understood that although Figure 1-2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0058] In one embodiment, Figure 7 As shown, an external sorting device for NVM is provided, including: an ordered interval retrieval module 702, an index table construction module 704 and a data merging module 706, wherein:

[0059] The ordered interval retrieval module 702 is used to obtain the ordered intervals of the small files in the input cache read into the memory, and sort the unordered data in the input cache to obtain the first ordered intermediate result, and write the first ordered intermediate result back to the NVM; the small files are obtained by segmenting the large data files.

[0060] The index table building module 704 is used to obtain the position information of the ordered interval on the NVM, build an index table according to the position information, and store the index table in the memory.

[0061] The data merging module 706 is used to merge the data according to the loser tree, the index table and the first ordered intermediate result when merging the data.

[0062] In one embodiment, the ordered interval retrieval module 702 is also used to obtain small files in the input cache read into the memory to be detected; traverse the data in the input cache, and when the number of continuous ordered data exceeds a threshold, obtain the ordered interval of the small file.

[0063] In one embodiment, the ordered interval retrieval module 702 is further configured to store the continuous ordered data in an unordered data bucket in the memory when the number of continuous ordered data is less than a threshold.

[0064] In one embodiment, the ordered interval retrieval module 702 is further configured to sort the data in the unordered data bucket when the number of data in the unordered data bucket exceeds a threshold value to obtain a second ordered intermediate result of the ordered data.

[0065] In one embodiment, the ordered interval retrieval module 702 is further used to store the unordered data in the input buffer in an unordered interval array before sorting the unordered data in the input buffer, and sort the data in the unordered interval array when the amount of data in the unordered interval array reaches a threshold.

[0066] In one embodiment, the index table construction module 704 is further configured to write the second ordered intermediate result back to the NVM, record the location information of the second ordered intermediate result rewritten back to the NVM, and add the location information to the index table.

[0067] In one of the embodiments, the data merging module 706 is further used to search for the location information of the ordered interval on the NVM according to the index table; read the header of the ordered interval and the first ordered intermediate result into the memory and use them as leaf nodes of the loser tree to obtain the minimum value in the header, and write the minimum value to the output cache; iteratively retrieve the minimum value in the remaining data of the ordered interval and the first ordered intermediate result in turn, and write the retrieval result to the output cache; when the data in the output cache is full, write the data in the output cache back to the NVM to obtain an ordered data file in the NVM.

[0068] In one of the embodiments, it is also used to merge two ordered intervals to obtain a merged ordered interval when the maximum value of the ordered interval is less than the minimum value of another ordered interval; and update the index table according to the position information of the merged ordered interval.

[0069] For the specific definition of the external sorting device of NVM, please refer to the definition of the external sorting method of NVM above, which will not be repeated here. Each module in the above-mentioned external sorting device of NVM can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0070] In one embodiment, a NVM memory is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in the above embodiment are implemented.

[0071] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the non-volatile memory NVM memory cited in the embodiments provided in this application can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM) or a flash memory.

[0072] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0073] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for external sorting of NVM, characterized in that: The method comprises: Obtaining an ordered interval of a small file in an input cache read into the memory, and sorting the unordered data in the input cache to obtain a first ordered intermediate result, and writing the first ordered intermediate result back to the NVM; the small file is obtained by segmenting the large data file; Acquire location information of the ordered interval on the NVM, establish an index table according to the location information, and store the index table in a memory; When data merging is performed, data merging is performed according to the loser tree, the index table, and the first ordered intermediate result.

2. The method according to claim 1, characterized in that The step of obtaining the ordered intervals of small files in the input buffer read into the memory includes: Get the small file to be detected in the input buffer read into the memory; The data in the input buffer is traversed, and when the number of continuous ordered data exceeds a threshold, an ordered interval of the small file is obtained.

3. The method according to claim 2, characterized in that The method further comprises: When the number of continuous ordered data is less than a threshold, the continuous ordered data is stored in an unordered data bucket in the memory.

4. The method according to claim 3, characterized in that: The method further comprises: When the number of data in the unordered data bucket exceeds a threshold, the data in the unordered data bucket is sorted to obtain a second ordered intermediate result of the ordered data.

5. The method according to claim 4, characterized in that The method further comprises: The second ordered intermediate result is written back to the NVM, the position information of the second ordered intermediate result being rewritten back to the NVM is recorded, and the position information is added to the index table.

6. The method according to any one of claims 1 to 5, characterized in that: Before sorting the out-of-order data in the input buffer, it also includes: The unordered data in the input buffer is stored in an unordered interval array, and when the amount of data in the unordered interval array reaches a threshold, the data in the unordered interval array is sorted.

7. The method according to claim 1, characterized in that When merging data, merging data according to the loser tree, the index table and the ordered intermediate results includes: Find the location information of the ordered interval on the NVM according to the index table; Read the headers of the ordered interval and the first ordered intermediate result into the memory and use them as leaf nodes of the loser tree, obtain the minimum value in the headers, and write the minimum value to the output buffer; Iterate and search for the minimum value in the ordered interval and the remaining data of the first ordered intermediate result in sequence, and write the search result to the output buffer; When the data in the output buffer is full, the data in the output buffer is written back to the NVM, and an ordered data file is obtained in the NVM.

8. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: When the maximum value of an ordered interval is less than the minimum value of another ordered interval; merging the two ordered intervals to obtain a merged ordered interval; Update the index table according to the position information of the merged ordered intervals.

9. An external sorting device for NVM, characterized in that: The device comprises: An ordered interval retrieval module is used to obtain the ordered intervals of the small files in the input cache read into the memory, and sort the unordered data in the input cache to obtain a first ordered intermediate result, and write the first ordered intermediate result back to the NVM; the small files are obtained by segmenting the large data files; An index table building module, used for obtaining the position information of the ordered interval on the NVM, building an index table according to the position information, and storing the index table in a memory; The data merging module is used to merge the data according to the loser tree, the index table and the first ordered intermediate result when merging the data.

10. A NVM memory having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.