Method, device, electronic equipment, storage medium and program product for data pre-reading

CN120723730BActive Publication Date: 2026-09-15BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410371557.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2026-09-15
Estimated Expiration
2044-03-28

AI Technical Summary

Technical Problem

预读的数据量越大,系统内存压力越大,如果预读数据的命中率低,则大部分预读数据需要被丢弃,这势必对系统性能造成影响

Benefits of technology

[0065] This disclosure, upon completion of the first read operation, retrieves target data from the storage medium according to a pre-read rule. Then, it identifies first data smaller than the target data to be compressed from the target data and compresses this first data to obtain compressed data. Finally, it stores the second data (excluding the first data) and the compressed data from the target data into memory. This disclosure selects a portion of the target data for compression and stores the remaining data and compressed data into memory, which reduces memory usage while pre-reading a large amount of data, thereby improving the system's data reading and processing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723730B_ABST
    Figure CN120723730B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data pre-reading method, device, electronic equipment, storage medium and program product, and relates to the technical field of electronic information. The method comprises: in the case that a first read operation is completed, obtaining target data from a storage medium according to a pre-reading rule, the pre-reading rule being used to indicate a manner of selecting the target data. The first read operation is used to read data indicated by a received read instruction from the storage medium. First data to be compressed is determined from the target data, and the size of the first data is smaller than the size of the target data. The first data is compressed to obtain compressed data. Second data and the compressed data are stored to a memory, and the second data comprises data other than the first data in the target data. The present disclosure selects a part of the target data for compression, and stores the remaining data and the compressed data to the memory, which can reduce the occupation of the memory space while pre-reading a large amount of data, thereby improving the performance of the system in reading and processing data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of electronic information technology, and in particular to a method, apparatus, electronic device, storage medium, and program product for data pre-reading. Background Technology

[0002] Linux file prefetching refers to the Linux kernel pre-fetching a specific region of a file into a cache so that subsequent reads of that region won't be blocked by page faults. Because reading data from memory is much faster than reading from storage media, prefetching effectively reduces the number of seek operations on storage media and the I / O wait time for applications, making it a crucial optimization technique for improving storage media read I / O performance. The larger the amount of data prefetched, the greater the system memory pressure. If the prefetch hit rate is low, most of the prefetched data needs to be discarded, inevitably impacting system performance. To avoid the risks to memory resources, the amount of data prefetched is usually set conservatively, but this can limit data read performance in some scenarios. Summary of the Invention

[0003] To overcome the problems existing in related technologies, this disclosure provides a method, apparatus, electronic device, storage medium, and program product for data pre-reading.

[0004] According to a first aspect of the present disclosure, a data prefetching method is provided, the method comprising:

[0005] Upon completion of the first read operation, target data is retrieved from the storage medium according to the pre-read rule; the first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data;

[0006] A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data;

[0007] The first data is compressed to obtain compressed data;

[0008] The second data and the compressed data are stored in memory, the second data including the target data excluding the first data.

[0009] Optionally, determining the first data to be compressed from the target data includes:

[0010] Obtain historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by the second read operation before obtaining the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory;

[0011] Determine the target hit rate based on the historical hit rate;

[0012] The first data is determined from the target data based on the target hit rate.

[0013] Optionally, determining the first data from the target data based on the target hit rate includes:

[0014] The product of the target hit rate and the size of the target data is used as the data segmentation value;

[0015] According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

[0016] Optionally, the historical hit rate includes the average hit rate of the most recent specified number of second read operations; determining the target hit rate based on the historical hit rate includes:

[0017] The historical hit rate is used as the target hit rate.

[0018] Optionally, the historical hit rate includes a first historical hit rate and a second historical hit rate, wherein the first historical hit rate includes the hit rate of the previous second read operation, and the second historical hit rate includes the average of the hit rates of the most recent specified number of second read operations; determining the target hit rate based on the historical hit rate includes:

[0019] The maximum value between the first historical hit rate and the second historical hit rate is taken as the target hit rate.

[0020] Optionally, the method further includes:

[0021] Determine the current hit rate of the target data, wherein the current hit rate represents the proportion of the target data read by the second read operation;

[0022] Update the first historical hit rate and the second historical hit rate based on the current hit rate.

[0023] Optionally, updating the first historical hit rate and the second historical hit rate based on the current hit rate includes:

[0024] The current hit rate is taken as the first historical hit rate;

[0025] The hit rate of the specified number of second read operations is updated based on the current hit rate to obtain the updated hit rate of the specified number of operations.

[0026] The average of the updated specified number of hit rates is taken as the second historical hit rate.

[0027] According to a second aspect of the present disclosure, a data prefetching apparatus is provided, the apparatus comprising:

[0028] The acquisition module is configured to acquire target data from the storage medium according to a pre-read rule after the first read operation is completed; the first read operation is used to read data indicated by a received read instruction from the storage medium, and the pre-read rule is used to indicate the method of selecting the target data;

