File reading method and device and electronic equipment

By dynamically adjusting the maximum value of the pre-read window and using scene indicators to adjust the size of the pre-read window, the problems of resource waste and memory bumps in differentiated data access scenarios are solved, and efficient utilization of memory resources and improvement of data access efficiency are achieved.

CN120407526APending Publication Date: 2025-08-01VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510511352.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The traditional pre-read window mechanism is difficult to adapt to differentiated data access scenarios, resulting in an inappropriate size of the pre-read window, causing the risk of wasted memory resources or memory bumps, affecting the utilization rate of memory resources and data access efficiency.

Method used

By dynamically adjusting the maximum value of the pre-read window based on the running scenario, using scene indicators such as file reading frequency, memory availability, read thread priority and file heat, dynamically adjusting the size of the pre-read window to adapt to the current running scenario, and avoiding the problem of too large or too small pre-read window.

Benefits of technology

It optimizes memory resource utilization, reduces the impact of memory bumps, improves data access efficiency and system fluency, and is suitable for various scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407526A_ABST
    Figure CN120407526A_ABST
Patent Text Reader

Abstract

The invention discloses a file reading method and device and electronic equipment, and belongs to the technical field of computers. The method comprises the following steps: under the condition that a file reading request is received, determining a scene index related to a current running scene of the electronic equipment; determining a pre-reading window maximum value based on the scene index; and reading the file based on the maximum value of the pre-reading window.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and particularly relates to a file reading method, apparatus, and electronic device. Background Art

[0002] A storage device is one of the essential firmware in electronic devices such as mobile phones, and the performance and power consumption of the storage device have received extensive attention from users. The Read-Ahead Window is the core mechanism for the operating system to optimize sequential read performance. When an application or process in an electronic device needs to read a file on a disk, it asynchronously loads the data that may be accessed subsequently into the Page Cache, so that when the application or process makes a read request again next time, some or all of the pages of the read request can be directly read from the memory, thereby reducing the number of disk accesses, reducing disk I / O latency, and thus improving the efficiency of file reading.

[0003] The operation process of the read-ahead window mainly monitors the continuity of read requests in the kernel and identifies the access pattern. When the read-ahead marker is continuously hit, the size of the read-ahead window expands exponentially until it reaches the maximum value of the read-ahead window. The traditional read-ahead mechanism usually sets the maximum value of the read-ahead window in a static configuration manner. However, this method is difficult to adapt to different data access scenarios, such as an application environment where both massive data with low-frequency access and small-scale data with high-frequency access coexist, and it is easy to have problems such as the maximum value of the read-ahead window being too small or too large. A too small window setting will limit the read-ahead efficiency, and a too large window setting will cause waste of memory resources, significantly reduce the utilization rate of memory resources, and at the same time pose a risk of memory thrashing. Summary of the Invention

[0004] The purpose of the embodiments of this application is to provide a file reading method, apparatus, and electronic device that can dynamically adjust the maximum value of the read-ahead window based on the running scenario, optimize the utilization rate of memory resources, and reduce the impact caused by memory thrashing.

[0005] In a first aspect, the embodiments of this application provide a file reading method, including:

[0006] When receiving a file reading request, determining a scenario metric related to the current running scenario of the electronic device;

[0007] Based on the scenario metric, determining the maximum value of the read-ahead window;

[0008] Performing file reading based on the maximum value of the read-ahead window.

[0009] In a second aspect, the embodiments of this application provide a file reading apparatus, including:

[0010] A determination module, configured to determine a scenario metric related to the current running scenario of the electronic device when receiving a file reading request;

[0011] A processing module, configured to determine a maximum prefetch window value based on the scenario metric;

[0012] A reading module, configured to perform file reading based on the maximum prefetch window value.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory. The memory stores a program or instruction that can run on the processor. When the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0015] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run a program or instruction to implement the method described in the first aspect.

[0016] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0017] In the embodiments of the present application, when file reading is required, the maximum prefetch window value is adjusted based on the current running scenario, so that the maximum prefetch window value can adapt to the current running scenario, thereby avoiding the problem of the maximum prefetch window value being too large or too small. While ensuring data access efficiency, it can significantly optimize the utilization rate of memory resources and reduce the impact caused by memory thrashing. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a flowchart of a file reading method provided by some embodiments of the present application;

[0019] Figure 2 is a schematic diagram of a file reading device provided by some embodiments of the present application;

[0020] Figure 3 is a block diagram of an electronic device provided by some embodiments of the present application;

[0021] Figure 4 is a schematic structural diagram of an electronic device provided by some embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0022] The following will clearly describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0023] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally indicates an "or" relationship between the associated objects before and after.

[0024] Before further elaborating on the embodiments of the present invention, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are applicable to the following explanations.

[0025] Memory Thrashing: That is, Memory Thrashing, which refers to the phenomenon that when the system memory pressure is high, frequent page cache reads and reclaims lead to a sharp decline in system performance. When the system frequently performs cache replacement operations, the data required by critical processes may be accidentally reclaimed, which will directly lead to experience degradation problems such as user interface response latency and application frame rate fluctuations, ultimately affecting the overall satisfaction of users with the use experience of intelligent terminals.

[0026] The following will, in conjunction with the accompanying drawings, elaborate in detail on the file reading method, device, electronic device, storage medium, and program product provided by the embodiments of the present application through specific embodiments and their application scenarios.

[0027] The file reading method provided by the present application can be applied to the scenario of reading files by an application or a process. The following will, in conjunction with Figure 1 Elaborate in detail on the file reading method provided by the embodiments of the present application. It should be noted that for the file reading method provided by the embodiments of the present application, the execution subject can be an electronic device. In the embodiments of the present application, taking an electronic device executing the file reading method as an example, the file reading method provided by the embodiments of the present application is described.

[0028] See Figure 1 , which is a schematic flowchart of the file reading method provided by the embodiments of the present application. As shown in Figure 1As shown, the method includes the following steps 110 - 130, which will be specifically described below.

[0029] Step 110. When a file reading request is received, determine the scenario metrics related to the current running scenario of the electronic device.

[0030] In some embodiments of the present application, when an application program and / or process in the electronic device initiates a file reading request, when the electronic device receives the file reading request, it calls a file reading interface such as generic_file_buffer_read to implement the reading operation. During the reading operation, it determines the scenario metrics related to the current running scenario to evaluate the characteristics of the current running scenario, so as to adjust the prefetch window size based on the current running scenario.

[0031] In some embodiments of the present application, the scenario metrics include, but are not limited to, parameters such as scenario type, thread status, memory status, and the popularity of the data to be read, which can characterize the characteristics of the current running scenario.

