SSD external sorting method, device and SSD storage device
By building an index table in the SSD and determining the reading order of data blocks based on its sorting results, the problem of ActiveSort's inability to predict the reading order is solved, improving the read and write multi-channel concurrency and channel resource utilization of the SSD, and improving data merging. execution efficiency.
Patent Information
- Application Number
- CN202210466201.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-04-29
AI Technical Summary
ActiveSort cannot predict the order of reading data blocks on the SSD side, causing data blocks with larger values to stay in DRAM in scenarios where the data is partially ordered, occupying cache resources, unable to fully utilize the SSD's internal read and write multi-channel concurrency, and reducing the merging algorithm. execution efficiency.
By dividing large files into small files and sorting them in memory, orderly intermediate results are generated, and an index table is constructed based on the minimum value of each data page to determine the reading order of data pages. The index table is used to merge data and reduce data. Transmission and read and write operations to improve algorithm execution performance.
It improves the read and write multi-channel concurrency of SSD, improves channel resource utilization, reduces the merging operation overhead during frequent queries on the host side, and improves the execution efficiency of data merging.
Smart Images

Figure CN114816322B
Abstract
Description
Technical Field
[0001] The present application relates to the field of novel non-volatile storage technology, and in particular to an SSD external sorting method, device and SSD memory. Background Art
[0002] With the development of new non-volatile storage technology, flash memory has been widely used in large servers, personal mobile devices, embedded sensor devices and high-performance computing systems. Flash memory is a block-addressed persistent external memory. The minimum granularity of reading and writing is the flash memory block. The read and write granularity of new non-volatile memory is smaller. From the perspective of flash memory type, flash memory can be divided into NAND Flash and NOR Flash. Flash-based solid state drive (SSD) is a new semiconductor storage device based on flash memory chip. Active SSDs are a smart SSD that can perform some computing functions. ActiveSort is an external sorting algorithm based on Active SSDs. ActiveSort is divided into two stages, the stage of generating ordered intermediate results and the stage of merging. The main idea of ActiveSort is to build a merge module inside Active SSDs, which can effectively reduce data transmission and reduce the read and write operations on SSD. When the host initiates a query request, ActiveSort will perform a merge-on-the-fly operation inside the Active SSD, merge the ordered intermediate results, and return the final ordered results to the host.
[0003] However, ActiveSort has two main problems. First, ActiveSort does not save the final ordered results on the SSD side. Every time the host side initiates a query request, the SSD side needs to perform a merge operation, which increases the computing overhead. Second, ActiveSort cannot predict the order of reading data blocks during the merge stage. It can only wait until the data blocks in the input cache are processed before reading the next data block from the intermediate result file where the data block is located. It cannot give full play to the internal read and write multi-channel concurrency of the SSD, especially in the scenario where the data is partially ordered. This will cause data blocks with larger values to remain in the SSD's DRAM, occupying cache resources and failing to improve the execution efficiency of the merge algorithm. Summary of the invention
[0004] Based on this, it is necessary to provide an SSD external sorting method, device and SSD memory to address the above technical problems.
[0005] An external sorting method for SSDs, the method comprising:
[0006] Obtain small files read into the memory, sort the small files to obtain ordered intermediate results, and write the ordered intermediate results back to the flash memory, wherein the small files are obtained by segmenting the large file data;
[0007] According to the minimum value of each data page in the ordered intermediate results and the position information of the ordered intermediate results written back to the flash memory, an index table is constructed in the memory of the SSD; the index table contains index information corresponding to the position information;
[0008] When data merging is performed, the index table is sorted according to the minimum value of the data page, and data merging is performed according to the sorting result of the index table and the index information to obtain an ordered result, which is written back to the flash memory.
[0009] In one of the embodiments, it also includes: reading data pages in sequence into the input cache of the SSD according to the sorting result of the index table and the index information; merging the data pages to obtain an ordered result, recording the minimum value of the next data page to be merged, and when the data size in the input cache does not exceed the minimum value, writing the ordered results back to the flash memory in batches.
[0010] In one of the embodiments, it also includes: when the data size in the input cache is larger than the minimum value, writing the data page containing the minimum data in the ordered result back to the flash memory, reading the next data page to be merged into the input cache, and iteratively merging the data pages in the input cache.
[0011] In one of the embodiments, it also includes: setting a read flash channel and a write flash channel between the flash memory and the input cache.
[0012] In one of the embodiments, the further includes: the read flash channel processes a read request for data merging, and reads data from the read flash channel to an input cache.
[0013] In one of the embodiments, it also includes: the write flash channel processes a write-back request for data merging, writes the ordered result back to the write flash channel, and writes the ordered result back to the flash memory through the write flash channel.
[0014] In one of the embodiments, the method further includes: allocating the ordered intermediate results to each flash memory channel between the memory and the flash memory in an interleaved manner with data pages as basic units, and writing the ordered intermediate results back to the flash memory through the flash memory channel.
[0015] In one of the embodiments, the number of data pages of the ordered intermediate result is equal to the number of data pages that can be accommodated by the SSD input cache.
[0016] An external sorting device for an SSD, the device comprising:
[0017] An ordered intermediate result generation module obtains small files read into the memory, sorts the small files, obtains ordered intermediate results, and writes the ordered intermediate results back to the flash memory. The small files are obtained by segmenting the large file data.
[0018] An index table construction module, used to construct an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory; the index table contains index information corresponding to the location information;
[0019] The data merging module is used to sort the index table according to the minimum value of the data page when performing data merging, merge the data according to the sorting result of the index table and the index information, obtain an ordered result, and write the ordered result back to the flash memory.
[0020] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0021] An ordered intermediate result generation module obtains small files read into the memory, sorts the small files, obtains ordered intermediate results, and writes the ordered intermediate results back to the flash memory. The small files are obtained by segmenting the large file data.
[0022] An index table construction module, used to construct an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory; the index table contains index information corresponding to the location information;
[0023] The data merging module is used to sort the index table according to the minimum value of the data page when performing data merging, merge the data according to the sorting result of the index table and the index information, obtain an ordered result, and write the ordered result back to the flash memory.
[0024] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0025] An ordered intermediate result generation module obtains small files read into the memory, sorts the small files, obtains ordered intermediate results, and writes the ordered intermediate results back to the flash memory. The small files are obtained by segmenting the large file data.
[0026] An index table construction module, used to construct an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory; the index table contains index information corresponding to the location information;
[0027] The data merging module is used to sort the index table according to the minimum value of the data page when performing data merging, merge the data according to the sorting result of the index table and the index information, obtain an ordered result, and write the ordered result back to the flash memory.
[0028] The above-mentioned external sorting method, device, computer equipment and storage medium of SSD divides the large data file into small files that can be accommodated in the host memory, reads each small file into the memory in turn and sorts it to obtain an ordered intermediate result, writes the ordered intermediate result back to the SSD in units of data pages, builds an index table in the memory of the SSD according to the minimum value and position information of each data page, sorts the index table according to the minimum value of the data page, and determines the order of reading data pages in the data merging stage according to the index table, which can avoid the data pages with large values residing in the memory, and can improve the execution efficiency of the algorithm. Merge data according to the sorting result of the index table and the index information to obtain an ordered result, and write the ordered result back to the flash memory. When the host frequently queries the ordered result, the ordered result can be directly output without re-executing the merge operation. The embodiment of the present invention can improve the multi-channel concurrency of SSD reading and writing and improve the channel resource utilization of SSD. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of an external sorting method of SSD in one embodiment;
[0030] Figure 2 A schematic diagram of reading and writing data pages in the data merging phase of IndexSort in one embodiment;
[0031] Figure 3 A schematic diagram of the impact of different read-write channel ratios on the performance of a write-back strategy in one embodiment;
[0032] Figure 4 is a schematic diagram of the merging phase of IndexSort in another embodiment;
[0033] Figure 5 A schematic diagram of the impact of different data set sizes on the performance of Isort and Baseline in one embodiment;
[0034] Figure 6 A schematic diagram of the impact of different DRAM sizes on the performance of Isort and Baseline in one embodiment;
[0035] Figure 7 is a structural block diagram of an external sorting device of an SSD in one embodiment;
[0036] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present application more clear, 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. The present invention is based on the external sorting algorithm of Active SSD and proposes an external sorting algorithm called IndexSort.
[0038] In one embodiment, Figure 1 As shown, an external sorting method of SSD is provided, comprising the following steps:
[0039] Step 102, obtain the small files read into the memory, sort the small files, obtain ordered intermediate results, and write the ordered intermediate results back to the flash memory.
[0040] Small files are obtained by splitting large file data. Due to limited memory space, large file data is split into small files that can be accommodated in the memory. The small files are read into the memory and sorted in memory to obtain ordered intermediate results. The ordered intermediate results are written back to the flash memory of the SSD in units of data pages. The ordered intermediate results are sorted through data merging to obtain ordered results.
[0041] Step 104: construct an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory.
[0042] The index table contains index information corresponding to the position information, detects the minimum value of each data page in the ordered intermediate result, builds a data page minimum value index table based on the minimum value of the data page and the position information on the flash memory, and sorts the index table from small to large based on the minimum value of the data page. The main function of the index table is to determine the order in which data blocks are read from the flash memory to the input cache of the SSD during the merge phase. By building the index table, the order in which data pages are read during the merge phase is determined, thereby speeding up the execution of external sorting.
[0043] Step 106, when merging data, sort the index table according to the minimum value of the data page, merge the data according to the sorting result of the index table and the index information, obtain an ordered result, and write the ordered result back to the flash memory.
[0044] Merging externally sorted data within the SSD can reduce data transmission and read and write operations on the SSD, while utilizing the internal concurrency and high I / O bandwidth of the SSD to greatly improve algorithm execution performance. Writing the merged ordered results back to the flash memory to save the ordered results, when the host frequently queries the ordered results, there is no need to re-execute the merge operation, which can save time.
[0045] In the above-mentioned external sorting method of SSD, the large data file is divided into small files that can be accommodated in the host-side memory, and each small file is read into the memory in turn for sorting to obtain an ordered intermediate result, and the ordered intermediate result is written back to the SSD side in units of data pages. An index table is constructed in the memory of the SSD according to the minimum value and position information of each data page, and the index table is sorted according to the minimum value of the data page. The order of reading data blocks can be predicted according to the index table, and the execution performance of the algorithm is improved by pre-reading the data. Data is merged according to the sorting result and index information of the index table to obtain an ordered result, and the ordered result is written back to the flash memory. When the host side frequently queries the ordered result, the ordered result can be directly output without re-executing the merge operation. The embodiment of the present invention can improve the multi-channel concurrency of SSD reading and writing and improve the channel resource utilization of SSD.
[0046] In one of the embodiments, data is merged according to the sorting results and index information of the index table to obtain an ordered result, and the ordered result is written back to the flash memory, including: reading data pages in sequence according to the sorting results and index information of the index table to the input cache of the SSD; merging data pages to obtain an ordered result, recording the minimum value of the next data page to be merged, and when the data size in the input cache does not exceed the minimum value, the ordered results are written back to the flash memory in batches. In this embodiment, merging data pages according to the index table realizes that the data page with the smallest data in the large file data is read into the input cache first to participate in the merge. By writing back small value data in batches, the time that data pages with larger values stay in the memory can be reduced, and more space can be freed up in the memory, thereby speeding up the execution of the merge stage.
[0047] In one of the embodiments, it also includes: when the data size in the input cache is greater than the minimum value, writing the data page containing the minimum data in the ordered result back to the flash memory, reading the next data page to be merged into the input cache, and iteratively merging the data pages in the input cache.
[0048] In this embodiment, Figure 2 Taking the data page read and write diagram of IndexSort in the data merging stage as an example, according to the order of the index table, b1, b2, a1, a2, a3, c1, c2 and a4 are read in sequence, and the merge comparison operation is performed. At the same time, the minimum value of the next data page is recorded, that is, the minimum value of data page b3 is used as a threshold. If all the data in the data cache area is smaller than the threshold, it means that this part of the data is also the smallest data that has not yet been written back to the flash memory channel. Then this part of the data can be written back to the flash memory in batches after sorting, which improves the flash memory channel write multi-channel concurrency and improves the flash memory channel resource utilization. At the same time, the data cache area will also free up more space. At this time, multiple data pages can be read according to the current data cache area free space status, which can improve the flash memory read multi-channel concurrency and improve the flash memory channel resource utilization.
[0049] In one of the embodiments, it also includes: setting a read flash channel and a write flash channel between the flash memory and the input cache; the read flash channel processes the read request for data merging, and reads data from the read flash channel to the input cache; the write flash channel processes the write back request for data merging, writes the ordered result back to the write flash channel, and writes the ordered result back to the flash memory through the write flash channel. In this embodiment, the read and write channel separation strategy is used to process the read and write requests for data merging. The read and write channel separation strategy means that the read flash channel is specifically used to process the read request for data merging, the input cache reads data from the read flash channel, and the write flash channel is mainly used to process the write back request for data merging, and writes the merged ordered result back to the flash channel. In this way, the channel resource utilization rate of the SSD can be fully improved, the idle channel situation can be reduced, the read and write multi-channel concurrency can be improved, and the execution performance of the algorithm can be accelerated.
[0050] In a specific embodiment, Figure 3 As shown in FIG. 1 , a schematic diagram of the performance impact of different read-write channel ratios on the write-back strategy is provided. Baseline refers to ActiveSort, RT refers to the read time, WT refers to the write-back time, Avg refers to the average, and the write-back strategy refers to the read-write channel hybrid strategy and the read-write channel separation strategy. The read-write channel hybrid strategy means that the flash memory channel must process both the read request of data merging and the write request of data merging at the same time. Figure 3 In the figure, the horizontal axis is the ratio of read and write channels when the read and write channels are separated. The SSDSim simulator has a total of 16 flash memory channels. The SSDSim simulator is a configurable, modular solid-state drive simulator. The SSDSim simulator parameter configuration is shown in the following table:
[0051] SSDSim simulator parameter settings
[0052]
[0053] The horizontal axis 16:16 refers to the average processing delay of read and write requests under the read-write channel hybrid strategy. At this time, the read-write hybrid strategy has the best performance because 16 channels are used to process read and write requests in the merge stage, reducing the idleness of the SSD flash channel. The read-write channel hybrid strategy can improve the flash channel resource utilization and speed up the execution of the merge stage. The horizontal axis 12:4 means that 12 channels are used to process read requests in the merge stage, and 4 channels are used to process write requests in the merge stage. The merged ordered results are written back to the independent 4 channels without occupying the resources of the read channel. However, when performing read operations and algorithm merge operations in the merge stage, the write channel will be idle, which does not improve the channel resource utilization of the SSD well. Under the read-write channel separation strategy, as the number of read channels increases and the number of write channels decreases, it can be seen that the average response time for processing read requests in the line graph gradually increases, while the average processing time for write requests decreases. In summary, the read-write channel hybrid strategy can give full play to the read-write multi-channel concurrency of the SSD and improve the channel resource utilization.
[0054] In one of the embodiments, writing the ordered intermediate results back to the flash memory includes: allocating the ordered intermediate results to each flash memory channel between the memory and the flash memory in an interleaved manner with data pages as basic units, and writing the ordered intermediate results back to the flash memory through the flash memory channels. In this embodiment, the ordered intermediate results are written back to the flash memory using an interleaved data placement strategy, which means that the ordered intermediate results are interleaved to each channel of the SSD in an interleaved manner with data pages as basic units, so that the multi-channel write concurrency performance of the SSD can be fully utilized, the channel resource utilization rate can be improved, and the efficiency of writing back to the flash memory can be improved.
[0055] In one embodiment, the number of data pages of the ordered intermediate result is equal to the number of data pages that the SSD input buffer can accommodate. In this embodiment, the accuracy of the algorithm can be guaranteed only by ensuring that the number of data pages of the input buffer is equal to the number of data pages of the ordered intermediate result.
[0056] In a specific embodiment, Figure 4 As shown, a schematic diagram of the merge phase of IndexSort is provided. Figure 4In the traditional merge stage, a data page is read from each of the six intermediate results into the cache for merge comparison. When the data distribution is not particularly uniform, the data pages with smaller values such as (2, 4, 12) and the data pages with larger values (200, 400, 612) are read into the cache together, and the data with smaller values are written back to the flash channel first, and then the data with larger values are written back. The data pages with larger values (200, 400, 612) will remain in the cache and be merged and compared with the data with smaller values, occupying DRAM space until the merge stage reaches the end, and the data with larger values will be written back to the flash channel. Figure 4 Isort refers to Indexsort, sort refers to sorting, and output buffer refers to the output cache in the flash memory. In the merging stage of IndexSort, six ordered intermediate results are stored in the flash memory of the SSD. The ordered intermediate results are called runs. Each ordered intermediate result contains three data pages. The values of each ordered intermediate result are sorted from small to large. The input cache in the SSD has 6 data page spaces. According to the order of the index table (page_min_index), the first 6 data pages are read into the input cache in turn and sorted. These 6 data pages containing the minimum values may come from the same run. The minimum value of the seventh data page with the minimum value is 25. Then, the values smaller than 25 in the cache can be directly written back to the flash memory, because the data in the cache that are smaller than 25 are also part of the current minimum value data, so they can be written back in batches.
[0057] In this embodiment, the IndexSort algorithm can solve the problem of data pages with large values being retained in the memory when the data is partially ordered, thereby improving DRAM resource utilization. At the same time, data below the threshold can be written back to the flash memory in batches, and reading data is not limited to reading only one data page. This threshold refers to the minimum value of the data page that is currently in the index table and has not been read into the DRAM. During the merging process, IndexSort concurrently writes multiple data pages in the DRAM that are below the threshold back to the flash memory, freeing up more cache space for reading the next batch of data pages from the flash memory. This is conducive to improving the multi-channel resource utilization of the SSD and improving the multi-channel concurrency of reading and writing.
[0058] In one embodiment, Figure 5As shown in the figure, a schematic diagram of the performance impact of different data set sizes on Isort and Baseline is provided. Isort refers to Indexsort, Baseline refers to ActiveSort, RT refers to read time, WT refers to write back time, Avg refers to average, and the time on the vertical axis refers to the average response time of read and write requests. The average response time of read and write requests can be a good indicator to measure the response time of the external sorting algorithm in the merging process inside the SSD. Because the response time includes the processing request time and the waiting time, the shorter the average response time of read and write requests, the higher the performance of the algorithm. The data volume is set to 100M, 200M, 400M, 800M and 1GB respectively. It can be seen that as the data volume increases, the average response time of read and write requests of the two algorithms increases, but under various data volumes, the performance of IndexSort is better than that of Baseline (ActiveSort).
[0059] In a specific embodiment, Figure 6 As shown in the figure, a schematic diagram of the impact of different DRAM sizes on the performance of Isort and Baseline is provided. Isort refers to Indexsort, Baseline refers to ActiveSort, RT represents read time, WT represents write back time, and Avg represents average. The internal DRAM capacity of SD is limited, but DRAM can cache some read and write requests, which can speed up the processing time of read and write requests in SSD. As the DRAM capacity increases, the average response delay of read and write requests of the two algorithms decreases. Under different DRAM conditions, the average response time of IndexSort's read and write requests is shorter than that of ActiveSort, and the performance is improved by nearly 36%.
[0060] It should be understood that although Figure 1 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 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.
[0061] In one embodiment, an external sorting device for an SSD is provided, comprising: an ordered intermediate result generating module 702, an index table building module 704 and a data merging module 706, wherein:
[0062] The ordered intermediate result generation module 702 obtains the small files read into the memory, sorts the small files, obtains the ordered intermediate results, and writes the ordered intermediate results back to the flash memory. The small files are obtained by segmenting the large file data.
[0063] An index table building module 704 is used to build an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory; the index table contains index information corresponding to the location information;
[0064] The data merging module 706 is used to sort the index table according to the minimum value of the data page when merging data, merge the data according to the sorting result of the index table and the index information, obtain the ordered result, and write the ordered result back to the flash memory.
[0065] In one embodiment, the ordered intermediate result generation module 702 is further used to distribute the ordered intermediate results to each flash memory channel between the memory and the flash memory in an interleaved manner with data pages as basic units, and write the ordered intermediate results back to the flash memory through the flash memory channel.
[0066] In one of the embodiments, the data merging module 706 is also used to read data pages into the input cache of the SSD in sequence according to the sorting results and index information of the index table; merge the data pages to obtain ordered results, record the minimum value of the next data page to be merged, and when the data size in the input cache does not exceed the minimum value, write the ordered results back to the flash memory in batches.
[0067] 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.
[0068] In one of the embodiments, when the data size in the input cache is greater than the minimum value, the data page containing the minimum data in the ordered result is written back to the flash memory, the next data page to be merged is read into the input cache, and the data pages in the input cache are iteratively merged.
[0069] In one of the embodiments, a read flash channel and a write flash channel are also set between the flash memory and the input cache.
[0070] In one of the embodiments, the read flash channel is also used to process a read request for data merging, and read data from the read flash channel to the input cache.
[0071] In one of the embodiments, the write flash channel is also used to process the write back request of the data merge, write the ordered result back to the write flash channel, and write the ordered result back to the flash memory through the write flash channel.
[0072] In one of the embodiments, the number of data pages used for the ordered intermediate results is equal to the number of data pages that can be accommodated by the SSD input buffer.
[0073] For the specific definition of the external sorting device of the SSD, please refer to the definition of the external sorting method of the SSD above, which will not be repeated here. Each module in the above-mentioned external sorting device of the SSD can be implemented in whole or in part by software, hardware and a combination thereof. 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.
[0074] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in the above embodiment when executing the computer program.
[0075] In one embodiment, an SSD memory is provided, and the SSD memory is obtained by executing the steps of the SSD external sorting method in the above embodiment.
[0076] 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 of the SSD 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.
[0077] 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.
[0078] 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. An external sorting method for SSD, characterized in that: The method comprises: Obtain small files read into the memory, sort the small files to obtain ordered intermediate results, and write the ordered intermediate results back to the flash memory, wherein the small files are obtained by segmenting the large file data; According to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory, an index table is constructed in the memory of the SSD; the index table contains index information corresponding to the location information; When data merging is performed, the index table is sorted according to the minimum value of the data page, and data merging is performed according to the sorting result of the index table and the index information to obtain an ordered result, which is written back to the flash memory.
2. The method according to claim 1, characterized in that Merging data according to the sorting result of the index table and the index information to obtain an ordered result, and writing the ordered result back to the flash memory comprises: Reading data pages sequentially into the input cache of the SSD according to the sorting result of the index table and the index information; The data pages are merged to obtain an ordered result, a minimum value of a next data page to be merged is recorded, and when the data size in the input cache does not exceed the minimum value, the ordered results are written back to the flash memory in batches.
3. The method according to claim 2, characterized in that The method further includes: when the data size in the input cache is greater than the minimum value, writing the data page containing the minimum data in the ordered result back to the flash memory, reading the next data page to be merged into the input cache, and iteratively merging the data pages in the input cache.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: A read flash channel and a write flash channel are provided between the flash memory and the input buffer.
5. The method according to claim 4, characterized in that The read flash channel processes the read request for data merging and reads data from the read flash channel to the input cache.
6. The method according to claim 4, characterized in that The write flash channel processes the write back request of the data merge, writes the ordered result back to the write flash channel, and writes the ordered result back to the flash memory through the write flash channel.
7. The method according to claim 1, characterized in that Writing the ordered intermediate results back to the flash memory comprises: The ordered intermediate results are interleaved and distributed to each flash memory channel between the memory and the flash memory with data pages as basic units, and the ordered intermediate results are written back to the flash memory through the flash memory channel.
8. The method according to any one of claims 1, 2, 3 or 7, characterized in that: The number of data pages of the ordered intermediate result is equal to the number of data pages that the SSD input cache can accommodate.
9. An external sorting device for SSD, characterized in that: The device comprises: An ordered intermediate result generation module obtains small files read into the memory, sorts the small files, obtains ordered intermediate results, and writes the ordered intermediate results back to the flash memory. The small files are obtained by segmenting the large file data. An index table construction module, used to construct an index table in the memory of the SSD according to the minimum value of each data page in the ordered intermediate result and the location information of the data page on the flash memory; the index table contains index information corresponding to the location information; The data merging module is used to sort the index table according to the minimum value of the data page when performing data merging, merge the data according to the sorting result of the index table and the index information, obtain an ordered result, and write the ordered result back to the flash memory.
10. An SSD memory, characterized in that: The SSD memory is obtained by executing the steps of the SSD external sorting method according to any one of claims 1 to 8.