[0029] The first determining module is configured to determine first data to be compressed from the target data, wherein the size of the first data is smaller than the size of the target data;

[0030] A compression module is configured to compress the first data to obtain compressed data;

[0031] The storage module is configured to store the second data and the compressed data in memory, the second data including the target data other than the first data.

[0032] Optionally, the first determining module includes:

[0033] The acquisition submodule is configured to acquire historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by a second read operation before acquiring the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory;

[0034] The first determining submodule is configured to determine the target hit rate based on the historical hit rate.

[0035] The second determining submodule is configured to determine the first data from the target data based on the target hit rate.

[0036] Optionally, the second determining submodule is configured as follows:

[0037] The product of the target hit rate and the size of the target data is used as the data segmentation value;

[0038] According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

[0039] Optionally, the historical hit rate includes the average hit rate of the most recent specified number of second read operations; the first determining submodule is configured to:

[0040] The historical hit rate is used as the target hit rate.

[0041] Optionally, the historical hit rate includes a first historical hit rate and a second historical hit rate, wherein the first historical hit rate includes the hit rate of the previous second read operation, and the second historical hit rate includes the average of the hit rates of the most recent specified number of second read operations; the first determining submodule is configured to:

[0042] The maximum value between the first historical hit rate and the second historical hit rate is taken as the target hit rate.

[0043] Optionally, the device further includes:

[0044] The second determining module is configured to determine the current hit rate of the target data, wherein the current hit rate represents the proportion of the target data read by the second read operation;

[0045] The update module is configured to update the first historical hit rate and the second historical hit rate based on the current hit rate.

[0046] Optionally, the update module is configured as follows:

[0047] The current hit rate is taken as the first historical hit rate;

[0048] The hit rate of the specified number of second read operations is updated based on the current hit rate to obtain the updated hit rate of the specified number of operations.

[0049] The average of the updated specified number of hit rates is taken as the second historical hit rate.

[0050] According to a third aspect of the present disclosure, an electronic device is provided, comprising:

[0051] processor;

[0052] Memory used to store processor-executable instructions;

[0053] The processor is configured as follows:

[0054] Upon completion of the first read operation, target data is retrieved from the storage medium according to the pre-read rule; the first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data;

[0055] A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data;

[0056] The first data is compressed to obtain compressed data;

[0057] The second data and the compressed data are stored in memory, the second data including the target data excluding the first data.

[0058] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, wherein when instructions in the storage medium are executed by a processor of a mobile terminal, the mobile terminal is enabled to perform a data prefetching method, the method comprising:

[0059] Upon completion of the first read operation, target data is retrieved from the storage medium according to the pre-read rule; the first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data;

[0060] A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data;

[0061] The first data is compressed to obtain compressed data;

[0062] The second data and the compressed data are stored in memory, the second data including the target data excluding the first data.

[0063] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the data prefetching method described in the first aspect of the present disclosure.

[0064] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0065] This disclosure, upon completion of the first read operation, retrieves target data from the storage medium according to a pre-read rule. Then, it identifies first data smaller than the target data to be compressed from the target data and compresses this first data to obtain compressed data. Finally, it stores the second data (excluding the first data) and the compressed data from the target data into memory. This disclosure selects a portion of the target data for compression and stores the remaining data and compressed data into memory, which reduces memory usage while pre-reading a large amount of data, thereby improving the system's data reading and processing performance.

[0066] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0067] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0068] Figure 1 This is a schematic diagram of a data pre-reading process in related technologies.

[0069] Figure 2 This is a flowchart illustrating a data pre-reading method according to some embodiments of the present disclosure.

[0070] Figure 3 It is based on Figure 2 An example illustration shows a schematic diagram of a data prefetching process.

[0071] Figure 4 This is a flowchart illustrating another data prefetching method according to some embodiments of the present disclosure.

[0072] Figure 5 It is based on Figure 4 An embodiment shows a schematic diagram of a first data and a second data.

[0073] Figure 6 It is based on Figure 4 An embodiment illustrates a schematic diagram of a second type of data and compressed data.

[0074] Figure 7 This is a flowchart illustrating another data prefetching method according to some embodiments of the present disclosure.

[0075] Figure 8 It is based on Figure 7 An example illustration shows a schematic diagram of updating historical hit rates.

[0076] Figure 9 This is a block diagram illustrating a data prefetching apparatus according to some embodiments of the present disclosure.

[0077] Figure 10 This is a block diagram illustrating another data prefetching apparatus according to some embodiments of the present disclosure.

[0078] Figure 11 This is a block diagram illustrating another data prefetching apparatus according to some embodiments of the present disclosure.

[0079] Figure 12 This is a block diagram illustrating an electronic device according to some embodiments of the present disclosure. Detailed Implementation