[0032] In some embodiments of the present application, when the electronic device needs to perform a prefetch operation, it adjusts the prefetch window size. Based on this, when the electronic device receives a file reading request, before determining the scenario metrics related to the current running scenario of the electronic device, it first determines whether the operation initiated by the file reading request is a prefetch operation. If it is determined that the operation initiated by the file reading request is a prefetch operation, then it executes the step of determining the scenario metrics related to the current running scenario of the electronic device; otherwise, it does not need to execute the step of determining the scenario metrics related to the current running scenario of the electronic device.

[0033] In some embodiments of the present application, the electronic device determines whether the operation initiated by the file reading request is a prefetch operation by determining whether the operation initiated by the file reading request hits a prefetch mark. The prefetch mark is used to identify prefetch pages. A prefetch page refers to a data page that is read into memory from a storage device (such as a disk, flash memory, etc.) in advance in the electronic device system to improve data access efficiency. The operating system of the electronic device provides performance monitoring tools, such as the Performance Monitor in the Windows system and the perf tool in the Linux system. The performance monitoring tools can monitor relevant metrics such as memory access and disk I / O, and can display information such as whether there is a prefetch operation and the prefetch hit rate. For example, in Linux, the perf command can be used to track various events of the system, including the access situation of memory pages. Based on this, the electronic device can determine whether the operation initiated by the file reading request hits the prefetch mark by analyzing the relevant event data monitored by the performance monitoring tools.

[0034] Step 120. Determine the maximum value of the prefetch window based on the scenario metrics.

[0035] In some embodiments of the present application, the scenario metrics can reflect the characteristics of the current operating scenario of the electronic device. After obtaining the scenario metrics, evaluate the characteristics of the current operating scenario based on the scenario metrics, and then generate the maximum value of the prefetch window that conforms to the characteristics of the current operating scenario.

[0036] Step 130. Read files based on the maximum value of the prefetch window.

[0037] In some embodiments of the present application, after obtaining the maximum value of the prefetch window that conforms to the current operating scenario, the electronic device modifies the readahead parameter of the thread based on the maximum value of the prefetch window, and reads the file data corresponding to the file read request from the storage device of the electronic device according to the native data reading logic based on the modified readahead parameter. Among them, the readahead parameter is used to control the amount or range of data read in advance when the thread performs file or data reading operations.

[0038] The file reading method provided by the embodiments of the present application adjusts the maximum value of the prefetch window based on the current operating scenario when a file needs to be read, so that the maximum value of the prefetch window can adapt to the current operating scenario, thereby avoiding the problem of the maximum value of the prefetch window being too large or too small. While ensuring data access efficiency, it can significantly optimize the utilization rate of memory resources, reduce the impact caused by memory thrashing, and improve the fluency of the system. Moreover, this method is applicable to any scenario and has wide applicability.

[0039] In some embodiments, in the above step 110, the scenario metrics can be obtained through the following steps 1101 - 1102.

[0040] Step 1101. Obtain the current operating scenario parameters of the electronic device. The current operating scenario parameters include at least two of the following: the file reading frequency in the current operating scenario, the current available memory, the current read thread priority, and the currently read file. The currently read file is the file indicated to be read by the file read request.

[0041] In some embodiments of the present application, a multi - dimensional perception system is constructed to identify multi - dimensional parameters such as the scenario data, thread state, memory state, and file data of the electronic device, so as to characterize the characteristics of the current operating scenario.

[0042] In some embodiments of the present application, the current running scenario parameters include the file reading frequency in the current running scenario. The electronic device can count the read operations in the current running scenario to obtain the file reading frequency in the current running scenario. The file reading frequency in the current running scenario includes the consecutive reading times and the total reading times in the current running scenario. Among them, the consecutive reading times refer to the number of times the file offset increases continuously in the read operation, that is, the number of times the prefetch flag is consecutively hit.

[0043] In some embodiments of the present application, the current running scenario parameters include the current available memory. The electronic device can read MemAvailable from the " / proc / meminfo" node to determine the current available memory. Among them, / proc / meminfo is mainly used to provide information related to the system memory usage. By reading the / proc / meminfo node, the usage status of the system memory can be understood. MemAvailable is a field in the output content of the / proc / meminfo node, which is used to represent the current available memory quantity of the system.

[0044] In some embodiments of the present application, the current running scenario parameters include the current read thread priority. The electronic device can monitor the read system call chain to capture the thread priority metric, thereby determining the current read thread priority.

[0045] In some embodiments of the present application, the current running scenario parameters include the currently read file. The electronic device can parse the file reading request in step 110 to determine the file to be read by the file reading request, and determine this file as the currently read file.

[0046] Step 1102. Quantize the current scenario parameters to obtain at least two scenario metrics of the electronic device.

[0047] In some embodiments of the present application, the sources and formats of the current running scenario parameters in different dimensions are usually different. Therefore, in order to facilitate the analysis of the current running scenario based on multi-dimensional parameters, the obtained current scenario parameters are quantized to obtain scenario metrics with a consistent format, and the current running scenario is characterized by the scenario metrics. Among them, each current running scenario parameter can be quantized to obtain a scenario metric. Therefore, when the current scenario parameters include at least two parameters, at least two scenario metrics can be obtained by quantizing the current scenario parameters.

[0048] In some embodiments of the present application, the scenario metric includes a first metric T1, which is used to indicate the probability of a high continuous read file scenario in the current running scenario. A high continuous read file scenario refers to a scenario where continuous reading is easily triggered. In a high continuous read file scenario, file reading needs to be performed frequently. Therefore, the prefetch window size required in a high continuous read file scenario is usually large. It can be seen that whether the current running scenario is a high continuous read file scenario is closely related to the prefetch window requirement of the electronic device. The greater the probability of a high continuous read file scenario in the current running scenario, that is, the greater the first metric, the higher the prefetch window requirement of the electronic device. Therefore, using the first metric as a scenario metric to adjust the prefetch window helps to accurately determine the preset window size that conforms to the current running scenario.

[0049] In some embodiments of the present application, the first metric is obtained by quantifying the read frequency in the current running scenario. When quantifying the read frequency in the current running scenario, based on the read frequency in the current running scenario, a first ratio of the number of continuous reads to the total number of reads in the current running scenario is determined, and the first ratio is determined as the first metric. The value range of the first metric is 0 to 1. The easier it is to trigger continuous reading in the current running scenario, the greater the value of T1. For example, in the application cold start scenario, the value of T1 is about 0.7 to 0.9, and in the AI large model loading scenario, the value of T1 is about 0.8 to 1.0.

[0050] In some embodiments of the present application, the scenario metric includes a second metric T2, which is used to indicate the current memory availability rate of the electronic device. When the memory availability rate of the electronic device is large, the memory pressure is small. At this time, there is sufficient memory space to store prefetch data and a large prefetch window can be supported. When the memory availability rate of the electronic device is small, the memory pressure is large. At this time, a large prefetch window may cause frequent page cache reading and recycling, resulting in the occurrence of the phenomenon of Memory Thrashing. It can be seen that there is a correlation between the current memory availability rate of the electronic device and the prefetch window size that the electronic device can support. The greater the current memory availability rate, the larger the prefetch window that the electronic device can support. Therefore, using the second metric as a scenario metric to adjust the prefetch window helps to set an appropriate prefetch window size and reduce memory thrashing.

[0051] In some embodiments of the present application, a second metric is obtained by quantifying the currently available memory. When quantifying the currently available memory, a second ratio of the currently available memory to the maximum reserved available memory preset is calculated, and the second ratio is determined as the second metric. Among them, the maximum reserved available memory can be set according to the actual situation, and the maximum reserved available memory of different electronic devices can be different. For example, the maximum reserved available memory can be 1GB. The second metric obtained by quantifying in this way can indicate the memory pressure of the electronic device. By comparing the second metric with a preset metric threshold, it can be determined whether the current memory space of the electronic device can tolerate a larger memory occupation. For example, by comparing the second metric with the first metric threshold and the second metric threshold respectively, if the second metric is greater than the second metric threshold, it is determined that the current memory availability rate is relatively large, and the current memory space is sufficient to tolerate a larger memory occupation. Therefore, a larger space can be provided as the storage space for pre-read data. If the second metric is less than the first metric threshold, it is determined that the current memory availability rate is relatively small, and the currently available memory space is tight and memory recycling will be performed. Among them, the first metric threshold is less than the second metric threshold, the value range of the first metric threshold is 0.3 - 0.4, and the value range of the second metric threshold is 0.5 - 0.7.

[0052] In some embodiments of the present application, the scenario metric includes a third metric T3, and the third metric is used to indicate the current read thread priority. The higher the current read thread priority, the larger the value of the third metric. A read thread with a higher priority is usually given more resources and execution opportunities by the system. At this time, if a larger pre-read window is allocated to it, it is convenient to pre-read more data in advance, meet its subsequent reading requirements, reduce the waiting time, and improve the data reading efficiency. It can be seen that there is a relationship between the current read thread priority and the size of the pre-read window. The higher the current read thread priority, the more suitable it is to set a larger pre-read window, that is, the pre-read demand of the electronic device is extremely large. Therefore, using the third metric as the scenario metric to adjust the pre-read window helps to improve the reading efficiency.

[0053] In some embodiments of the present application, a third metric is obtained by quantifying the current read thread priority. A first functional relationship is preset, and the first functional relationship is used to indicate the corresponding relationship between the thread reading priority and the third metric. Based on this, when quantifying the current read thread priority, the current read thread priority can be quantified as the third metric based on the preset first functional relationship. For example, the value range of the read thread priority is 0 - 120, and the larger the priority value, the lower the priority level. The first functional relationship includes that when the priority value of the read thread is less than 20, T3 takes the value of 1; when the priority value is between 20 and 120, T3 takes the value of 1 - 0. At this time, the value of T3 is in a proportional relationship with the priority value.

[0054] In some embodiments of the present application, the scenario metric includes a fourth metric T4. The fourth metric is used to indicate the popularity of the currently read file, that is, to indicate whether the currently read file is a preset file. The preset file is a file in the pre-set file access whitelist in the electronic device. The file access whitelist can be set according to actual needs. For example, by sorting out information such as common public libraries, private libraries, and commonly used apk files of applications, system files, application executable files, trusted configuration files, etc. can be set as files in the file access whitelist. For the files in the file access whitelist, the system generally considers them to be safe and frequently accessed. To improve the access speed of these files, when accessing the files in the file access whitelist, appropriately increasing the prefetch window can prefetch more subsequent data that may be needed in advance, reduce disk I / O operations, thereby accelerating the file reading speed and improving the overall system performance. Thus, it can be seen that there is a correlation between the popularity of the currently read file and the size of the prefetch window. The higher the popularity of the currently read file, the higher the prefetch demand of the electronic device. Therefore, using the fourth metric as a scenario metric to adjust the prefetch window helps to improve the reading speed.

[0055] In some embodiments of the present application, the fourth metric is obtained by quantifying the currently read file. A preset file is set in advance. Based on this, when quantifying the currently read file, the currently read file is matched with the preset file to obtain a file matching result. Based on the file matching result and a preset second functional relationship, the file matching result is quantified into the fourth metric. The second functional relationship is used to indicate the corresponding relationship between the file matching result and the fourth metric. For example, the file matching result is used to indicate whether the currently read file is a preset file. The second functional relationship includes that when the file matching result indicates that the currently read file is a preset file, the value of T4 is 1, and when the file matching result indicates that the currently read file is not a preset file, the value of T4 is 0. Based on this, when the file matching result of the currently read file indicates that the currently read file is a preset file, it is determined that T4 is 1, and when the file matching result of the currently read file indicates that the currently read file is not a preset file, it is determined that T4 is 0.

[0056] By the above method, scenario metrics in at least two dimensions can be obtained. Furthermore, the size of the prefetch window can be set based on the scenario metrics in at least two dimensions. Compared with setting the size of the prefetch window based on the scenario metric in a single dimension, the scenario metrics in multiple dimensions can more accurately reflect the characteristics of the current running scenario. Furthermore, a more appropriate prefetch window size that conforms to the current running scenario can be set, thus avoiding problems such as resource waste or performance degradation caused by an overly large or small prefetch window.

[0057] In some embodiments, after determining at least two scenario metrics, in step 120 above, according to the scenario metrics, a prefetch window adjustment value is determined, and then based on the prefetch window adjustment value and the prefetch window preset value, the maximum prefetch window value is determined. That is, the prefetch window preset value is adjusted based on the prefetch window adjustment value to determine the maximum prefetch window value corresponding to the current running scenario. Here, the prefetch window preset value provides an initial benchmark, that is, a basic guarantee. Even when the scenario metrics of the current running scenario are not very accurate or complete, the system can still perform a certain degree of prefetch according to the prefetch window preset value, ensuring data continuity and normal system operation, thereby improving the stability and reliability of the system in complex environments. Moreover, if the maximum prefetch window value is directly determined based on the scenario metrics of the current running scenario, the size of the prefetch window may change frequently due to minor fluctuations in the scenario data, and such frequent adjustments may cause instability in system resource allocation, such as frequent cache updates and frequent I / O operation switches. By pre-setting the prefetch window preset value and using it as a benchmark for adjustment, excessive adjustment of the prefetch window size due to minor changes in the scenario data can be avoided, thus keeping the size of the prefetch window relatively stable within a certain range and improving the stability of the system.