[0080] Some embodiments of this disclosure will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. Various changes, modifications, and equivalents of the methods, apparatus, and / or systems described herein will become apparent upon understanding this disclosure. For example, the order of operations described herein is merely illustrative and is not limited to those orders set forth herein, but can be changed as will become apparent upon understanding this disclosure, except for operations that must be performed in a particular order. Furthermore, for clarity and brevity, descriptions of features known in the art may be omitted.

[0081] The embodiments described in the following examples of this disclosure are not representative of all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0082] Before introducing a data pre-reading method, apparatus, electronic device, storage medium, and program product shown in the embodiments of this disclosure, the application scenarios involved in the embodiments of this disclosure will be introduced first.

[0083] When reading files in file systems (such as f2fs, ext4, etc.), read-ahead operations are typically used to improve performance. The size of the read-ahead data is determined by the configuration ` / sys / block / sda / queue / read_ahead_kb`, in kilobytes (KB). Figure 1 As shown, in related technologies, the system reads data up to the specified size according to the read_ahead_size setting, following a pre-reading rule each time it reads file data. If read_ahead_size is set too small, the efficiency of reading file pages will decrease; if read_ahead_size is set too large, it will put pressure on memory resources.

[0084] This disclosure can be applied to any operating system with read-ahead functionality, such as Linux, Android, etc.

[0085] Figure 2 This is a flowchart illustrating a data prefetching method according to some embodiments of the present disclosure, such as... Figure 2 As shown, the method may include the following steps.

[0086] In step S101, upon completion of the first read operation, the target data is retrieved from the storage medium according to the pre-read rule. The first read operation is used to read the data indicated by the received read instruction from the storage medium.

[0087] For example, the system reads data from the storage medium according to the received read command. After the first read operation is completed, a pre-read operation is performed. The storage medium may include, but is not limited to, disks, solid-state drives, external hard drives, recordable optical discs, magneto-optical discs, MP3 players, MP4 players, USB flash drives, flash memory cards, etc. First, the target data can be obtained from the storage medium according to the pre-read rules. The target data can be understood as the data read in this pre-read operation. The pre-read rules are used to indicate the method of selecting the target data from the storage medium. The pre-read rules can be any type of pre-read rule, such as sequential pre-read, random pre-read, etc. This disclosure does not specifically limit the pre-read rules.

[0088] In step S102, the first data to be compressed is determined from the target data.

[0089] In this step, for the target data obtained from the storage medium, a portion of the target data can be selected as the first data to be compressed. The size of the first data is smaller than the size of the target data. In other words, the first data to be compressed is only a portion of the target data, not all of the target data.

[0090] In some embodiments, a target hit rate can be determined based on the historical hit rate from recent reads of prefetched data, and first data can be determined from the target data based on the target hit rate. The prefetched data may include data prefetched from storage medium into memory, and the target hit rate is dynamically updated as the historical hit rate is updated. For example, the product of the target hit rate and the size of the target data can be used as a data segmentation value, and data within the target data that follows the data segmentation value in the storage medium can be selected as the first data according to their address order in the storage medium.

[0091] In other embodiments, a preset compression ratio can be set in advance, and the first data can be determined from the target data based on the preset compression ratio. For example, the product of the preset compression ratio and the target data can be used as the compressed data size, and the last compressed data in the target data can be used as the first data according to the address order stored in the storage medium. Taking a target data size of 10kb and a preset compression ratio of 0.2 as an example, the compressed data size can be determined to be 0.2 * 10kB = 2kB. Then, the last 2kB of data in the target data can be used as the first data according to the address order stored in the storage medium.

[0092] In other embodiments, a preset compression value can be set in advance, and the first data can be determined from the target data according to the preset compression value. For example, the last data in the target data with the preset compression value can be used as the first data according to the address order stored in the storage medium. Taking a target data size of 10kB and a preset compression value of 3kB as an example, the last 3kB of data in the target data can be used as the first data according to the address order stored in the storage medium.

[0093] In step S103, the first data is compressed to obtain compressed data.

[0094] In this step, after determining the first data from the target data, the first data can be compressed to obtain compressed data. One possible implementation is as follows: Figure 3 As shown, the file system's read function has compression capabilities. Compression algorithms can be indirectly invoked by directly calling the compression function. For example, the compression algorithm can be zstd, Gzip, Snappy, LZ4, etc. The compression ratio of the first data can be determined by the compression algorithm.

[0095] In step S104, the second data and compressed data are stored in memory.

[0096] In this step, the data in the target data other than the first data can be used as the second data. The second data can be directly stored in memory, while the first data is compressed and stored in memory as compressed data. The storage order of the second data and compressed data in memory can be consistent with the address order of the second data and the first data in the storage medium. For example, if the first data is stored after the second data in the storage medium, then when storing the second data and compressed data in memory, the compressed data can be stored after the second data; that is, the address of the compressed data in memory is after the second data. The memory in this disclosure can be a cache, main memory, etc. For example, in a Linux system, it could be a filecache. This disclosure does not specifically limit the specific type of memory.

[0097] For example, after the system completes the first read operation, the pre-read data will be read into memory according to the size set by `read_ahead_size`. However, a portion of this data will be compressed before being stored in memory. In other words, the actual target data size for pre-reading is `size`, but the actual physical memory occupied is less than `size`. This allows the size of the pre-read data set by `read_ahead_size` to be relatively large, enabling the pre-reading of as much data as possible from the storage medium while ensuring that the pre-read data occupies a small amount of memory, thus improving the performance of system data reading and processing.

[0098] In summary, this disclosure, upon completion of the first read operation, retrieves target data from the storage medium according to the pre-read rule, then determines first data smaller than the target data to be compressed from the target data, compresses the first data to obtain compressed data, and finally stores the second data (excluding the first data) and the compressed data in memory. This disclosure selects a portion of the target data for compression and stores the remaining data and compressed data in memory, which can reduce memory usage while pre-reading a large amount of data, thereby improving the system's data reading and processing performance.

[0099] Figure 4 This is a flowchart illustrating another data prefetching method according to some embodiments of the present disclosure, such as... Figure 4 As shown, step S102 can be achieved through the following steps.

[0100] In step S1021, the historical hit rate is obtained.

[0101] In this step, the historical hit rate represents the proportion of pre-read data read from memory by the second read operation before acquiring the target data. The historical hit rate can include one hit rate or multiple hit rates. The hit rate can be understood as the proportion of pre-read data read from memory by the second read operation, which can include read operations that retrieve data from memory. For example, if the second read operation reads 80% of the specified pre-read data, then the hit rate for that second read operation is 80%. The specified pre-read data can be understood as a segment of pre-read data read from the storage medium in a single pre-read operation.

[0102] In step S1022, the target hit rate is determined based on the historical hit rate.

[0103] In some embodiments, the hit rate of the most recent second read operation before acquiring the target data can be used as the historical hit rate, and correspondingly, the target hit rate can be the historical hit rate.

[0104] In other embodiments, the hit rate of the most recent second read operations before acquiring the target data can be used as the historical hit rate, and correspondingly, the target hit rate can be the average of multiple historical hit rates.

[0105] In other embodiments, the hit rate of the most recent second read operations before acquiring the target data can be used, where the number of most recent operations can be preset. Accordingly, the larger of the hit rate of the most recent second read operation and the average hit rate of the most recent second read operations can be used as the target hit rate. For example, if the historical hit rates, arranged from shortest to largest time from the current moment, are 0.8, 0.5, 0.7, and 0.8, then the hit rate of the most recent second read operation can be determined to be 0.8. The average hit rate of the most recent second read operations is (0.8 + 0.5 + 0.7 + 0.8) ÷ 4 = 0.7 < 0.8. Therefore, the hit rate of the most recent second read operation, 0.8, can be used as the target hit rate.

[0106] In other embodiments, the hit rate of the most recent multiple second read operations before acquiring the target data can be used. Accordingly, the larger of the hit rate of the most recent second read operation and the average hit rate of the multiple second read operations prior to the most recent one can be used as the target hit rate. For example, if the historical hit rates, arranged from shortest to largest time from the current moment, are 0.6, 0.8, 0.7, and 0.6, then the hit rate of the most recent second read operation can be determined to be 0.8. The average hit rate of the multiple second read operations prior to the most recent one is (0.8 + 0.7 + 0.6) ÷ 3 = 0.7 > 0.6. Therefore, the average hit rate of the multiple second read operations prior to the most recent one, 0.7, can be used as the target hit rate.

[0107] In step S1023, the first data is determined from the target data based on the target hit rate.

[0108] In this step, since the larger the amount of data read each time, the lower the hit rate of the data read later each time, that is, the lower the probability of the later data in the target data being read, the later data in the target data can be selected as the first data according to the target hit rate.

[0109] For example, the product of the target hit rate and the size of the target data is used as the data segmentation value. Data following the data segmentation value in the storage medium is then treated as the first data, according to their address order in the storage medium. Since the probability of the first data being read is low, compressing it and storing it in memory reduces the memory space occupied by the target data. If a subsequent second read operation reads the compressed data, a decompression function can be called to decompress the matched compressed data into memory for reading. If the compressed data is not matched, it occupies only a small portion of memory and is directly removed during memory reclamation.

[0110] Taking the target data size as size, the target hit rate as ratio, and the compression ratio of the first data as 1 / 4 as an example, such as Figure 5 As shown, the data after the data split value size*ratio, with a size of size*(1-ratio), is the first data; correspondingly, the data before the data split value size*ratio, with a size of size*ratio, is the second data. For example... Figure 6 As shown, the compressed data obtained by compressing according to the target hit rate actually occupies size*(1-ratio) / 4 of physical memory. The second data and the memory data together occupy size*(1+ratio*3) / 4 of physical memory, which is smaller than the size of the target data, thus significantly saving memory space.