[0058] In some embodiments of the present application, before step 120, a prefetch window preset value is pre-set in the electronic device, so that in step 120, the prefetch window preset value pre-set in the electronic device can be directly obtained.

[0059] In some embodiments of the present application, the electronic device can adopt the following steps 210 - 240 based on the user's usage habits of the electronic device to set the prefetch window preset value by means of testing.

[0060] Step 210. Obtain at least two first prefetch window candidate values, and each first prefetch window candidate value is less than or equal to the single-request data volume threshold of the storage device in the electronic device.

[0061] In some embodiments of the present application, a preset window initial value can be set according to actual needs. The preset window initial value is greater than or equal to the page length and is a power of 2. Herein, the page length refers to the fixed size of the memory page, and the page length is usually a power of 2. Then, based on the preset window initial value, increase the power by 1 successively until it is greater than or equal to the single-request data volume threshold of the storage device in the electronic device, obtaining one or more preset window sizes. Both the preset window initial value and the one or more preset window sizes obtained by successive increment are determined as the first prefetch window candidate values. The single-request data volume threshold of the storage device can be set according to the performance of the storage device. For example, the single-request data volume threshold of the storage device can be the maximum single-request data volume of the storage device.

[0062] Exemplarily, assume that the page length is 4KB, the preset window initial value is set to 2 4 KB, and the single-request data volume threshold of the storage device is 512KB. Then, the determined first prefetch window candidate values include 16KB, 32KB, 64KB, 128KB, 256KB, and 512KB.

[0063] Step 220. Determine the target operating scenario corresponding to the user's usage habit.

[0064] In some embodiments of the present application, for each first prefetch window candidate value, performance testing is performed on the electronic device. Before performing the performance testing, first determine the target operating scenario for performing the performance testing on the electronic device.

[0065] In some embodiments of the present application, in order to make the finally set prefetch window preset value more in line with the user's usage habit, the target operating scenario is determined based on the user's usage habit. Herein, the user's usage habit refers to the user's usage habit of the electronic device.

[0066] In some embodiments of the present application, the user's usage habit includes the user's preference for application programs. Based on this, when determining the target operating scenario, the electronic device can obtain the user's behavior data, determine the usage frequency of each application program in the electronic device based on the behavior data, sort the application programs in descending order of usage frequency, select the top N application programs among them as the target application programs, and determine the scenarios related to the startup and operation of the N target application programs as the target operating scenario. Herein, N is a positive integer greater than or equal to 1. For example, N is 20.

[0067] Step 230. For each first prefetch window candidate value, test the performance of the electronic device when using the first prefetch window candidate value in the target operating scenario, and obtain a first performance parameter corresponding to the first prefetch window candidate value. The first performance parameter includes a first parameter related to the scenario performance of the electronic device and a second parameter related to the memory state of the electronic device.

[0068] In some embodiments of the present application, the performance of the electronic device is tested separately when using each first prefetch window candidate value. For each first prefetch window candidate value, when testing, set the prefetch window size of the electronic device to the first prefetch window candidate value, and then let the electronic device run in the target operating scenario, and test the performance of the electronic device during the running process, so as to obtain a first performance parameter corresponding to the first prefetch window candidate value.

[0069] In some embodiments of the present application, the first performance parameter includes a first parameter related to the scenario performance of the electronic device and a second parameter related to the memory state of the electronic device. Exemplarily, the first parameter includes, but is not limited to, parameters such as application startup time consumption, frame rate during application browsing stuttering, etc. The second parameter includes, but is not limited to, memory pressure, file page thrashing rate Thrashing, etc.

[0070] Taking the scenario where 20 target applications are normally started and browsed as the target operating scenario as an example, for each first prefetch window candidate value, after setting the prefetch window size of the electronic device to the first prefetch window candidate value, control the 20 target applications in the electronic device to be normally started and browsed. During the startup and browsing of the target applications, obtain a first parameter related to the scenario performance of the electronic device, such as application startup time consumption, stuttering rate during browsing, etc., and a second parameter related to the memory thrashing situation, such as memory pressure, file page thrashing rate Thrashing, etc. Take the first parameter and the second parameter obtained through the test as the first performance parameter corresponding to the first prefetch window candidate value.

[0071] Step 240. Determine the first prefetch window candidate value with the optimal first performance parameter among at least two first prefetch window candidate values as the preset value of the prefetch window of the electronic device.

[0072] In some embodiments of the present application, after the first performance parameter corresponding to each first prefetch window candidate value among at least two first prefetch window candidate values, compare the first performance parameters corresponding to all the first prefetch window candidate values, so as to determine the optimal first performance parameter, and determine the first prefetch window candidate value corresponding to the optimal first performance parameter as the preset value of the prefetch window.

[0073] In some embodiments of the present application, the target running scenario is the warm start scenario of 20 target applications. The first performance parameters include the application startup time and the file page thrashing rate. Based on this, among at least two first prefetch window candidate values, the first prefetch window candidate value with the minimum application startup time and no mutation in the file page thrashing rate can be determined as the prefetch window preset value.

[0074] By the above method, determining the prefetch window preset value by testing multiple first prefetch window candidate values based on user habits can make the prefetch window preset value more in line with the user's usage habits.

[0075] In some embodiments, various memory capacity configurations of the electronic device are respectively preset with corresponding second prefetch window candidate values. Based on this, when the electronic device determines the prefetch window preset value, it can determine the second prefetch window candidate value corresponding to the current memory capacity configuration of the electronic device, and determine this second prefetch window candidate value as the prefetch window preset value.

[0076] In some embodiments of the present application, the memory capacity configuration is positively correlated with the second prefetch window candidate value, that is, the larger the memory capacity configuration, the larger the corresponding second prefetch window candidate value. Among them, the second prefetch window candidate values corresponding to each memory capacity configuration can be set according to the actual situation. For example, the second prefetch window candidate value corresponding to a memory capacity configuration of 16GB can be 512KB, and the second prefetch window candidate value corresponding to a memory capacity configuration of 6GB can be 128KB.

[0077] By the above method, the electronic device can determine a prefetch window preset value that matches its own memory capacity configuration.

[0078] In some embodiments, the electronic device supports the server to issue and modify the prefetch window preset value. Based on this, the electronic device can receive the third prefetch window candidate value sent by the server, and determine this third prefetch window candidate value as the prefetch window preset value of the electronic device.

[0079] In some embodiments of the present application, the server may determine the candidate value of the third prefetch window through big data analysis. Multiple prefetch window sizes are preset in advance. The server obtains the application startup scenario performance parameters reported by the electronic device under each set prefetch window size, such as application startup time consumption, memory jitter, etc. By performing big data analysis on the obtained application startup scenario performance parameters, the server determines the prefetch window size with the optimal application startup scenario performance parameters among the multiple set prefetch window sizes, and determines this prefetch window size as the candidate value of the third prefetch window, and then sends it to the electronic device. Among them, the application startup scenario performance parameters reported by the electronic device are closely related to the application programs started on the electronic device, and the application programs started on the electronic device are in turn closely related to the user's usage habits. Different users may use different application programs. Therefore, the application startup scenario performance parameters reported by the electronic device can reflect the user's usage habits. Based on this, the candidate value of the third prefetch window determined based on the application startup scenario performance parameters matches the user's usage habits.

[0080] Exemplarily, the preset prefetch window sizes include 64KB, 128KB, and 256KB respectively. The server obtains the application startup time consumption and memory jitter of the electronic device reported at multiple time points under the prefetch window sizes of 64KB, 128KB, and 256KB, so as to obtain multiple application startup time consumptions and memory jitters corresponding to 64KB, multiple application startup time consumptions and memory jitters corresponding to 128KB, and multiple application startup time consumptions and memory jitters corresponding to 256KB. Calculate the statistics of the multiple application startup time consumptions corresponding to 64KB, the statistics of the multiple application startup time consumptions corresponding to 128KB, and the statistics of the multiple application startup time consumptions corresponding to 256KB respectively. Based on the statistics of the application startup time consumptions and the memory jitter corresponding to 64KB, 128KB, and 256KB respectively, determine the prefetch window size with the lowest application startup time consumption and no obvious mutation in memory jitter among 64KB, 128KB, and 256KB as the candidate value of the third prefetch window. Among them, the statistics include but are not limited to mean, median, mode, standard deviation, minimum value, maximum value, etc.

[0081] In some embodiments of the present application, the server may obtain the application startup scenario performance parameters of the electronic device under multiple set prefetch window sizes every day, analyze the application startup scenario performance parameters, and dynamically update and iterate the candidate value of the third prefetch window based on the analysis results. When the candidate value of the third prefetch window is updated, the updated candidate value of the third prefetch window is synchronously updated to the electronic device. This strategy of dynamically updating the candidate value of the third prefetch window can help the electronic device adapt to the usage situation of each user and determine a set of preset value configurations that conform to its own usage habits according to different users.

[0082] In this way, the electronic device can dynamically update the pre-reading window preset value based on the third pre-reading window candidate value sent by the server, so that the pre-reading window preset value can change dynamically, thereby making the pre-reading window preset value more in line with the user's usage habits.

[0083] In some embodiments, the electronic device supports the above three methods to determine the pre-reading window preset value. In this case, the electronic device can determine the maximum value of the three pre-reading window preset values determined by the above three methods as the final pre-reading window preset value.

[0084] In some embodiments of the present application, the read-ahead window adjustment value is determined through the following steps 310 to 330 .

[0085] Step 310: Multiply each scenario indicator by its corresponding weight to obtain a weighted value of each scenario indicator.

[0086] In some embodiments of the present application, in order to more accurately evaluate the characteristics of the current operating scenario, different importance weight parameters W are set for scenario indicators of different dimensions. The weight corresponding to each scenario indicator can be set based on the scenario performance that the system focuses on, but it is necessary to ensure that the sum of the weights corresponding to at least two scenario indicators is 1. Based on this, after obtaining the scenario indicators, each scenario indicator is multiplied by the corresponding weight to obtain the weighted value corresponding to each scenario indicator.

[0087] Step 320: Add the weighted values of at least two scenario indicators to obtain a window adjustment parameter.

[0088] In some embodiments of the present application, after obtaining the weighted value of each scenario indicator, these weighted values are added, and the sum obtained by the addition is determined as the current operating scenario criterion parameter for adjusting the preset window maximum value, that is, the window adjustment parameter.

[0089] For example, taking the scenario index including the first index, the second index, the third index and the fourth index as an example, the window adjustment parameter S can be calculated by the following formula (1):

[0090] S=T1W1+T2W2+T3W3+T4W4 (1)

[0091] In the above formula (1), W1 represents the weight corresponding to the first indicator, W2 represents the weight corresponding to the second indicator, W3 represents the weight corresponding to the third indicator, and W4 represents the weight corresponding to the fourth indicator. Assuming that W1 = 0.4, W2 = 0.3, W3 = 0.2, and W4 = 0.1, then in the operating scenario of T1 = 0.5, T2 = 0.8, T3 = 0.5, and T4 = 1, the window adjustment parameter S is determined to be 0.5*0.4+0.8*0.3+0.5*0.2+1*0.1=0.64.

[0092] Step 330. Determine a prefetch window adjustment value based on the window adjustment parameter.

[0093] In some embodiments of the present application, based on the above descriptions of the first index, the second index, the third index, and the fourth index, it can be known that the first index, the second index, the third index, and the fourth index are all related to the prefetch demand of the electronic device and are all positively correlated with the prefetch demand of the electronic device. Based on this, the window adjustment parameter determined based on at least two of the first index, the second index, the third index, and the fourth index is also positively correlated with the prefetch demand of the electronic device, that is, the larger the window adjustment parameter, the higher the prefetch demand of the electronic device.

[0094] In some embodiments of the present application, a third functional relationship is set in advance based on the correspondence between the window adjustment parameter and the prefetch window adjustment value. Based on this, after obtaining the window adjustment parameter, based on the window adjustment parameter and the third functional relationship, the prefetch window adjustment value corresponding to the window adjustment parameter can be determined. In this embodiment, the larger the window adjustment parameter value, the higher the prefetch demand of the electronic device in the current operating scenario. Based on this, the correspondence between the window adjustment parameter and the prefetch window adjustment value is a positive correlation, that is, the larger the window adjustment parameter, the larger the prefetch window adjustment value. In this way, the finally determined prefetch window adjustment value meets the actual requirements of the current operating scenario.

[0095] In some embodiments of the present application, two critical window adjustment parameters, namely a first critical value and a second critical value, can be set in advance according to the system performance requirements of the electronic device. The first critical value is less than the second critical value. Then, based on the magnitude relationship between the window adjustment parameter and the first critical value and the second critical value, the prefetch window adjustment value is determined. Specifically, the window adjustment parameter is compared with the preset first critical value and second critical value; when the window adjustment parameter is less than the first critical value, it is determined that the prefetch demand in the current operating scenario is low, and the first value is determined as the prefetch window adjustment value; when the window adjustment parameter is greater than or equal to the first critical value and less than or equal to the second critical value, it is determined that the prefetch demand in the current operating scenario is relatively balanced, and the second value is determined as the prefetch window adjustment value; when the window adjustment parameter is greater than the second critical value, it is determined that the prefetch demand in the current operating scenario is high, and the third value is determined as the prefetch window adjustment value; where the first value is less than the second value, and the second value is less than the third value.