[0111] According to other embodiments of this disclosure, the historical hit rate may include the average hit rate of the most recent specified number of second read operations. Accordingly, one implementation of step S1022 may be:

[0112] Use historical hit rate as the target hit rate.

[0113] For example, a history array can be predefined, and the hit rates of the most recent specified number of second read operations can be recorded in the history array. The length of the history array can be the length corresponding to the specified number. Taking a specified number of 3 as an example, the length of the history array can be 3, and the history data can store the hit rates of the most recent 3 second read operations. The average of the specified number of hit rates stored in the history array can be used as the historical hit rate, and the historical hit rate can be used as the target hit rate. In other words, the average of the specified number of hit rates stored in the history array can be used as the target hit rate.

[0114] According to other embodiments of this disclosure, the historical hit rate may include a first historical hit rate and a second historical hit rate, wherein the first historical hit rate includes the hit rate of the previous second read operation, and the second historical hit rate may include the average of the hit rates of the most recent specified number of second read operations. Accordingly, one implementation of step S1022 may be:

[0115] The higher of the first and second historical hit rates is taken as the target hit rate.

[0116] For example, a history array and a current variable can be predefined. The history array can record the hit rate of the most recent specified number of second read operations. The average of the multiple hit rates in the history array is the second historical hit rate. The value of the current variable is the hit rate of the most recent second read operation, which is the first historical hit rate.

[0117] Figure 7 This is a flowchart illustrating another data prefetching method according to some embodiments of the present disclosure, such as... Figure 7As shown, the method may also include the following steps.

[0118] In step S105, the current hit rate of the target data is determined. The current hit rate represents the proportion of the target data read by the second read operation.

[0119] In step S106, the first historical hit rate and the second historical hit rate are updated based on the current hit rate.

[0120] For example, after storing the second data and compressed data in memory, a second read operation targeting the second data and compressed data can be monitored. The hit rate of this second read operation can be used as the current hit rate for the target data. Then, the first historical hit rate and the second historical hit rate can be updated based on the current hit rate. In other words, after each second read operation is completed, the hit rate of this second read operation is recorded, and this hit rate is used to update the historical hit rate, so as to determine the target hit rate for the next pre-read operation based on the updated historical hit rate.

[0121] In one possible implementation, the current hit rate can be used as the first historical hit rate, and the hit rate of a specified number of second read operations can be updated based on the current hit rate to obtain the updated specified number of hit rates. Then, the average of the updated specified number of hit rates can be used as the second historical hit rate.

[0122] For example, such as Figure 8 As shown, taking a specified quantity of 3 as an example, the history array history_ratio[3] stores ratio[0], ratio[1] and ratio[2]. The time elapsed between ratio[0], ratio[1] and ratio[2] and the current time increases sequentially. The average value of ratio[0], ratio[1] and ratio[2] is the second historical hit rate, and the value of the current variable is the hit rate of the most recent second read operation, which is the first historical hit rate. After determining the current hit rate, the value of the current variable can be updated using the current hit rate, that is, the current hit rate can be assigned to the current variable. The values ​​of ratio[0], ratio[1] and ratio[2] in the history array history_ratio[3] can be migrated in sequence, that is, the value of ratio[1] is assigned to ratio[0], the value of ratio[2] is assigned to ratio[1], and the value of the current variable is assigned to ratio[2]. Then the average value of the updated ratio[0], ratio[1] and ratio[2] is used as the second historical hit rate.

[0123] In this way, the first and second historical hit rates can be updated after each second read operation, and the target hit rate for the next pre-read operation can be determined based on the updated first and second historical hit rates. This ensures that each pre-read operation can use the most accurate hit rate to determine the first data to be compressed, thereby guaranteeing the rationality and accuracy of the compressed data in the target data.

[0124] In summary, this disclosure, upon completion of the first read operation, retrieves target data from the storage medium according to the pre-read rule, then determines first data smaller than the target data to be compressed from the target data, compresses the first data to obtain compressed data, and finally stores the second data (excluding the first data) and the compressed data in memory. This disclosure selects a portion of the target data for compression and stores the remaining data and compressed data in memory, which can reduce memory usage while pre-reading a large amount of data, thereby improving the system's data reading and processing performance.

[0125] Figure 9 This is a block diagram illustrating a data prefetching apparatus according to some embodiments of the present disclosure, such as... Figure 9 As shown, the device 200 may include:

[0126] The acquisition module 201 is configured to acquire target data from the storage medium according to a pre-read rule after the first read operation is completed. The first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data.

[0127] The first determining module 202 is configured to determine the first data to be compressed from the target data, wherein the size of the first data is smaller than the size of the target data.

[0128] Compression module 203 is configured to compress the first data to obtain compressed data.

[0129] Storage module 204 is configured to store second data and compressed data in memory, the second data including data in the target data other than the first data.

[0130] Figure 10 This is a block diagram illustrating another data prefetching apparatus according to some embodiments of the present disclosure, such as... Figure 10 As shown, the first determining module 202 includes:

[0131] The Acquisition submodule 2021 is configured to acquire historical hit rates. Historical hit rate represents the proportion of pre-read data read from memory during the second read operation before acquiring target data. The second read operation includes read operations that retrieve data from memory, and the pre-read data includes data pre-read from storage media into memory.

[0132] The first determination submodule 2022 is configured to determine the target hit rate based on historical hit rates.

[0133] The second determination submodule 2023 is configured to determine the first data from the target data based on the target hit rate.

[0134] In some embodiments, the second determining submodule 2023 is configured to:

[0135] The product of the target hit rate and the size of the target data is used as the data splitting value.

[0136] According to the address order stored in the storage medium, the data following the data segmentation value in the target data is taken as the first data.

[0137] In other embodiments, the historical hit rate includes the average hit rate of the most recent specified number of second read operations, and the first determining submodule 2022 is configured to:

[0138] Use historical hit rate as the target hit rate.

[0139] In other embodiments, the historical hit rate includes a first historical hit rate and a second historical hit rate. The first historical hit rate includes the hit rate of the previous second read operation, and the second historical hit rate includes the average of the hit rates of the most recent specified number of second read operations. The first determining submodule 2022 is configured to:

[0140] The higher of the first and second historical hit rates is taken as the target hit rate.

[0141] Figure 11 This is a block diagram illustrating another data prefetching apparatus according to some embodiments of the present disclosure, such as... Figure 11 As shown, the device 200 may further include:

[0142] The second determining module 205 is configured to determine the current hit rate of the target data, whereby the current hit rate represents the proportion of the target data read by the second read operation.

[0143] Update module 206 is configured to update the first historical hit rate and the second historical hit rate based on the current hit rate.

[0144] In other embodiments, the update module 206 is configured to:

[0145] Use the current hit rate as the first historical hit rate.

[0146] Update the hit rate of a specified number of second read operations based on the current hit rate to obtain the updated hit rate of the specified number of operations.

[0147] The average of the updated specified number of hit rates is used as the second historical hit rate.

[0148] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0149] In summary, this disclosure, upon completion of the first read operation, retrieves target data from the storage medium according to the pre-read rule, then determines first data smaller than the target data to be compressed from the target data, compresses the first data to obtain compressed data, and finally stores the second data (excluding the first data) and the compressed data in memory. This disclosure selects a portion of the target data for compression and stores the remaining data and compressed data in memory, which can reduce memory usage while pre-reading a large amount of data, thereby improving the system's data reading and processing performance.

[0150] Figure 12 This is a block diagram illustrating an electronic device according to some embodiments of the present disclosure. For example, the electronic device 300 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0151] Reference Figure 12 The electronic device 300 may include one or more of the following components: processing component 302, memory 304, power component 306, multimedia component 308, audio component 310, input / output (I / O) interface 312, sensor component 314, and communication component 316.

[0152] Processing component 302 typically controls the overall operation of electronic device 300, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 302 may include one or more processors 320 to execute instructions to complete all or part of the steps of the data prefetching method described above. Furthermore, processing component 302 may include one or more modules to facilitate interaction between processing component 302 and other components. For example, processing component 302 may include a multimedia module to facilitate interaction between multimedia component 308 and processing component 302.

[0153] Memory 304 is configured to store various types of data to support the operation of device 300. Examples of this data include instructions for any application or method operating on electronic device 300, contact data, phonebook data, messages, pictures, videos, etc. Memory 304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, storage media, or optical disc.

[0154] Power component 306 provides power to various components of electronic device 300. Power component 306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 300.

[0155] Multimedia component 308 includes a screen that provides an output interface between the electronic device 300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 308 includes a front-facing camera and / or a rear-facing camera. When the device 300 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0156] Audio component 310 is configured to output and / or input audio signals. For example, audio component 310 includes a microphone (MIC) configured to receive external audio signals when electronic device 300 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 304 or transmitted via communication component 316. In some embodiments, audio component 310 also includes a speaker for outputting audio signals.

[0157] I / O interface 312 provides an interface between processing component 302 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0158] Sensor assembly 314 includes one or more sensors for providing state assessments of various aspects of electronic device 300. For example, sensor assembly 314 may detect the on / off state of device 300, the relative positioning of components such as the display and keypad of electronic device 300, changes in position of electronic device 300 or a component of electronic device 300, the presence or absence of user contact with electronic device 300, orientation or acceleration / deceleration of electronic device 300, and temperature changes of electronic device 300. Sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 314 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 314 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0159] Communication component 316 is configured to facilitate wired or wireless communication between electronic device 300 and other devices. Electronic device 300 can access wireless networks based on communication standards, such as WiFi, 3G, 4G, 5G, other communication standards, or combinations thereof. In some embodiments of this disclosure, communication component 316 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In some embodiments of this disclosure, communication component 316 further includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0160] In some embodiments of this disclosure, the electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described data prefetching method.