[0096] In some embodiments of the present application, the first value, the second value, and the third value can be set according to the system performance. The value range of the first value is 32KB - 64KB, the value range of the second value is 128KB - 256KB, and the value range of the third value is 512KB - 1024KB.

[0097] Through the above method, a prefetch window adjustment value that conforms to the current operating scenario can be obtained.

[0098] In some embodiments, in step 120 above, based on the prefetch window adjustment value and the prefetch window preset value, the maximum prefetch window is determined through the following steps 410-step 430.

[0099] Step 410. Multiply the prefetch window adjustment value and the prefetch window preset value by their respective corresponding weights to obtain a first weighted value and a second weighted value.

[0100] In some embodiments of the present application, the prefetch window adjustment value and the prefetch window preset value are respectively set in advance according to the system performance requirements. The sum of the two weights is 1.

[0101] Step 420. Add the first weighted value and the second weighted value to obtain a fusion value.

[0102] In some embodiments of the present application, the fusion value can be calculated based on the following formula (2):

[0103] RA finale = θ * RA value +(1 - θ) * RA default (2)

[0104] In the above formula (2), RA finale represents the fusion value, RA finale represents the prefetch window adjustment value, θ represents the weight corresponding to the prefetch window adjustment value, RA default represents the prefetch window preset value, and (1 - θ) represents the weight corresponding to the prefetch window preset value.

[0105] Step 430. Determine the maximum prefetch window based on the fusion value.

[0106] In some embodiments of the present application, the electronic device has certain constraint conditions for the maximum prefetch window. Based on this, after obtaining the fusion value, it can be determined whether the fusion value meets the constraint conditions. If the fusion value meets the constraint conditions, the fusion value is determined as the adjusted maximum prefetch window, that is, the maximum prefetch window corresponding to the current operating scenario. If the fusion value does not meet the constraint conditions, a correction value is determined based on the fusion value, and the correction value is determined as the maximum prefetch window. Wherein, the correction value is the value closest to the fusion value and meeting the constraint conditions.

[0107] In some embodiments of the present application, the memory management of the electronic device performs memory alignment in units of powers of 2. Therefore, in order to ensure memory alignment and improve data access efficiency, the constraint conditions for the maximum prefetch window include: being greater than or equal to the page length and being a power of 2. For example, assuming the page length is 4KB, if the fusion value is 50KB, although this fusion value is greater than the page length, it is not a power of 2. Therefore, this fusion value cannot be directly determined as the maximum prefetch window value. At this time, a correction value is determined based on the fusion value. The power of 2 closest to 50KB is 64KB. Therefore, the correction value is determined to be 64KB, and the determined correction value, that is, 64KB, is determined as the maximum prefetch window value.

[0108] Through the above method, the maximum prefetch window value that meets the constraint conditions can be determined.

[0109] In the file reading method provided by the embodiments of the present application, the execution subject may be a file reading device. In the embodiments of the present application, taking the file reading device executing the file reading method as an example, the file reading device provided by the embodiments of the present application is described.

[0110] See Figure 2 , which is a schematic diagram of the file reading device provided by the embodiments of the present application. As Figure 2 shown, the device 200 includes the following modules:

[0111] A determination module 201, configured to determine a scenario metric related to the current running scenario of the electronic device when receiving a file reading request;

[0112] A processing module 202, configured to determine the maximum prefetch window value based on the scenario metric;

[0113] A reading module 203, configured to perform file reading based on the maximum prefetch window value.

[0114] In the embodiments of the present application, when file reading is required, the maximum prefetch window value is adjusted based on the current running scenario, so that the maximum prefetch window value can adapt to the current running scenario, thereby avoiding the problem of the maximum prefetch window value being too large or too small. While ensuring data access efficiency, it can significantly optimize the utilization rate of memory resources and reduce the impact caused by memory thrashing.

[0115] In some embodiments, the determination module 201 is specifically configured to:

[0116] Obtain the current running scenario parameters of the electronic device. The current running scenario parameters include at least two of the following: the file reading frequency in the current running scenario, the current available memory, the current read thread priority, and the current file to be read. The current file to be read is the file indicated by the file reading request to be read;

[0117] Quantify the current scene parameters to obtain at least two scene metrics of the electronic device.

[0118] In some embodiments, the at least two scene metrics include at least two of the following: a first metric, a second metric, a third metric, and a fourth metric;

[0119] The determination module 201 is specifically configured to perform at least two of the following:

[0120] Based on the file read frequency in the current running scene, determine a first ratio of the number of consecutive reads to the total number of reads in the current running scene, and determine the first ratio as the first metric;

[0121] Calculate a second ratio of the current available memory to the maximum reserved available memory preset, and determine the second ratio as the second metric;

[0122] Quantify the current read thread priority as a third metric based on a preset first functional relationship, where the first functional relationship is used to indicate the correspondence between the thread read priority and the third metric;

[0123] Match the current read file with a preset file to obtain a file matching result, and quantify the file matching result as a fourth metric based on the file matching result and a preset second functional relationship, where the second functional relationship is used to indicate the correspondence between the file matching result and the fourth metric.

[0124] In some embodiments, the processing module 202 is specifically configured to:

[0125] Multiply each scene metric by its respective weight to obtain a weighted value for each scene metric;

[0126] Add the weighted values of the at least two scene metrics to obtain a window adjustment parameter;

[0127] Determine a prefetch window adjustment value based on the window adjustment parameter;

[0128] Determine a maximum prefetch window value based on the prefetch window adjustment value and a preset prefetch window value.

[0129] In some embodiments, the processing module 202 is specifically configured to:

[0130] Compare the window adjustment parameter with a preset first critical value and a second critical value, where the first critical value is less than the second critical value;

[0131] In the case where the window adjustment parameter is less than the first critical value, determine the first value as the prefetch window adjustment value;

[0132] In the case where the window adjustment parameter is greater than or equal to the first critical value and less than or equal to the second critical value, determine the second value as the prefetch window adjustment value;

[0133] When the window adjustment parameter is greater than the second critical value, determine the third value as the prefetch window adjustment value;

[0134] Wherein, the first value is less than the second value, and the second value is less than the third value.

[0135] In some embodiments, the processing module 202 is specifically configured to:

[0136] Multiply the prefetch window adjustment value and the prefetch window preset value by their respective corresponding weights to obtain a first weighted value and a second weighted value;

[0137] Add the first weighted value and the second weighted value to obtain a fusion value;

[0138] Based on the fusion value, determine the maximum value of the prefetch window.

[0139] In some embodiments, the processing module 202 is specifically configured to:

[0140] When the fusion value meets the preset constraint conditions, determine the fusion value as the maximum value of the prefetch window;

[0141] When the fusion value does not meet the constraint conditions, determine the correction value as the maximum value of the prefetch window, and the correction value is the value closest to the fusion value and meeting the constraint conditions.

[0142] In some embodiments, the processing module 202 is further configured to:

[0143] Before determining the maximum value of the prefetch window based on the prefetch window adjustment value and the prefetch window preset value, obtain at least two first prefetch window candidate values, and each first prefetch window candidate value is less than or equal to the single-request data volume threshold of the storage device in the electronic device;

[0144] Determine the target operation scenario corresponding to the user's usage habit;

[0145] For each first prefetch window candidate value, test the performance of the electronic device when using the first prefetch window candidate value in the target operation scenario to obtain a first performance parameter corresponding to the first prefetch window candidate value, and the first performance parameter includes a first parameter related to the scenario performance of the electronic device and a second parameter related to the memory state of the electronic device;

[0146] Determine the first prefetch window candidate value with the optimal first performance parameter among at least two first prefetch window candidate values as the prefetch window preset value of the electronic device.

[0147] In some embodiments, the processing module 202 is further configured to:

[0148] Before determining the maximum value of the prefetch window based on the prefetch window adjustment value and the prefetch window preset value, determine a second prefetch window candidate value corresponding to the memory capacity configuration of the electronic device;

[0149] Determine the second prefetch window candidate value as the prefetch window preset value of the electronic device.

[0150] In some embodiments, the processing module 202 is further configured to:

[0151] Before determining the maximum value of the prefetch window based on the prefetch window adjustment value and the prefetch window preset value, receive a third prefetch window candidate value sent by the server;

[0152] Determine the third prefetch window candidate value as the prefetch window preset value of the electronic device.

[0153] The file reading device in the embodiments of the present application may be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal or other devices other than terminals. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and may also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.

[0154] The file reading device in the embodiments of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.

[0155] The file reading device provided by the embodiments of the present application can implement Figure 1 each process implemented by the method embodiments. To avoid repetition, it will not be described in detail here.

[0156] Optionally, as Figure 3As shown in the figure, an embodiment of the present application further provides an electronic device 300, including a processor 301 and a memory 302. A program or instruction that can run on the processor 301 is stored on the memory 302. When the program or instruction is executed by the processor 301, it implements the respective steps of the above-described embodiment of the file reading method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0157] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0158] Figure 4 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application.

[0159] The electronic device 400 includes, but is not limited to: a radio frequency unit 401, a network module 402, an audio output unit 403, an input unit 404, a sensor 405, a display unit 406, a user input unit 407, an interface unit 408, a memory 409, and a processor 410, etc.

[0160] Those skilled in the art can understand that the electronic device 400 may further include a power source (such as a battery) for supplying power to each component. The power source can be logically connected to the processor 410 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. Figure 4 The structure of the electronic device shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0161] Among them, the processor 410 is used to determine a scene index related to the current operating scene of the electronic device when receiving a file reading request;

[0162] The processor 410 is used to determine the maximum value of the pre-reading window based on the scene index;

[0163] The processor 410 is further used to perform file reading based on the maximum value of the pre-reading window.

[0164] In some embodiments, the processor 410 is specifically used for:

[0165] Obtain the current operating scene parameters of the electronic device. The current operating scene parameters include at least two of the following: the file reading frequency in the current operating scene, the current available memory, the current read thread priority, the currently read file, and the currently read file is the file indicated by the file reading request to be read;

[0166] Perform quantization processing on the current scene parameters to obtain at least two scene indexes of the electronic device.

[0167] In some embodiments, at least two scenario metrics include at least two of the following: a first metric, a second metric, a third metric, and a fourth metric;

[0168] The processor 410 is specifically configured to perform at least two of the following:

[0169] Based on the file reading frequency in the current running scenario, determine a first ratio of the number of consecutive reads to the total number of reads in the current running scenario, and determine the first ratio as the first metric;

[0170] Calculate a second ratio of the current available memory to the maximum value of the preset reserved available memory, and determine the second ratio as the second metric;

[0171] Based on a preset first functional relationship, quantify the current read thread priority as the third metric, where the first functional relationship is used to indicate the corresponding relationship between the thread reading priority and the third metric;

[0172] Match the current read file with a preset file to obtain a file matching result, and based on the file matching result and a preset second functional relationship, quantify the file matching result as the fourth metric, where the second functional relationship is used to indicate the corresponding relationship between the file matching result and the fourth metric.

[0173] In some embodiments, the processor 410 is specifically configured to:

[0174] Multiply each scenario metric by its respective weight to obtain a weighted value for each scenario metric;

[0175] Add the weighted values of at least two scenario metrics to obtain a window adjustment parameter;

[0176] Based on the window adjustment parameter, determine a prefetch window adjustment value;

[0177] Based on the prefetch window adjustment value and the preset value of the prefetch window, determine the maximum value of the prefetch window.

[0178] In some embodiments, the processor 410 is specifically configured to:

[0179] Compare the window adjustment parameter with a preset first critical value and a second critical value, where the first critical value is less than the second critical value;

[0180] In the case where the window adjustment parameter is less than the first critical value, determine the first value as the prefetch window adjustment value;

[0181] In the case where the window adjustment parameter is greater than or equal to the first critical value and less than or equal to the second critical value, determine the second value as the prefetch window adjustment value;

[0182] When the window adjustment parameter is greater than the second critical value, determine the third value as the prefetch window adjustment value;

[0183] Wherein, the first value is less than the second value, and the second value is less than the third value.

[0184] In some embodiments, the processor 410 is specifically configured to:

[0185] Multiply the prefetch window adjustment value and the prefetch window preset value by their respective corresponding weights to obtain a first weighted value and a second weighted value;

[0186] Add the first weighted value and the second weighted value to obtain a fusion value;

[0187] Based on the fusion value, determine the maximum value of the prefetch window.

[0188] In some embodiments, the processor 410 is specifically configured to:

[0189] When the fusion value meets the preset constraint conditions, determine the fusion value as the maximum value of the prefetch window;

[0190] When the fusion value does not meet the constraint conditions, determine the correction value as the maximum value of the prefetch window, and the correction value is the value closest to the fusion value and meeting the constraint conditions.

[0191] In some embodiments, the processor 410 is further configured to:

[0192] Before determining the maximum value of the prefetch window based on the prefetch window adjustment value and the prefetch window preset value, obtain at least two first prefetch window candidate values, and each first prefetch window candidate value is less than or equal to the single-request data volume threshold of the storage device in the electronic device;

[0193] Determine the target operating scenario corresponding to the user's usage habits;