[0161] In some embodiments of this disclosure, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 304 including instructions, which can be executed by a processor 320 of an electronic device 300 to complete the aforementioned data pre-reading method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0162] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a mobile terminal, enables the mobile terminal to perform the aforementioned data prefetching method.

[0163] In some embodiments of this disclosure, a computer program product is also provided, including a computer program that, when executed by a processor, implements the above-described data prefetching method.

[0164] In the above detailed description, reference has been made to the accompanying drawings, which illustrate specific aspects of this disclosure by way of illustration. In this regard, terms indicating direction or positional relationship, such as “center,” “longitudinal,” “lateral,” “length,” “width,” “thickness,” “upper,” “lower,” “front,” “rear,” “left,” “right,” “vertical,” “horizontal,” “top,” “bottom,” “inner,” “outer,” “clockwise,” “counterclockwise,” “axial,” “radial,” and “circumferential,” are used with reference to the orientation of the described figures. Since components of the described device can be positioned in multiple different orientations, directional terms are used for illustrative purposes and not for limitation. It should be understood that other aspects can be utilized and structural or logical changes can be made without departing from the concept of this disclosure. Therefore, the following detailed description should not be considered limiting.

[0165] It should be understood that, unless otherwise specifically indicated, features of various embodiments of this disclosure described herein can be combined with each other. As used herein, the term “and / or” includes any one of the relevant listed items and any combination of any two or more; similarly, “at least one of…” includes any one of the relevant listed items and any combination of any two or more.

[0166] It should be understood that, unless otherwise expressly specified and limited, the terms "joining," "attaching," "installing," "connecting," "linking," "fixing," etc., used in the embodiments of this disclosure should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection, an electrical connection, or a connection that allows communication between them; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise expressly limited. Those skilled in the art can understand the specific meaning of the above terms herein based on the specific circumstances.

[0167] Furthermore, the term "above" as used herein with respect to components, elements, or material layers formed or located "above" a surface may be used to indicate that the component, element, or material layer is "indirectly" positioned (e.g., placed, formed, deposited, etc.) on the surface such that one or more additional components, elements, or layers are arranged between the surface and the component, element, or material layer. However, the term "above" as used with respect to components, elements, or material layers formed or located "above" a surface may also optionally have a specific meaning: that the component, element, or material layer is "directly" positioned (e.g., placed, formed, deposited, etc.) on the surface, for example, in direct contact with the surface.

[0168] Although terms such as “first,” “second,” and “third” may be used herein to describe various components, parts, regions, layers, or sections, these components, parts, regions, layers, or sections are not limited to these terms. Rather, these terms are used only to distinguish one component, part, region, layer, or section from another. Therefore, without departing from the teachings of the examples described herein, the first component, part, region, layer, or section mentioned in the examples may also be referred to as the second component, part, region, layer, or section. Furthermore, the terms “first” and “second” are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as “first” or “second” may explicitly or implicitly include at least one of that feature. In the description herein, “a plurality” means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0169] It should be understood that spatial relative terms, such as “above,” “upper,” “below,” and “lower,” are used herein to describe the relationship between one element and another shown in the figures. In addition to the orientation depicted in the figures, these spatial relative terms are also intended to encompass different orientations of the device in use or operation. For example, if the device in the figures is flipped, an element described as “above” or “upper” relative to another element would be “below” or “lower” relative to that other element. Thus, depending on the spatial orientation of the device, the term “above” encompasses both above and below orientations. Devices may have other orientations (e.g., rotated 90 degrees or in other orientations), and the spatial relative terms used herein should be interpreted accordingly.

[0170] Furthermore, the term “exemplary” is used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as advantageous compared to other aspects or designs. Rather, the use of the term “exemplary” is intended to present the concept in a concrete manner. As used herein, the term “or” is intended to mean an inclusive “or” rather than an exclusive “or.” That is, unless otherwise specified or clear from the context, “X applies A or B” is intended to mean any of the natural inclusive arrangements. That is, “X applies A or B” satisfies any of the foregoing instances if X applies A; X applies B; or both X applies A and B. Additionally, unless otherwise specified or clear from the context to refer to the singular form, the articles “a” and “an” as used in this application and the appended claims are generally understood to mean “one or more.”

[0171] Similarly, although this disclosure has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art upon reading and understanding the specification and drawings. This disclosure includes all such modifications and variations and is limited only by the scope of the claims. In particular, with respect to the various functions performed by the components described above (e.g., elements, resources, etc.), unless otherwise indicated, the terminology used to describe such components is intended to correspond to any component (functionally equivalent) that performs the specific function of the described component, even if structurally not equivalent to the disclosed structure. Furthermore, although specific features of this disclosure may have been disclosed with respect to only one of several implementations, such features may be combined with one or more other features of other implementations, as may be desired and advantageous to any given or particular application. Moreover, with regard to the terms “comprising,” “owning,” “having,” “having,” or variations thereof as used in the detailed description or claims, such terms are intended to be inclusive in a manner similar to the term “including.”

[0172] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0173] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A method for data pre-reading, characterized in that, The method includes: Upon completion of the first read operation, target data is retrieved from the storage medium according to the pre-read rule; the first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data; A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data; The first data is compressed to obtain compressed data; The second data and the compressed data are stored in memory, wherein the second data includes the target data excluding the first data; The step of determining the first data to be compressed from the target data includes: Obtain historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by the second read operation before obtaining the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory; Determine the target hit rate based on the historical hit rate; The first data is determined from the target data based on the target hit rate; Determining the first data from the target data based on the target hit rate includes: The product of the target hit rate and the size of the target data is used as the data segmentation value; According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

2. The method according to claim 1, characterized in that, The historical hit rate includes the average hit rate of the most recent specified number of second read operations; determining the target hit rate based on the historical hit rate includes: The historical hit rate is used as the target hit rate.

3. The method according to claim 1, characterized in that, The historical hit rate includes a first historical hit rate and a second historical hit rate. The first historical hit rate includes the hit rate of the last second read operation, and the second historical hit rate includes the average of the hit rates of the most recent specified number of second read operations. Determining the target hit rate based on the historical hit rate includes: The maximum value between the first historical hit rate and the second historical hit rate is taken as the target hit rate.

4. The method according to claim 3, characterized in that, The method further includes: Determine the current hit rate of the target data, wherein the current hit rate represents the proportion of the target data read by the second read operation; Update the first historical hit rate and the second historical hit rate based on the current hit rate.

5. The method according to claim 4, characterized in that, The step of updating the first historical hit rate and the second historical hit rate based on the current hit rate includes: The current hit rate is taken as the first historical hit rate; The hit rate of the specified number of second read operations is updated based on the current hit rate to obtain the updated hit rate of the specified number of operations. The average of the updated specified number of hit rates is taken as the second historical hit rate.

6. A data prefetching device, characterized in that, The device includes: The acquisition module is configured to acquire target data from the storage medium according to a pre-read rule after the first read operation is completed; the first read operation is used to read data indicated by a received read instruction from the storage medium, and the pre-read rule is used to indicate the method of selecting the target data; The first determining module is configured to determine first data to be compressed from the target data, wherein the size of the first data is smaller than the size of the target data; A compression module is configured to compress the first data to obtain compressed data; The storage module is configured to store the second data and the compressed data in memory, wherein the second data includes the target data excluding the first data; The first determining module includes: The acquisition submodule is configured to acquire historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by a second read operation before acquiring the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory; The first determining submodule is configured to determine the target hit rate based on the historical hit rate. The second determining submodule is configured to determine the first data from the target data based on the target hit rate; The second determining submodule is configured as follows: The product of the target hit rate and the size of the target data is used as the data segmentation value; According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

7. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured as follows: Upon completion of the first read operation, target data is retrieved from the storage medium according to the pre-read rule; the first read operation is used to read data indicated by the received read instruction from the storage medium, and the pre-read rule is used to indicate the method for selecting the target data; A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data; The first data is compressed to obtain compressed data; The second data and the compressed data are stored in memory, wherein the second data includes the target data excluding the first data; The step of determining the first data to be compressed from the target data includes: Obtain historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by the second read operation before obtaining the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory; Determine the target hit rate based on the historical hit rate; The product of the target hit rate and the size of the target data is used as the data segmentation value; According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

8. A non-transitory computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of a mobile terminal, the mobile terminal is enabled to perform a data prefetching method, the method comprising: Once the first read operation is complete, the target data is retrieved from the storage medium according to the pre-read rules; The first read operation is used to read data indicated by a received read instruction from the storage medium, and the pre-read rule is used to indicate the method of selecting the target data; A first data to be compressed is determined from the target data, wherein the size of the first data is smaller than the size of the target data; The first data is compressed to obtain compressed data; The second data and the compressed data are stored in memory, wherein the second data includes the target data excluding the first data; The step of determining the first data to be compressed from the target data includes: Obtain historical hit rate; the historical hit rate represents the proportion of pre-read data read from memory by the second read operation before obtaining the target data, the second read operation includes a read operation to read data from memory, and the pre-read data includes data pre-read from the storage medium to the memory; Determine the target hit rate based on the historical hit rate; The product of the target hit rate and the size of the target data is used as the data segmentation value; According to the address order stored in the storage medium, the data in the target data after the data segmentation value is taken as the first data.

9. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the data prefetching method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data Processing System And Method Of Operating The Same

    CN104052493A

  • Method for processing data in external storage apparatus

    KR1020100083283A