[0194] For each first prefetch window candidate value, test the performance of the electronic device when using the first prefetch window candidate value in the target operating scenario to obtain a first performance parameter corresponding to the first prefetch window candidate value. The first performance parameter includes a first parameter related to the scenario performance of the electronic device and a second parameter related to the memory state of the electronic device;

[0195] Determine the first prefetch window candidate value with the optimal first performance parameter among the at least two first prefetch window candidate values as the prefetch window preset value of the electronic device.

[0196] In some embodiments, the processor 410 is further configured to:

[0197] Before determining the maximum prefetch window value based on the prefetch window adjustment value and the prefetch window preset value, determine a second prefetch window candidate value corresponding to the memory capacity configuration of the electronic device;

[0198] Determine the second prefetch window candidate value as the prefetch window preset value of the electronic device.

[0199] In some embodiments, the processor 410 is further configured to:

[0200] Before determining the maximum prefetch window value based on the prefetch window adjustment value and the prefetch window preset value, receive a third prefetch window candidate value sent by the server;

[0201] Determine the third prefetch window candidate value as the prefetch window preset value of the electronic device.

[0202] It should be understood that in the embodiments of the present application, the input unit 404 may include a graphics processing unit (GPU) 4041 and a microphone 4042. The graphics processing unit 4041 processes the image data of static pictures or videos obtained by an image capturing device (such as a camera) in a video capture mode or an image capture mode. The display unit 406 may include a display panel 4061, and the display panel 4061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 407 includes at least one of a touch panel 4071 and other input devices 4072. The touch panel 4071 is also referred to as a touch screen. The touch panel 4071 may include two parts: a touch detection device and a touch controller. The other input devices 4072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be elaborated here.

[0203] The memory 409 can be used to store software programs and various data. The memory 409 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area can store an operating system, application programs or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 409 can include volatile memory or non-volatile memory, or the memory 409 can include both volatile and non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synch link dynamic random access memory (SLDRAM), and a direct rambus random access memory (DRRAM). The memory 409 in the embodiments of the present application includes but is not limited to these and any other suitable types of memory.

[0204] The processor 410 may include one or more processing units; optionally, the processor 410 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor may not be integrated into the processor 410.

[0205] The embodiments of the present application also provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements each process of the above-mentioned embodiment of the file reading method and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0206] Among them, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs.

[0207] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above embodiment of the file reading method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0208] It should be understood that the chip mentioned in the embodiments of the present application can also be referred to as a system-on-chip, system chip, chip system, or system-on-chip.

[0209] The embodiments of the present application provide a computer program product. The program product is stored in a storage medium and is executed by at least one processor to implement each process of the above embodiment of the file reading method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0210] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0211] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described example methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0212] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative rather than restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.

Claims

1. A file reading method, characterized in that, including: When receiving a file reading request, determining a scenario metric related to the current running scenario of the electronic device; Based on the scenario metric, determining a maximum prefetch window value; Performing file reading based on the maximum prefetch window value.

2. The method according to claim 1, wherein The determining the scenario metric related to the current running scenario of the electronic device includes: Obtaining the current running scenario parameters of the electronic device, where the current running scenario parameters include at least two of the following: the file reading frequency in the current running scenario, the current available memory, the current read thread priority, and the current file to be read, and the current file to be read is the file indicated by the file reading request to be read; Performing quantization processing on the current scenario parameters to obtain at least two scenario metrics of the electronic device.

3. The method according to claim 2, wherein The at least two scenario metrics include at least two of the following: a first metric, a second metric, a third metric, and a fourth metric; The performing quantization processing on the current scenario parameters to obtain at least two scenario metrics of the electronic device includes at least two of the following: Based on the file reading frequency in the current running scenario, determining a first ratio of the number of consecutive reads to the total number of reads in the current running scenario, and determining the first ratio as the first metric; Calculating a second ratio of the current available memory to the maximum reserved available memory preset, and determining the second ratio as the second metric; Based on a preset first functional relationship, quantizing the current read thread priority as the third metric, where the first functional relationship is used to indicate the correspondence between the thread reading priority and the third metric; Matching the current file to be read with a preset file to obtain a file matching result, and based on the file matching result and a preset second functional relationship, quantizing the file matching result as the fourth metric, where the second functional relationship is used to indicate the correspondence between the file matching result and the fourth metric.

4. The method according to claim 2, wherein The based on the scenario metric, determining a maximum prefetch window value includes: Multiplying each scenario metric by its corresponding weight to obtain a weighted value of each scenario metric; Adding the weighted values of the at least two scenario metrics to obtain a window adjustment parameter; Based on the window adjustment parameter, determining a prefetch window adjustment value; ​ 5. The method according to claim 4, characterized in that ​ ​ ​ ​ ​ ​ 6. The method according to claim 4, characterized in that, ​ Multiply the pre-reading window adjustment value and the pre-reading window preset value by their respective corresponding weights to obtain a first weighted value and a second weighted value; Add the first weighted value and the second weighted value to obtain a fusion value; Based on the fusion value, determine the maximum value of the pre-reading window.

7. The method according to claim 6, characterized in that, The determining the maximum value of the pre-reading window based on the fusion value includes: When the fusion value satisfies a preset constraint condition, determine the fusion value as the maximum value of the pre-reading window; When the fusion value does not satisfy the constraint condition, determine a correction value as the maximum value of the pre-reading window, where the correction value is the value closest to the fusion value and satisfying the constraint condition.

8. The method according to any one of claims 4-7, characterized in that, Before determining the maximum value of the pre-reading window based on the pre-reading window adjustment value and the pre-reading window preset value, the method further includes: Obtain at least two first pre-reading window candidate values, each of the first pre-reading window candidate values being less than or equal to the single-request data volume threshold of the storage device in the electronic device; Determine a target running scenario corresponding to the user usage habit; For each of the first pre-reading window candidate values, test the performance of the electronic device when using the first pre-reading window candidate value in the target running scenario to obtain a first performance parameter corresponding to the first pre-reading window candidate value, where the first performance parameter includes a first parameter related to the scenario performance of the electronic device and a second parameter related to the memory state of the electronic device; Determine the first pre-reading window candidate value with the optimal first performance parameter among the at least two first pre-reading window candidate values as the pre-reading window preset value of the electronic device.

9. A file reading device, characterized in that, including: A determination module, configured to determine a scenario metric related to the current running scenario of the electronic device when receiving a file reading request; A processing module, configured to determine the maximum value of the pre-reading window based on the scenario metric; A reading module, configured to perform file reading based on the maximum value of the pre-reading window.

10. An electronic device, characterized in that, including a processor and a memory, where the memory stores a program or instruction that can run on the processor, and when the program or instruction is executed by the processor, the steps of the file reading method according to any one of claims 1-8 are implemented.