WO2021036370A1 - Method and device for pre-reading file page, and terminal device - Google Patents

Method and device for pre-reading file page, and terminal device Download PDF

Info

Publication number
WO2021036370A1
WO2021036370A1 PCT/CN2020/092247 CN2020092247W WO2021036370A1 WO 2021036370 A1 WO2021036370 A1 WO 2021036370A1 CN 2020092247 W CN2020092247 W CN 2020092247W WO 2021036370 A1 WO2021036370 A1 WO 2021036370A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
reading
page
memory
reading window
Prior art date
Application number
PCT/CN2020/092247
Other languages
French (fr)
Chinese (zh)
Inventor
孙秋阳
缪勰
童甜根
赵鸿江
方炜
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021036370A1 publication Critical patent/WO2021036370A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0862Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with prefetch
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management

Definitions

  • This application relates to computer technology, and in particular to a method, device and terminal device for pre-reading document pages.
  • the operating system is located between the underlying hardware and the user, and is the bridge between the two.
  • the user can input instructions through the user interface of the operating system.
  • the operating system parses the instructions and drives the hardware devices to meet user requirements.
  • the operating system can provide the following functions: process management, memory management, file system, network communication, security mechanism, user interface, and driver programs.
  • the file system is a method and data structure used in the operating system to specify files on storage devices (disks, solid state drives, etc.) or partitions, that is, a method for organizing files on storage devices.
  • some file pages can be read from the external memory (for example, a disk) to the memory through the file pre-reading method provided by the operating system for use by the application program.
  • the file pre-reading method can adjust the size of the pre-reading window according to the file access mode (sequential read or random read) according to certain rules. For example, sequential read will increase the pre-read window, random read will decrease, and the pre-read window will be All file pages are read into memory so that applications can quickly access file pages from memory.
  • the above file pre-reading method has the problem of pre-reading too many invalid file pages, that is, too many file pages that will not be accessed in the near future are pre-read into the memory, occupying too much memory space, and squeezing the application program of the terminal device.
  • the used memory space causes the terminal device to have slow response to application startup, freezes, etc., which affects the performance of the terminal device.
  • This application provides a method, device and terminal device for pre-reading document pages to improve the use performance of the terminal device.
  • the present application provides a method for pre-reading document pages.
  • the method may include: obtaining state parameter information, where the state parameter information is used to indicate at least one of a memory usage state or an input/output IO processing state;
  • the status parameter information determines the size of the file pre-reading window; according to the file pre-reading window, the corresponding file page is read from the external storage device to the memory. After the file page is read into the memory, it can be accessed by the application.
  • the size of the file pre-reading window can be adjusted adaptively based on the state parameter information, and then the pre-reading operation is performed according to the size of the file pre-reading window, and the file page size of the pre-reading operation is performed based on the size of the file pre-reading window.
  • the number is different, the file page of the pre-read operation occupies different memory resources, so as to realize the adaptive adjustment of the memory resource occupancy of the pre-read operation. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window.
  • the read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
  • the achievable way of determining the size of the file pre-reading window according to the state parameter information includes: when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level, reducing Reduce the size of the file pre-reading window; when the status parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the second level, increase the size of the file pre-reading window; where the first level The memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
  • the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level, it indicates that the memory usage pressure is greater and/or the IO processing pressure is greater, and the size of the file pre-reading window is reduced.
  • the status parameter information indicates memory usage pressure or IO processing pressure
  • the state parameter information may include at least one of a memory parameter or an IO parameter
  • the memory parameter includes at least one of a memory footprint, a memory usage rate, or a cumulative number of page faults
  • the IO parameter includes IO queue length.
  • the usage status of the memory resource can be determined according to the memory parameter and/or the IO parameter, and the occupation of the memory resource by the pre-reading operation is adaptively adjusted based on this, so as to improve the usage performance of the terminal device.
  • the achievable manner of determining the size of the file pre-reading window according to the state parameter information includes: determining the first index according to at least one of the memory parameter and the IO parameter. The size of the file pre-reading window is determined according to the first indicator.
  • an achievable way of determining the size of the file pre-reading window according to the first index includes: determining the numerical range to which the first index belongs according to the first index.
  • the window size corresponding to the numerical interval to which the first indicator belongs is used as the size of the file pre-reading window.
  • an achievable way of reading the corresponding file page from the external storage device to the memory according to the file pre-reading window includes: selecting at least one file in the file pre-reading window according to the pre-reading model Page, read the at least one file page from the external storage device into the memory.
  • the pre-reading model is a data structure in the memory determined according to at least one of file access real-time data and file access historical data, the pre-reading model corresponds to the file, and the file access real-time data is not synchronized with the file access historical data ,
  • the file access history data is the data in the external storage device.
  • the pre-reading model since the pre-reading model is determined based on at least one of file access real-time data and file access historical data, the pre-reading model records the access records of file pages, and the pre-reading model can be used to increase pre-reading hits It improves the probability that the file page read from the external storage device to the memory is accessed by the application layer, thereby reducing invalid pre-reading and reducing the waste of memory resources.
  • the pre-reading model includes N bits, each bit corresponds to a file page of the file, and each bit is used to indicate whether the file page corresponding to the bit is accessed, and N is An integer greater than or equal to 1.
  • the method may further include: determining whether the number of segments formed by the at least one file page is greater than a first threshold. If the number of fragments formed by the at least one file page is greater than the first threshold, all file pages in the file pre-reading window are read from the external storage device into the memory. If the number of segments formed by the at least one file page is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is performed.
  • reading all the file pages in the file pre-reading window from the external storage device to the memory may include: judging whether the bit corresponding to the last file page of the file pre-reading window indicates the last one The file page is accessed. When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device to In memory. When the bit corresponding to the last file page indicates that the last file page has not been accessed, all file pages in the file pre-reading window are read from the external storage device to the memory; among them, after the file pre-reading window At least one file page of the file belongs to the same segment as the last file page of the file pre-reading window.
  • the file page belonging to the same segment as the last file page is read into the memory to avoid the pre-reading window.
  • the boundary division causes I/O fragmentation (that is, some pages in the same fragment are divided outside the window, and will be read again when accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
  • reading the at least one file page from the external storage device into the memory may include: determining whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed .
  • the bit corresponding to the last file page indicates that the last file page is accessed
  • the at least one file page and the at least one file page after the file pre-reading window are read from the external storage device into the memory.
  • the bit corresponding to the last file page indicates that the last file page has not been accessed
  • the at least one file page is read from the external storage device into the memory.
  • at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  • the file page belonging to the same segment as the last file page is read into the memory to avoid the pre-reading window.
  • the boundary division causes I/O fragmentation (that is, some pages in the same fragment are divided outside the window, and will be read again when accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
  • the file access history data includes at least one of the location, length, or time of the read access request before the file is opened this time, and the file access real-time data includes the read access after the file is opened this time. At least one of the location, length, or time of the access request.
  • the method may further include: updating the file access history data corresponding to the file in the external storage device according to the pre-reading model.
  • the acquiring state parameter information may include: acquiring the state parameter information when the pre-fetching of the document page is triggered; or, acquiring the state parameter information in a preset period.
  • an embodiment of the present application provides an apparatus for pre-reading document pages.
  • the apparatus may include: a status acquisition module for acquiring status parameter information, the status parameter information being used to indicate memory usage status or input/output IO processing At least one of the status.
  • the pre-reading window determination module is used to determine the size of the file pre-reading window according to the state parameter information; the pre-reading module is used to read the corresponding file page from the external storage device to the memory according to the file pre-reading window for supply Layer to access the file page.
  • the pre-reading window determination module is used to reduce the size of the file pre-reading window when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level;
  • the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the second level
  • the size of the file pre-reading window is increased; wherein the memory usage pressure or the IO processing pressure of the first level is greater than This second level of memory usage pressure or IO processing pressure.
  • the pre-reading window determination module is used to determine the first index according to at least one of the memory parameter and the IO parameter.
  • the size of the file pre-reading window is determined according to the first indicator.
  • the pre-reading window determination module is used to determine the numerical interval to which the first index belongs according to the first index.
  • the window size corresponding to the numerical interval to which the first indicator belongs is used as the size of the file pre-reading window.
  • the pre-reading module is used to select at least one file page in the file pre-reading window according to the pre-reading model, and read the at least one file page from the external storage device into the memory.
  • the pre-reading model is a data structure determined based on at least one of file access real-time data and file access historical data.
  • the pre-reading model corresponds to the file.
  • the file access real-time data is not synchronized with the file access history data.
  • the access history data is the data in the external storage device.
  • the pre-reading module is further used to determine whether the number of fragments formed by the at least one file page is greater than a first threshold. If the number of fragments constituted by the at least one file page is greater than the first threshold, all file pages in the file pre-reading window are read from the external storage device into the memory; if the fragments constituted by the at least one file page If the number of is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is executed.
  • the pre-reading module is used to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed; when the bit corresponding to the last file page Indicates that when the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device into the memory; when the last file page corresponds The bit indicates that when the last file page is not accessed, all file pages in the file pre-reading window are read from the external storage device to the memory; among them, at least one file page after the file pre-reading window and the The last file page of the file pre-reading window belongs to the same segment.
  • the pre-reading module is used to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed; when the bit corresponding to the last file page Indicates that when the last file page is accessed, the at least one file page and at least one file page after the file pre-reading window are read from the external storage device into the memory; when the bit corresponding to the last file page indicates the When the last file page is not accessed, the at least one file page is read from the external storage device into the memory; wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window Belong to the same segment.
  • the pre-reading module is further used to update the file access history data corresponding to the file in the external storage device according to the pre-reading model.
  • the state obtaining module is used to obtain the state parameter information when the pre-fetching of the document page is triggered; or, to obtain the state parameter information in a preset period.
  • the device for pre-reading document pages may be a terminal device or an internal chip of the terminal device.
  • this application provides a terminal device, including: one or more processors; a memory, used to store one or more programs; when the one or more programs are executed by the one or more processors , Enabling the one or more processors to implement the method according to any one of the foregoing first aspects.
  • the present application provides a computer-readable storage medium, including a computer program, which when executed on a computer, causes the computer to execute the method described in any one of the above-mentioned first aspects.
  • the present application provides a computer program or a computer program product containing a computer program, when the computer program is executed by a computer, it is used to execute the method described in any one of the above-mentioned first aspects.
  • the present application provides a chip including a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the above-mentioned first aspect The method of any one of.
  • the method, device, and terminal device for pre-reading document pages of the present application obtain status parameter information, which can be used to indicate at least one of the memory usage status or the I/O processing status, and the file pre-determination is determined according to the status parameter information.
  • the size of the read window read the corresponding file page from the external storage device to the memory according to the file pre-read window, and access the file page by the application layer.
  • the size of the file pre-read window can be adjusted adaptively based on the state parameter information, and then according to The size of the file pre-reading window is used for pre-reading operations, the number of file pages for pre-reading operations based on the size of different file pre-reading windows is different, and the file pages for pre-reading operations occupy different memory resources, thereby achieving adaptive adjustment Occupation of memory resources by pre-reading operations. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window.
  • the read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
  • FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the application.
  • FIG. 2 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application.
  • FIG. 3 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application
  • 4A is a flowchart of a method for pre-reading document pages according to an embodiment of the application.
  • 4B is a schematic diagram of a file pre-reading window according to an embodiment of the application.
  • FIG. 5 is a flowchart of another method for pre-reading document pages according to an embodiment of the application.
  • 6A is a flowchart of another method for pre-reading document pages according to an embodiment of the application.
  • 6B is a schematic diagram of a pre-fetched document page according to an embodiment of the application.
  • FIG. 7 is a flowchart of another method for pre-reading document pages according to an embodiment of the application.
  • FIG. 8 is a schematic structural diagram of another terminal device according to an embodiment of the application.
  • At least one (item) refers to one or more, and “multiple” refers to two or more.
  • “And/or” is used to describe the association relationship of associated objects, indicating that there can be three types of relationships, for example, “A and/or B” can mean: only A, only B, and both A and B , Where A and B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an “or” relationship.
  • the following at least one item (a) or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a).
  • At least one of a, b, or c can mean: a, b, c, "a and b", “a and c", “b and c", or "a and b and c" ", where a, b, and c can be single or multiple.
  • the method for pre-reading document pages provided by the embodiments of this application can be applied to mobile phones, tablet computers, notebook computers, ultra-mobile personal computers (UMPC), handheld computers, netbooks, and personal digital assistants (personal digital assistants).
  • UMPC ultra-mobile personal computers
  • personal digital assistants personal digital assistants
  • terminal devices such as digital assistant (PDA), wearable electronic devices, and virtual reality devices
  • the embodiments of the present application do not impose any limitation on this.
  • FIG. 1 shows a schematic structural diagram of a terminal device 100.
  • the terminal device 100 may include: an application processor 101, a microcontroller unit (microcontroller unit, MCU) 103, a memory 105, a modem (modem) 107, a radio frequency (RF) module 109, and a wireless fidelity (Wireless-Fidelity, (Referred to as Wi-Fi) module 111, Bluetooth module 113, sensor 114, positioning module 150, input/output (input/output, I/O) device 115 and other components. These components can communicate through one or more communication buses or signal lines.
  • the terminal device 100 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. Layout.
  • the application processor 101 is the control center of the terminal device 100, and uses various interfaces and buses to connect various components of the terminal device 100.
  • the application processor 101 may include one or more processing units.
  • the memory 105 stores computer programs, such as the operating system 161 and application programs 163 shown in FIG. 1.
  • the application processor 101 is configured to execute a computer program in the memory 105 to implement functions defined by the computer program.
  • the application processor 101 executes an operating system 161 to implement various functions of the operating system on the terminal device 100.
  • the memory 105 also stores other data besides computer programs, such as data generated during the running of the operating system 161 and the application program 163.
  • the memory 105 may include internal memory and external memory.
  • Memory includes but is not limited to random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), or cache (cache).
  • External storage includes but is not limited to flash memory (flash memory), hard disks, optical disks, universal serial bus (USB) disks, etc.
  • Computer programs are usually stored in external memory, and the processor loads the program from external memory to memory before executing the computer program.
  • the memory 105 may be independent and connected to the application processor 101 through a bus; the memory 105 and the application processor 101 may also be integrated into a chip subsystem.
  • MCU 103 is a co-processor used to acquire and process data from the sensor 114.
  • the processing power and power consumption of MCU 103 are less than that of the application processor 101, but it has the feature of "always on” and can be used in the application processor.
  • 101 continuously collects and processes sensor data when it is in sleep mode to ensure the normal operation of the sensor with extremely low power consumption.
  • the sensor 114 may include a light sensor, a motion sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
  • the MCU 103 and the sensor 114 may be integrated on the same chip, or may be separate components, connected by a bus.
  • the modem 107 and the radio frequency module 109 constitute the communication subsystem of the terminal device 100, which is used to implement the main functions of the wireless communication standard protocols such as 3GPP and ETSI. Among them, Modem 107 is used for encoding and decoding, signal modulation and demodulation, and equalization.
  • the radio frequency module 109 is used for receiving and transmitting wireless signals.
  • the radio frequency module 109 includes but is not limited to an antenna, at least one amplifier, a coupler, a duplexer, and the like. The radio frequency module 109 cooperates with the Modem 107 to realize the wireless communication function.
  • the terminal device 100 may also use the Wi-Fi module 111, the Bluetooth module 113, etc. to perform wireless communication.
  • the Wi-Fi module 111 is used to provide the terminal device 100 with network access that complies with Wi-Fi related standard protocols.
  • the terminal device 100 can access a Wi-Fi access point through the Wi-Fi module 111 to access the Internet.
  • the Wi-Fi module 111 can also be used as a Wi-Fi wireless access point, which can provide Wi-Fi network access for other terminal devices.
  • the Bluetooth module 113 is used to implement short-distance communication between the terminal device 100 and other terminal devices (such as mobile phones, smart watches, etc.).
  • the Wi-Fi module 111 in the embodiment of the present application may be an integrated circuit or a Wi-Fi chip or the like, and the Bluetooth module 113 may be an integrated circuit or a Bluetooth chip or the like.
  • the positioning module 150 is used to determine the geographic location of the terminal device 100. It is understandable that the positioning module 150 may specifically be a positioning system such as a global positioning system (GPS), a global navigation satellite system (GLONASS), or a Beidou satellite navigation system (BDS). Receiver.
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou satellite navigation system
  • the Wi-Fi module 111, the Bluetooth module 113, and the positioning module 150 may be separate chips or integrated circuits, respectively, or they may be integrated together.
  • the Wi-Fi module 111, the Bluetooth module 113 and the positioning module 150 may be integrated on the same chip.
  • the Wi-Fi module 111, the Bluetooth module 113, the positioning module 150, and the MCU 103 may also be integrated into the same chip.
  • the input/output device 115 includes, but is not limited to: a display 151, a touch screen 153, an audio circuit 155, and so on.
  • the touch screen 153 can collect touch events on or near the user of the terminal device 100 (for example, the user uses a finger, a stylus, or any other suitable object to operate on the touch screen 153 or near the touch screen 153), and Send the collected touch events to other devices (for example, the application processor 101).
  • the display (also called a display screen) 151 is used to display information input by the user or information presented to the user.
  • the display can be configured in the form of a liquid crystal display, an organic light-emitting diode, etc.
  • the audio circuit 1155, the speaker 116, and the microphone 117 may provide an audio interface between the user and the terminal device 100.
  • the audio circuit 109 can transmit the electric signal after the conversion of the received audio data to the speaker 113, which is converted into a sound signal by the speaker 113 for output; on the other hand, the microphone 114 converts the collected sound signal into an electric signal, and the audio circuit 109 After being received, the audio data is converted into audio data, and then the audio data is sent to, for example, another terminal device through the Modem 107 and the radio frequency module 109, or the audio data is output to the memory 105 for further processing.
  • the terminal device 100 may also have a fingerprint recognition function.
  • a fingerprint collection device may be configured on the back of the terminal device 100 (for example, below the rear camera), or a fingerprint collection device may be configured on the front of the terminal device 100 (for example, below the touch screen 153).
  • the operating system 161 carried by the terminal device 100 may be Or other operating systems, this embodiment of the application does not impose any restriction on this.
  • the terminal device 100 of the operating system is taken as an example.
  • the terminal device 100 can be logically divided into a hardware layer 21, an operating system 161, and an application layer 31.
  • the hardware layer 21 includes hardware resources such as the application processor 101, the microcontroller unit 103, the memory 105, the Modem 107, the Wi-Fi module 111, the sensor 114, and the positioning module 150 as described above.
  • the application layer 31 includes one or more applications, such as an application 163.
  • the application 163 may be any type of application such as a social application, an e-commerce application, or a browser.
  • the operating system 161, as a software middleware between the hardware layer 21 and the application layer 31, is a computer program that manages and controls hardware and software resources.
  • the operating system 161 includes a kernel 23, a hardware abstraction layer (HAL) 25, a library and runtime (libraries and runtime) 27, and a framework 29.
  • the kernel 23 is used to provide underlying system components and services, such as: power management, memory management, file system management, thread management, hardware drivers, etc.; hardware drivers include Wi-Fi drivers, sensor drivers, positioning module drivers, etc.
  • the hardware abstraction layer 25 encapsulates the kernel driver, provides an interface to the framework 29, and shields low-level implementation details.
  • the hardware abstraction layer 25 runs in the user space, and the kernel driver runs in the kernel space.
  • the library and runtime 27 is also called the runtime library, which provides the required library files and execution environment for the executable program at runtime.
  • the framework 29 is used to provide various basic public components and services for applications in the application layer 31, such as window management, location management, and so on.
  • the functions of the various components of the operating system 161 described above can all be implemented by the application processor 101 executing a program stored in the memory 105.
  • the hardware layer 21 may include a memory 1051 and an external memory 1052.
  • the kernel 23 may include a memory management 231 and a file system management 232.
  • the application processor 101 of the embodiment of the present application may be configured to execute the computer program in the memory 105, thereby implementing the method for pre-reading file pages in the embodiment of the present application , So that the memory management 231 can dynamically adjust the size of the file pre-reading window based on the status parameter information.
  • the memory management 231 issues a pre-reading request to the file system management 232 based on the size of the file pre-reading window, and the file system management 232 will assign the corresponding file Pages are read from the external storage 1052 into the memory 1051, thereby improving the performance of the terminal device 100.
  • external memory may also be referred to as an external memory.
  • the terminal 100 may include fewer or more components than those shown in FIG. 1, and the terminal device shown in FIG. 1 only includes those that are more relevant to the multiple implementations disclosed in the embodiments of the present application. part.
  • file refers to a collection of information stored on a terminal device using a memory as a carrier. Files can be text documents, pictures, audio and video, executable programs, and so on.
  • the “file page” mentioned in this application refers to the constituent unit of the file.
  • the operating system can perform I/O to the file in the unit of the file page to facilitate memory management.
  • the file as described above may include one or more file pages, and the size of each file page is equal, for example, it may be 4 kilobytes (KB). Each document page corresponds to a different serial number.
  • FIG. 4A is a flowchart of a method for pre-reading document pages according to an embodiment of the application. As shown in FIG. 4A, the method in this embodiment may be executed by a terminal device or a processor of the terminal device, and the processor may be an application processor. Device. The method can include:
  • Step 101 Obtain status parameter information.
  • the status parameter information can be used to indicate at least one of the memory usage status or the I/O processing status.
  • the memory usage state can be understood as the occupancy of the memory by the computer program, data generated during the running of the computer program, cached data (for example, cache file pages), etc., and can also be understood as the situation where the memory is available for use.
  • the I/O processing status can be understood as the processing status of the I/O request, for example, the number of I/O requests that need to be processed.
  • the state parameter information may include at least one of a memory parameter or an I/O parameter.
  • the memory parameter may include at least one of memory usage, memory usage, or cumulative number of page faults.
  • the I/O parameter may include at least one of the length of the I/O queue or the amount of I/O request data.
  • the above-mentioned state parameter information may be obtained when the pre-fetching of the document page is triggered; or, the above-mentioned state parameter information may be obtained in a preset period.
  • the way to trigger the pre-reading of the file page may be to determine whether the page is missing when processing the file page read request issued by the user mode.
  • the page missing refers to the file page that needs to be read is not in the memory.
  • Page the pre-fetching of the file page is triggered.
  • This method of pre-fetching the file page can also be called synchronous pre-reading, that is, the file pre-reading window includes the currently accessed file page.
  • Another way to trigger pre-fetching file pages can be to pre-read part of the file pages after the currently accessed file page in the sequential read scenario.
  • This method of pre-fetching file pages can also be called asynchronous pre-reading, that is, It is also possible to pre-read part of the pages after the currently accessed file page when there is no page fault.
  • the application layer 31 can read the file page through system calls such as read(), mmap(), etc.
  • the operating system 161 can determine whether to trigger the pre-fetching of the file page in the above-mentioned manner.
  • the memory management 231 shown in FIG. 3 can obtain the state parameter information.
  • Step 102 Determine the size of the file pre-reading window according to the state parameter information.
  • the file pre-reading window is used to represent a collection of one or more file pages in a file.
  • a specific form of the file pre-reading window may be a set of consecutive file page numbers, and the other A specific form can be the start file page number and the end file page number.
  • Another specific form of the file pre-reading window can be the start file page number and the window length.
  • the unit of the window length is the file page, which needs to be explained.
  • the file pre-reading window may also be in other specific forms, such as the length of the window and the sequence number of the ending file page, etc.
  • the embodiments of this application will not illustrate one by one.
  • the file pre-reading window is schematically illustrated in Figure 4B. As shown in Figure 4B, the file pre-reading window 1 starts from the first file page to the end of the fourth file page, and the file pre-read window 2 starts from the first file page. The document page starts to the end of the 6th document page.
  • the embodiment of the present application can determine the size of the file pre-reading window, that is, the window length, according to the state parameter information, and the window length can be the number of file pages included in the file pre-reading window, for example, the file shown in FIG. 4B
  • the window length of the pre-reading window 1 is 4.
  • the size of the file pre-reading window can be determined to be a small value, such as the file pre-reading window 1 shown in Figure 4B, so that the memory usage pressure When it is larger, reduce the pre-fetched file pages.
  • the size of the file pre-reading window can be determined to be a larger value, such as the file pre-reading window 2 shown in FIG. 4B, so that when the memory space is free, Increase the pre-read file page.
  • the size of the file pre-reading window is reduced; when the state parameter information indicates the memory usage pressure or IO When at least one of the processing pressures is at the second level, the size of the file pre-reading window is increased; wherein the first level of memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
  • the first level may refer to a level where memory usage pressure and/or IO processing pressure is relatively high
  • the second level may refer to a level where memory use pressure and/or IO processing pressure is relatively high. For example, if the aforementioned memory usage is greater than the preset threshold, the memory usage pressure is at the first level, and if the memory usage is less than the preset threshold, the memory usage pressure is at the second level.
  • One achievable way to reduce the size of the file pre-reading window above can be to reset the size of the file pre-reading window to a value that is smaller than the original size, and another achievable way can be to reset the size of the file pre-reading window to a value smaller than the original size.
  • the size of the file pre-reading window is reduced by a value on the original basis.
  • the position of the file pre-reading window can be determined according to the position of triggering the pre-reading of the document page, for example, it can be determined according to the position of the page missing, which is not limited in the embodiment of the present application.
  • the memory management 231 shown in FIG. 3 can determine the size of the file pre-reading window according to the state parameter information.
  • Step 103 Read the corresponding file page from the external storage device into the memory according to the file pre-reading window, so as to access the file page by the application layer.
  • the memory management 231 shown in FIG. 3 may issue a pre-reading request to the file system management 232 based on the size of the file pre-reading window, and the file system management 232 will assign the corresponding file The page is read from the external memory 1052 to the memory 1051.
  • the embodiment of the present application pre-reads the corresponding file pages based on the file pre-reading window, which can reduce the pre-read file pages when the memory usage pressure is high and/or the I/O processing pressure is high.
  • the memory usage pressure is low and/or the I/O processing pressure is low, increase the pre-fetched file pages. That is, the occupation of memory resources by the pre-reading operation can be adaptively adjusted based on the file pre-reading window, so as to improve the use performance of the terminal device.
  • the status parameter information can be used to indicate at least one of the memory usage status or the I/O processing status.
  • the size of the file pre-reading window is determined according to the status parameter information, and the file pre-reading window is read from The external storage device reads the corresponding file page into the memory, and accesses the file page by the application layer. It can adaptively adjust the size of the file pre-reading window based on the state parameter information, and then perform the pre-reading operation according to the size of the file pre-reading window.
  • the number of file pages for pre-reading operations based on the size of different file pre-reading windows is different, and the file pages for pre-reading operations occupies different memory resources, so as to achieve adaptive adjustment of the pre-reading operation's occupancy of memory resources. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window.
  • the read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
  • FIG. 5 is a flowchart of another method for pre-reading document pages according to an embodiment of this application. As shown in FIG. 5, the method in this embodiment may be executed by a terminal device or a processor of a terminal device.
  • the information includes memory parameters and I/O parameters as examples.
  • the method can include:
  • Step 201 Obtain memory parameters and I/O parameters.
  • Step 202 Determine a first index according to the memory parameter and the I/O parameter.
  • the first index may be determined by means of summation, weighted summation, etc. for memory parameters and I/O parameters, and the first index may also be referred to as a comprehensive pressure index.
  • X represents the value of the first indicator. The larger the value of X, the greater the memory usage pressure and/or the I/O processing pressure, that is, the higher the memory usage rate and/or the I/O queue. The greater the length. Of course, it is understandable that the smaller the value of X can also be set, which means the greater the memory usage pressure and/or the I/O processing pressure, that is, the higher the memory usage and/or the larger the length of the I/O queue. In the embodiment of the present application, the larger the value of X, the larger the memory usage pressure and/or the I/O processing pressure is taken as an example for illustration.
  • Step 203 Determine the size of the file pre-reading window according to the first indicator.
  • the memory management 231 shown in FIG. 3 may determine the size of the file pre-reading window according to the first indicator.
  • n thresholds can divide the value range of X into (n+1) numerical intervals, the (n+1) The numerical interval can be: [0, X1], (X1, X2], ising, (Xn, ⁇ ), set each numerical interval to correspond to a window size, and the above (n+1) numerical intervals correspond to the corresponding window sizes in order Reduce.
  • One possible implementation of the above step 203 is to determine the numerical interval to which the first indicator belongs according to the first indicator, and use the window size corresponding to the numerical interval to which the first indicator belongs as the size of the file pre-reading window.
  • Step 204 Read the corresponding file page from the external storage device into the memory according to the file pre-reading window, so as to access the file page by the application layer.
  • step 204 refers to step 103 of the embodiment shown in FIG. 4A, which will not be repeated here.
  • the first index is determined according to the memory parameters and I/O parameters
  • the size of the file pre-reading window is determined according to the first index
  • the file pre-reading window is read from the external storage device according to the first index.
  • Corresponding file pages are stored in the memory, and the file pages are accessed at the application layer to achieve adaptive adjustments based on memory parameters and I/O parameters on the occupation of memory resources by pre-reading operations.
  • the memory usage pressure is high and/or I/O processing When the pressure is high, the size of the pre-reading window is reduced, thereby reducing the file pages read in the pre-reading operation, so as to alleviate the slow response and freezing of the application startup, thereby improving the use performance of the terminal device.
  • the embodiments of the present application can also use the pre-reading model to increase the pre-reading hit rate, that is, to increase the probability that the file page read from the external storage device into the memory is accessed by the application layer, thereby reducing invalidity.
  • Pre-reading For the specific implementation, please refer to the explanation of the following examples.
  • One possible implementation of the above step 103 or the above step 204 is: select at least one file page in the file pre-reading window according to the pre-reading model as the pre-read page, and read the pre-read page from the external storage device to the memory
  • the pre-reading model is a data structure in the memory determined based on the file access real-time data and the file access historical data.
  • the pre-reading model corresponds to the file.
  • the file access real-time data is not synchronized with the file access historical data.
  • the file access history data is the data in the external storage device.
  • the file access history data may include at least one of the location, length, or time of the read access request before the file is opened this time.
  • the file access history data may come from an external storage device.
  • the file access history data may include the file page number of the file accessed by the application layer before the file is opened this time.
  • the file access history data may include 2 , 3, and 10, which means that the application layer has accessed the file pages with serial numbers 2, 3, and 10 before opening the file this time.
  • the file access real-time data may include at least one of the location, length, or time of the read access request after the file is opened this time.
  • the file access real-time data may include the reading after the file is opened this time to before the file is closed this time.
  • At least one of the location, length, or time of the access request, that is, the file access real-time data is the data generated in the process of accessing the file by the application layer.
  • the file access real-time data may include the file accessed by the application layer.
  • the file page sequence number of the file may include 1, 2, and 10, which means that the application layer has accessed the file page of the file with sequence numbers 1, 2, and 10.
  • the above-mentioned file access history data and the above-mentioned file access real-time data may also be bitmaps.
  • the file access history data may include 2, 3, and 10, assuming that there are 11 files corresponding to the file access history data.
  • File page, the file access history data can be 01100000010.
  • the pre-reading model is a data structure in the memory determined according to at least one of the file access real-time data and the file access historical data. It is an achievable way.
  • the pre-reading model may be a bitmap.
  • the pre-reading model may be a bitmap.
  • the read model may include N bits, each bit corresponds to a file page of the file, and each bit is used to indicate whether the file page corresponding to the bit is accessed, and N is an integer greater than or equal to 1. When the bit is set to 0, it indicates that the corresponding file page has not been accessed. When the bit is set to 1, it means that the corresponding file page has been accessed. Of course, understandable, you can also use the bit to set 1 to indicate that the corresponding file page has not been accessed.
  • the bit when the bit is set to 0, it indicates that the corresponding file page has been accessed. In the embodiment of the present application, when the bit is set to 0, it indicates that the corresponding file page has not been accessed, and when the bit is set to 1, it indicates that the corresponding file page has been accessed as an example for illustration. Visited or unvisited means that the application has been visited or has not been visited during the startup or running of the application. Taking file A includes 15 file pages, and the first, second, third, and tenth file pages have been accessed (including historical and real-time) as an example, the pre-reading model of file A may be 111000000100000.
  • the document pre-reading window is determined based on the state parameter information in the embodiment of the application, one or more document pages can be selected as the pre-reading page in the document pre-reading window based on the pre-reading model, and the pre-reading page is externally selected.
  • the storage device is read into the memory.
  • the pre-reading model of file A as an example of 111000000100000 for further illustration
  • the file pre-reading window determined by the above embodiment starts from the first file page, and the window length is 11, which can be selected according to the pre-reading model of file A
  • the first, second, third, and tenth file pages in the file pre-reading window are used as pre-fetch pages.
  • the first, second, third, and tenth file pages are read from the external storage device to the internal memory.
  • the remaining file pages in the file pre-reading window do not perform pre-reading operations, thereby reducing the memory occupation of pre-reading operations and reducing invalid pre-reading.
  • FIG. 6A is a flowchart of another method for pre-reading document pages according to an embodiment of this application. As shown in FIG. 6A, the method in this embodiment may be executed by a terminal device or a processor of a terminal device, and the method in this embodiment may include:
  • Step 301 Obtain status parameter information.
  • Step 302 Determine the size of the file pre-reading window according to the status parameter information.
  • step 301 and step 302 please refer to step 101 and step 102 of the embodiment shown in FIG. 4A, which will not be repeated here.
  • Step 303 Select at least one document page in the document pre-reading window according to the pre-reading model as the pre-read page.
  • Step 304 Determine whether the number of fragments formed by the pre-fetched page is greater than the first threshold, if yes, execute step 305, and if not, execute step 306.
  • fragment refers to a number of consecutive document pages in a document.
  • the embodiment of the present application can determine the final pre-read document page based on the number of fragments constituted by the pre-read page, and select the document A as described above.
  • the first, second, third, and tenth document pages are taken as the pre-read page as an example for further illustration.
  • the first, second, and third document pages can constitute a fragment, and the tenth page is a fragment. Therefore, the pre-read page
  • the number of fragments formed by the read page is 2, and the number (2) of fragments formed by the pre-read page is compared with the first threshold.
  • the file is read through the following step 305 Pre-read all pages in the window, for example, read the first to eleventh file pages of file A. If it is less than or equal to, read the pre-read file pages through the following step 306, for example, read the file Pages 1, 2, 3, and 10 of A.
  • the value of the first threshold can be 3, 4, 5, etc., which can be flexibly set according to requirements. The first threshold may also be dynamically adjusted according to the current memory usage status and/or I/O processing status.
  • Step 305 Read all file pages in the file pre-reading window from the external storage device into the memory.
  • the number of fragments constituted by the pre-fetched page is greater than the first threshold, that is, the number of fragments is large. Since a large number of fragments will cause I/O fragmentation and affect the efficiency of I/O processing, this application In the embodiment, when the number of fragments is large, all file pages in the file pre-reading window are read from the external storage device into the memory to avoid I/O fragmentation.
  • Step 306 Read the pre-fetched page from the external storage device into the memory.
  • the pre-fetch page can be read from the external storage device into the memory, and the file pre-fetch window except for the pre-fetch page
  • the remaining file pages do not perform pre-reading operations, thereby reducing the memory occupation of pre-reading operations and reducing invalid pre-reading.
  • the method of the embodiment of the present application may also determine whether to read the file page outside the file pre-reading window according to the bit corresponding to the last file page in the file pre-reading window. Take it to the memory. For example, according to the pre-reading model, if the bit value corresponding to the last file page in the file pre-reading window is 1, you can go beyond the range of the file pre-reading window and continue to check the bit value corresponding to each file page in turn. , Until a complete segment is determined (that is, the first bit with a value of 0 after the pre-reading window is found, or the last page of the file is checked), and all of the file pages are read into the memory. A second threshold can also be set.
  • an achievable manner of the above step 305 is to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed.
  • the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device into the memory.
  • the bit corresponding to the last file page indicates that the last file page has not been accessed, all file pages in the file pre-reading window are read from the external storage device into the memory.
  • at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  • an achievable way to read all the file pages in the file pre-reading window and at least one file page after the file pre-reading window from the external storage device into the memory is to read all the file pages in the file pre-reading window.
  • the file page and the M file pages in at least one file page after the file pre-reading window are read from the external storage device into the memory.
  • the M may represent the second threshold.
  • an implementation manner of the above step 306 is to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed.
  • the bit corresponding to the last file page indicates that the last file page is accessed, read the pre-read page and at least one file page after the file pre-read window from the external storage device into the memory.
  • the bit corresponding to the last file page indicates that the last file page has not been accessed, the pre-fetched page is read from the external storage device into the memory.
  • at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  • an achievable way of reading the pre-fetch page and at least one file page after the file pre-reading window from the external storage device into the memory is to read the pre-fetch page and at least one file page after the file pre-reading window.
  • the M file pages in one file page are read from the external storage device into the memory.
  • the pre-reading model of file B is 10101100, and the file pre-reading window is the first to fifth file pages.
  • the black square indicates that the corresponding bit of the pre-reading model is 1.
  • the white square indicates that the corresponding bit of the pre-reading model is 0.
  • the pre-reading in the file pre-reading window can be Pages (the first, third, and fifth file pages) and at least one file page after the file pre-reading window (for example, the sixth file page) are read from the external storage device into the memory.
  • the size of the file pre-reading window is determined according to the status parameter information, and at least one file page in the file pre-reading window is selected according to the pre-reading model as the pre-read page, and the location of the pre-read page Whether the number of fragments constituted is greater than the first threshold, if yes, read all file pages in the file pre-reading window from the external storage device to the memory, if not, read the pre-fetched pages from the external storage device In the memory, it realizes the occupancy of memory resources by adaptively adjusting the pre-reading operation based on the state parameter information, which can alleviate the slow response and stalling of the application startup, thereby improving the performance of the terminal device.
  • the file page belonging to the same fragment as the last file page is read into the memory to avoid the division of the pre-reading window boundary I/O fragmentation (that is, some pages in the same fragment are divided out of the window, and will be read again when they are accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
  • the method for pre-reading file pages of the present application can also update the file access history data corresponding to the file in the external storage device according to the foregoing pre-reading model. It should be noted that before using the pre-reading model to update, the file access history data corresponding to the file can be empty.
  • An achievable way is to periodically update the file access history data corresponding to the file in the external storage device according to the pre-reading model through the kernel thread.
  • the external storage device can allocate different read-write paths for different files, and the storage space corresponding to the read-write path stores file access history data corresponding to one file.
  • the file system management 232 can read the file access history data from the storage space corresponding to the file read and write path into the memory to determine the pre-read based on the file access history data and the file access real-time data model. After the pre-read operation, the file system management 232 can write the pre-read model into the storage space corresponding to the read/write path of the file in the same format as the file access history data, that is, update the file access history data stored in the storage space .
  • FIG. 7 is a flowchart of another method for pre-reading document pages according to an embodiment of the application. As shown in FIG. 7, this embodiment uses the application layer 31 and the operating system 161 as examples to explain the method of the embodiment of the application. The method of this embodiment may include:
  • Step 401 The application layer triggers to open a file.
  • an application in the application layer when it starts, it triggers the opening of a file.
  • Step 402 Create an initialized pre-reading model.
  • creating an initialized pre-reading model can be to generate a bitmap containing N bits, and the initial values of the N bits are all 0.
  • Step 403 Determine whether there is file access history data in the storage space corresponding to the read-write path corresponding to the file, if yes, execute step 404, and if not, end.
  • Step 404 Read the file access history data into the memory, and fill the initialized pre-reading model after parsing the file access history data.
  • the value of the first, second, third, and tenth bit of the above N bits can be updated to 1. .
  • Step 405 The application layer triggers access to a file page of the file.
  • the application layer can read a file page through system calls such as read() and mmap().
  • Step 406 Record the information of accessing the file page into the pre-reading model.
  • the value of the fourth bit of the above N bits is updated to 1, and the updated pre-reading model is 11110000010000....
  • Step 407 Determine whether a page is missing, if yes, execute step 408, if not, end.
  • Step 408 Obtain status parameter information.
  • Step 409 Determine the size of the file pre-reading window according to the status parameter information.
  • step 408 and step 409 reference may be made to step 101 and step 102 in the embodiment shown in FIG. 4A, which will not be repeated here.
  • Step 410 Select at least one file page in the file pre-reading window according to the pre-reading model as the pre-read page, and issue an I/O request.
  • the pre-fetched page is read from the external storage device into the memory through the I/O request for application-level access.
  • This embodiment can implement adaptive adjustment of the pre-reading operation based on the state parameter information to occupy the memory resources, and can alleviate the slow response of the application program and the freezing and the like, thereby improving the use performance of the terminal device. And you can use the pre-reading model to increase the pre-reading hit rate, and increase the probability that the file page read from the external storage device into the memory is accessed by the application layer, thereby reducing invalid pre-reading.
  • the terminal device includes hardware and/or software modules corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Those skilled in the art can use different methods for each specific application in combination with the embodiments to implement the described functions, but such implementation should not be considered as going beyond the scope of the present application.
  • the terminal device may be divided into functional modules according to the foregoing method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • FIG. 8 shows a possible composition diagram of the terminal device 800 involved in the foregoing embodiment.
  • the terminal device 800 may include: state acquisition Module 801, pre-reading window determination module 802, and pre-reading module 803.
  • the state acquisition module 801 may be used to support the terminal device 800 to perform the above step 101, step 201, etc., and/or other processes used in the technology described herein.
  • the pre-reading window determination module 802 may be used to support the terminal device 800 to perform the above step 102, step 202, step 203, etc., and/or other processes used in the technology described herein.
  • the pre-reading module 803 may be used to support the terminal device 800 to perform the above step 103, step 204, step 303, step 304, etc., and/or other processes used in the technology described herein.
  • the terminal device provided in this embodiment is used to execute the above-mentioned method for pre-reading document pages, and therefore can achieve the same effect as the above-mentioned implementation method.
  • the terminal device may include a processing module, a storage module, and a communication module.
  • the processing module can be used to control and manage the actions of the terminal device. For example, it can be used to support the terminal device to execute the steps performed by the state acquisition module 801, the pre-reading window determining module 802, and the pre-reading module 803.
  • the storage module can be used to support the terminal device to execute the storage program code and data.
  • the communication module can be used to support the communication between the terminal device and other devices.
  • the processing module may be a processor or a controller. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the disclosure of this application.
  • the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and so on.
  • the storage module may be a memory.
  • the communication module may specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, and other devices that interact with other devices.
  • the terminal device involved in this embodiment may be a device having the structure shown in FIG. 1.
  • This embodiment also provides a computer storage medium in which computer instructions are stored.
  • the terminal device is caused to execute the above-mentioned related method steps to realize the pre-reading file in the above-mentioned embodiment. Page method.
  • This embodiment also provides a computer program product, which when the computer program product runs on a computer, causes the computer to execute the above-mentioned related steps, so as to realize the method of pre-reading document pages in the above-mentioned embodiment.
  • the embodiments of the present application also provide a device.
  • the device may specifically be a chip, component or module.
  • the device may include a processor and a memory connected to each other.
  • the memory is used to store computer execution instructions.
  • the processor can execute the computer-executable instructions stored in the memory, so that the chip executes the method of pre-reading file pages in the foregoing method embodiments.
  • the terminal device, computer storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding method provided above. The beneficial effects of the method will not be repeated here.
  • the disclosed device and method can be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of modules or units is only a logical function division.
  • there may be other division methods for example, multiple units or components may be combined or It can be integrated into another device, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product, and the software product is stored in a storage medium. It includes several instructions to make a device (may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods in the embodiments of the present application.
  • the foregoing storage media include: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application provides a method and a device for pre-reading a file page, and a terminal device. The method for pre-reading a file page of the present application comprises: acquiring state parameter information, the state parameter information being used for representing at least one of a memory usage state or an I/O processing state; determining the size of a file pre-reading window according to the state parameter information; and reading a corresponding file page from an external storage device into a memory according to the file pre-reading window. The present application can improve the usage performance of a terminal device.

Description

预读取文件页的方法、装置和终端设备Method, device and terminal equipment for pre-reading document pages
本申请要求于2019年8月27日提交中国专利局、申请号为201910798611.8、申请名称为“预读取文件页的方法、装置和终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on August 27, 2019, the application number is 201910798611.8, and the application name is "Method, Apparatus and Terminal Equipment for Pre-reading Document Pages", the entire content of which is incorporated by reference Incorporated in this application.
技术领域Technical field
本申请涉及计算机技术,尤其涉及一种预读取文件页的方法、装置和终端设备。This application relates to computer technology, and in particular to a method, device and terminal device for pre-reading document pages.
背景技术Background technique
操作系统位于底层硬件与用户之间,是两者沟通的桥梁。用户可以通过操作系统的用户界面,输入指令。操作系统对指令进行解析,驱动硬件设备,实现用户要求。操作系统可以提供如下的功能:进程管理、内存管理、文件系统、网络通信、安全机制、用户界面、以及驱动程序等。其中,文件系统是操作系统中用于明确存储设备(磁盘、固态硬盘等)或分区上的文件的方法和数据结构,即在存储设备上组织文件的方法。The operating system is located between the underlying hardware and the user, and is the bridge between the two. The user can input instructions through the user interface of the operating system. The operating system parses the instructions and drives the hardware devices to meet user requirements. The operating system can provide the following functions: process management, memory management, file system, network communication, security mechanism, user interface, and driver programs. Among them, the file system is a method and data structure used in the operating system to specify files on storage devices (disks, solid state drives, etc.) or partitions, that is, a method for organizing files on storage devices.
终端设备的应用程序在启动、运行过程中,可以通过操作系统提供的文件预读的方式从外部存储器(例如,磁盘)读取一些文件页至内存中,供应用程序使用。该文件预读的方式,可以根据文件访问模式(顺序读或随机读)按一定规则调整预读窗口大小,例如,顺序读则增大预读窗口,随机读则减小,将预读窗口中所有文件页读入内存,以便应用程序可以从内存中快速访问文件页。During the startup and running of the application program of the terminal device, some file pages can be read from the external memory (for example, a disk) to the memory through the file pre-reading method provided by the operating system for use by the application program. The file pre-reading method can adjust the size of the pre-reading window according to the file access mode (sequential read or random read) according to certain rules. For example, sequential read will increase the pre-read window, random read will decrease, and the pre-read window will be All file pages are read into memory so that applications can quickly access file pages from memory.
然而,上述文件预读的方式会存在预读过多无效文件页的问题,即过多近期不会被访问的文件页预读至内存中,过多占用内存空间,挤占终端设备的应用程序可使用的内存空间,从而导致终端设备出现应用程序启动响应慢、卡顿等现象,影响终端设备的使用性能。However, the above file pre-reading method has the problem of pre-reading too many invalid file pages, that is, too many file pages that will not be accessed in the near future are pre-read into the memory, occupying too much memory space, and squeezing the application program of the terminal device. The used memory space causes the terminal device to have slow response to application startup, freezes, etc., which affects the performance of the terminal device.
发明内容Summary of the invention
本申请提供一种预读取文件页的方法、装置和终端设备,以提升终端设备的使用性能。This application provides a method, device and terminal device for pre-reading document pages to improve the use performance of the terminal device.
第一方面,本申请提供一种预读取文件页的方法,该方法可以包括:获取状态参数信息,该状态参数信息用于表示内存使用状态或输入输出IO处理状态中至少一项;根据该状态参数信息确定文件预读窗口的大小;根据该文件预读窗口从外部存储设备读取相应的文件页至内存中。文件页被读取到内存中之后,可以被应用程序访问。In the first aspect, the present application provides a method for pre-reading document pages. The method may include: obtaining state parameter information, where the state parameter information is used to indicate at least one of a memory usage state or an input/output IO processing state; The status parameter information determines the size of the file pre-reading window; according to the file pre-reading window, the corresponding file page is read from the external storage device to the memory. After the file page is read into the memory, it can be accessed by the application.
本实现方式,可以基于状态参数信息自适应的调节文件预读窗口的大小,进而根据文件预读窗口的大小进行预读操作,基于不同的文件预读窗口的大小进行预读操作的文件页的个数不同,预读操作的文件页对内存资源的占用不同,从而实现自适应调节预读操作对内存资源的占用。例如,可以基于状态参数信息确定内存使用压力较大和/或I/O处理压力较大,在内存使用压力较大和/或I/O处理压力较大时,减少预读窗口的大小,从而减少预读操作所述读取的文件页,从而可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。In this implementation, the size of the file pre-reading window can be adjusted adaptively based on the state parameter information, and then the pre-reading operation is performed according to the size of the file pre-reading window, and the file page size of the pre-reading operation is performed based on the size of the file pre-reading window. The number is different, the file page of the pre-read operation occupies different memory resources, so as to realize the adaptive adjustment of the memory resource occupancy of the pre-read operation. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window. The read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
在一种可能的设计中,根据该状态参数信息确定文件预读窗口的大小的可实现方式包括:当该状态参数信息指示内存使用压力或IO处理压力中至少一项处于第一级别时,减小该文件预读窗口的大小;当该状态参数信息指示该内存使用压力或IO处理压力中至少一项处于第二级别时,增大该文件预读窗口的大小;其中,该第一级别的内存使用压力或IO处理压力大于该第二级别的内存使用压力或IO处理压力。In a possible design, the achievable way of determining the size of the file pre-reading window according to the state parameter information includes: when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level, reducing Reduce the size of the file pre-reading window; when the status parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the second level, increase the size of the file pre-reading window; where the first level The memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
本实现方式,当该状态参数信息指示内存使用压力或IO处理压力中至少一项处于第一级别时,表示内存使用压力较大和/或IO处理压力较大,通过减小文件预读窗口的大小,以减少预读取的文件页,从而减少预读取的文件页所占用的内存资源,以缓解应用程序启动响应慢、卡顿等现象,当该状态参数信息指示内存使用压力或IO处理压力中至少一项处于第一级别时,表示内存使用压力较小和/或IO处理压力较小,通过增大文件预读窗口的大小,以增加预读取的文件页,可以减少缺页现象提升终端设备文件访问速度,从而可以提升终端设备的使用性能。In this implementation, when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level, it indicates that the memory usage pressure is greater and/or the IO processing pressure is greater, and the size of the file pre-reading window is reduced. , In order to reduce the pre-read file pages, thereby reducing the memory resources occupied by the pre-read file pages, to alleviate the slow response and stalling of the application startup, when the status parameter information indicates memory usage pressure or IO processing pressure When at least one item is in the first level, it means that the memory usage pressure is low and/or the IO processing pressure is low. By increasing the size of the file pre-reading window to increase the pre-read file pages, the page faults can be reduced. The file access speed of the terminal device can improve the performance of the terminal device.
在一种可能的设计中,该状态参数信息可以包括内存参数或IO参数中至少一项,该内存参数包括内存占用量、内存使用率、或缺页累计次数中至少一项,该IO参数包括IO队列长度。In a possible design, the state parameter information may include at least one of a memory parameter or an IO parameter, the memory parameter includes at least one of a memory footprint, a memory usage rate, or a cumulative number of page faults, and the IO parameter includes IO queue length.
本实现方式,可以根据内存参数和/或IO参数确定内存资源的使用状况,基于此自适应的调节预读操作对内存资源的占用,以提升终端设备的使用性能。In this implementation manner, the usage status of the memory resource can be determined according to the memory parameter and/or the IO parameter, and the occupation of the memory resource by the pre-reading operation is adaptively adjusted based on this, so as to improve the usage performance of the terminal device.
在一种可能的设计中,根据该状态参数信息确定文件预读窗口的大小的可实现方式包括:根据该内存参数和该IO参数中至少一项确定第一指标。根据该第一指标确定该文件预读窗口的大小。In a possible design, the achievable manner of determining the size of the file pre-reading window according to the state parameter information includes: determining the first index according to at least one of the memory parameter and the IO parameter. The size of the file pre-reading window is determined according to the first indicator.
在一种可能的设计中,根据该第一指标确定该文件预读窗口的大小的一种可实现方式包括:根据该第一指标确定该第一指标所属的数值区间。将该第一指标所属的数值区间对应的窗口大小作为该文件预读窗口的大小。In a possible design, an achievable way of determining the size of the file pre-reading window according to the first index includes: determining the numerical range to which the first index belongs according to the first index. The window size corresponding to the numerical interval to which the first indicator belongs is used as the size of the file pre-reading window.
在一种可能的设计中,根据该文件预读窗口从外部存储设备读取相应的文件页至内存中的一种可实现方式包括:根据预读模型选取该文件预读窗口内的至少一个文件页,将该至少一个文件页从外部存储设备读取至内存中。其中,该预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的内存中的数据结构,该预读模型与文件对应,该文件访问实时数据与该文件访问历史数据不同步,该文件访问历史数据为该外部存储设备中的数据。In a possible design, an achievable way of reading the corresponding file page from the external storage device to the memory according to the file pre-reading window includes: selecting at least one file in the file pre-reading window according to the pre-reading model Page, read the at least one file page from the external storage device into the memory. Wherein, the pre-reading model is a data structure in the memory determined according to at least one of file access real-time data and file access historical data, the pre-reading model corresponds to the file, and the file access real-time data is not synchronized with the file access historical data , The file access history data is the data in the external storage device.
本实现方式,由于该预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的,所以该预读模型记录了文件页的被访问记录,可以使用预读模型增加预读命中率,提升从外部存储设备读取至内存中的文件页被应用层访问的机率,从而减少无效预读,减少内存资源浪费。In this implementation, since the pre-reading model is determined based on at least one of file access real-time data and file access historical data, the pre-reading model records the access records of file pages, and the pre-reading model can be used to increase pre-reading hits It improves the probability that the file page read from the external storage device to the memory is accessed by the application layer, thereby reducing invalid pre-reading and reducing the waste of memory resources.
在一种可能的设计中,该预读模型包括N个比特位,每个比特位对应该文件的一个文件页,每个比特位用于表示该比特位对应的文件页是否被访问,N为大于或等于1的整数。In a possible design, the pre-reading model includes N bits, each bit corresponds to a file page of the file, and each bit is used to indicate whether the file page corresponding to the bit is accessed, and N is An integer greater than or equal to 1.
在一种可能的设计中,该方法还可以包括:判断该至少一个文件页所构成的片段的个数是否大于第一阈值。若该至少一个文件页所构成的片段的个数大于第一阈值,则将该文件预读窗口内的所有文件页从外部存储设备读取至内存中。若该至少一个文件页所构成的片段的个数小于或等于第一阈值,则执行将该至少一个文件页从外部存储设备读取至内存 中的步骤。In a possible design, the method may further include: determining whether the number of segments formed by the at least one file page is greater than a first threshold. If the number of fragments formed by the at least one file page is greater than the first threshold, all file pages in the file pre-reading window are read from the external storage device into the memory. If the number of segments formed by the at least one file page is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is performed.
本实现方式,通过比较预读取的至少一个文件页所构成的片段的个数与第一阈值的大小,在所构成的片段的个数大于第一阈值时,将文件预读窗口内的所有文件页从外部存储设备读取至内存中,可以避免由于较多的片段个数所导致的I/O碎片化,提升I/O处理效率。在所构成的片段的个数小于或等于第一阈值时,将预读取的至少一个文件页从外部存储设备读取至内存中,文件预读窗口内的除预读取的至少一个文件页之外的其余文件页不作预读操作,从而降低预读操作对内存的占用,减少无效预读。In this implementation, by comparing the number of fragments formed by at least one file page read in advance with the size of the first threshold, when the number of fragments formed is greater than the first threshold, all files in the file pre-reading window are File pages are read from an external storage device into the memory, which can avoid I/O fragmentation caused by a large number of fragments, and improve the efficiency of I/O processing. When the number of fragments formed is less than or equal to the first threshold, read at least one pre-read file page from the external storage device into the memory, and at least one file page in the file pre-read window except for the pre-read at least one file page The rest of the file pages are not pre-read, thereby reducing the memory occupation of the pre-reading operation and reducing invalid pre-reading.
在一种可能的设计中,将文件预读窗口内的所有文件页从外部存储设备读取至内存中,可以包括:判断文件预读窗口的最后一个文件页对应的比特位是否表示该最后一个文件页被访问。当该最后一个文件页对应的比特位表示该最后一个文件页被访问时,将该文件预读窗口内的所有文件页和该文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中。当该最后一个文件页对应的比特位表示该最后一个文件页未被访问时,将该文件预读窗口内的所有文件页从外部存储设备读取至内存中;其中,该文件预读窗口之后的至少一个文件页与该文件预读窗口的最后一个文件页属于同一片段。In a possible design, reading all the file pages in the file pre-reading window from the external storage device to the memory may include: judging whether the bit corresponding to the last file page of the file pre-reading window indicates the last one The file page is accessed. When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device to In memory. When the bit corresponding to the last file page indicates that the last file page has not been accessed, all file pages in the file pre-reading window are read from the external storage device to the memory; among them, after the file pre-reading window At least one file page of the file belongs to the same segment as the last file page of the file pre-reading window.
本实现方式,通过判断文件预读窗口的最后一个文件页是否被访问,在最后一个文件页被访问时,将与最后一个文件页属于同一个片段的文件页读入内存,避免因预读窗口边界的划分造成I/O碎片化(即同一片段中部分页被划分在窗口之外,下次被访问时还要再次读入,增加I/O次数),从而可以提升I/O处理效率。In this implementation method, by judging whether the last file page of the file pre-reading window is accessed, when the last file page is accessed, the file page belonging to the same segment as the last file page is read into the memory to avoid the pre-reading window. The boundary division causes I/O fragmentation (that is, some pages in the same fragment are divided outside the window, and will be read again when accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
在一种可能的设计中,将该至少一个文件页从外部存储设备读取至内存中,可以包括:判断文件预读窗口的最后一个文件页对应的比特位是否表示该最后一个文件页被访问。当该最后一个文件页对应的比特位表示该最后一个文件页被访问时,将该至少一个文件页和该文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中。当该最后一个文件页对应的比特位表示该最后一个文件页未被访问时,将该至少一个文件页从外部存储设备读取至内存中。其中,该文件预读窗口之后的至少一个文件页与该文件预读窗口的最后一个文件页属于同一片段。In a possible design, reading the at least one file page from the external storage device into the memory may include: determining whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed . When the bit corresponding to the last file page indicates that the last file page is accessed, the at least one file page and the at least one file page after the file pre-reading window are read from the external storage device into the memory. When the bit corresponding to the last file page indicates that the last file page has not been accessed, the at least one file page is read from the external storage device into the memory. Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
本实现方式,通过判断文件预读窗口的最后一个文件页是否被访问,在最后一个文件页被访问时,将与最后一个文件页属于同一个片段的文件页读入内存,避免因预读窗口边界的划分造成I/O碎片化(即同一片段中部分页被划分在窗口之外,下次被访问时还要再次读入,增加I/O次数),从而可以提升I/O处理效率。In this implementation method, by judging whether the last file page of the file pre-reading window is accessed, when the last file page is accessed, the file page belonging to the same segment as the last file page is read into the memory to avoid the pre-reading window. The boundary division causes I/O fragmentation (that is, some pages in the same fragment are divided outside the window, and will be read again when accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
在一种可能的设计中,该文件访问历史数据包括本次打开该文件之前的读访问请求的位置、长度、或时间中至少一项,该文件访问实时数据包括本次打开该文件之后的读访问请求的位置、长度、或时间中至少一项。In a possible design, the file access history data includes at least one of the location, length, or time of the read access request before the file is opened this time, and the file access real-time data includes the read access after the file is opened this time. At least one of the location, length, or time of the access request.
在一种可能的设计中,该方法还可以包括:根据该预读模型更新该外部存储设备中的该文件对应的文件访问历史数据。In a possible design, the method may further include: updating the file access history data corresponding to the file in the external storage device according to the pre-reading model.
在一种可能的设计中,该获取状态参数信息,可以包括:在触发预读取文件页时获取该状态参数信息;或者,以预设周期获取该状态参数信息。In a possible design, the acquiring state parameter information may include: acquiring the state parameter information when the pre-fetching of the document page is triggered; or, acquiring the state parameter information in a preset period.
第二方面,本申请实施例提供一种预读取文件页的装置,该装置可以包括:状态获取模块,用于获取状态参数信息,该状态参数信息用于表示内存使用状态或输入输出IO处理状态中至少一项。预读窗口确定模块,用于根据该状态参数信息确定文件预读窗口的大 小;预读模块,用于根据该文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问该文件页。In a second aspect, an embodiment of the present application provides an apparatus for pre-reading document pages. The apparatus may include: a status acquisition module for acquiring status parameter information, the status parameter information being used to indicate memory usage status or input/output IO processing At least one of the status. The pre-reading window determination module is used to determine the size of the file pre-reading window according to the state parameter information; the pre-reading module is used to read the corresponding file page from the external storage device to the memory according to the file pre-reading window for supply Layer to access the file page.
在一种可能的设计中,该预读窗口确定模块用于:当该状态参数信息指示内存使用压力或IO处理压力中至少一项处于第一级别时,减小该文件预读窗口的大小;当该状态参数信息指示所述内存使用压力或IO处理压力中至少一项处于第二级别时,增大该文件预读窗口的大小;其中,该第一级别的内存使用压力或IO处理压力大于该第二级别的内存使用压力或IO处理压力。In a possible design, the pre-reading window determination module is used to reduce the size of the file pre-reading window when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level; When the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the second level, the size of the file pre-reading window is increased; wherein the memory usage pressure or the IO processing pressure of the first level is greater than This second level of memory usage pressure or IO processing pressure.
在一种可能的设计中,该预读窗口确定模块用于:根据该内存参数和该IO参数中至少一项确定第一指标。根据该第一指标确定该文件预读窗口的大小。In a possible design, the pre-reading window determination module is used to determine the first index according to at least one of the memory parameter and the IO parameter. The size of the file pre-reading window is determined according to the first indicator.
在一种可能的设计中,该预读窗口确定模块用于:根据该第一指标确定该第一指标所属的数值区间。将该第一指标所属的数值区间对应的窗口大小作为该文件预读窗口的大小。In a possible design, the pre-reading window determination module is used to determine the numerical interval to which the first index belongs according to the first index. The window size corresponding to the numerical interval to which the first indicator belongs is used as the size of the file pre-reading window.
在一种可能的设计中,该预读模块用于:根据预读模型选取该文件预读窗口内的至少一个文件页,将该至少一个文件页从外部存储设备读取至内存中。其中,该预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的数据结构,该预读模型与文件对应,该文件访问实时数据与该文件访问历史数据不同步,该文件访问历史数据为该外部存储设备中的数据。In a possible design, the pre-reading module is used to select at least one file page in the file pre-reading window according to the pre-reading model, and read the at least one file page from the external storage device into the memory. Wherein, the pre-reading model is a data structure determined based on at least one of file access real-time data and file access historical data. The pre-reading model corresponds to the file. The file access real-time data is not synchronized with the file access history data. The access history data is the data in the external storage device.
在一种可能的设计中,该预读模块还用于:判断该至少一个文件页所构成的片段的个数是否大于第一阈值。若该至少一个文件页所构成的片段的个数大于第一阈值,则将该文件预读窗口内的所有文件页从外部存储设备读取至内存中;若该至少一个文件页所构成的片段的个数小于或等于第一阈值,则执行将该至少一个文件页从外部存储设备读取至内存中的步骤。In a possible design, the pre-reading module is further used to determine whether the number of fragments formed by the at least one file page is greater than a first threshold. If the number of fragments constituted by the at least one file page is greater than the first threshold, all file pages in the file pre-reading window are read from the external storage device into the memory; if the fragments constituted by the at least one file page If the number of is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is executed.
在一种可能的设计中,该预读模块用于:判断该文件预读窗口的最后一个文件页对应的比特位是否表示该最后一个文件页被访问;当该最后一个文件页对应的比特位表示该最后一个文件页被访问时,将该文件预读窗口内的所有文件页和该文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;当该最后一个文件页对应的比特位表示该最后一个文件页未被访问时,将该文件预读窗口内的所有文件页从外部存储设备读取至内存中;其中,该文件预读窗口之后的至少一个文件页与该文件预读窗口的最后一个文件页属于同一片段。In a possible design, the pre-reading module is used to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed; when the bit corresponding to the last file page Indicates that when the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device into the memory; when the last file page corresponds The bit indicates that when the last file page is not accessed, all file pages in the file pre-reading window are read from the external storage device to the memory; among them, at least one file page after the file pre-reading window and the The last file page of the file pre-reading window belongs to the same segment.
在一种可能的设计中,该预读模块用于:判断该文件预读窗口的最后一个文件页对应的比特位是否表示该最后一个文件页被访问;当该最后一个文件页对应的比特位表示该最后一个文件页被访问时,将该至少一个文件页和该文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;当该最后一个文件页对应的比特位表示该最后一个文件页未被访问时,将该至少一个文件页从外部存储设备读取至内存中;其中,该文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。In a possible design, the pre-reading module is used to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed; when the bit corresponding to the last file page Indicates that when the last file page is accessed, the at least one file page and at least one file page after the file pre-reading window are read from the external storage device into the memory; when the bit corresponding to the last file page indicates the When the last file page is not accessed, the at least one file page is read from the external storage device into the memory; wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window Belong to the same segment.
在一种可能的设计中,该预读模块还用于:根据该预读模型更新该外部存储设备中的该文件对应的文件访问历史数据。In a possible design, the pre-reading module is further used to update the file access history data corresponding to the file in the external storage device according to the pre-reading model.
在一种可能的设计中,该状态获取模块用于:在触发预读取文件页时获取该状态参数信息;或者,以预设周期获取该状态参数信息。In a possible design, the state obtaining module is used to obtain the state parameter information when the pre-fetching of the document page is triggered; or, to obtain the state parameter information in a preset period.
在一种可能的设计中,该预读取文件页的装置可以是终端设备或终端设备的内部芯片。In a possible design, the device for pre-reading document pages may be a terminal device or an internal chip of the terminal device.
第三方面,本申请提供一种终端设备,包括:一个或多个处理器;存储器,用于存储一个或多个程序;当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如上述第一方面中任一项所述的方法。In a third aspect, this application provides a terminal device, including: one or more processors; a memory, used to store one or more programs; when the one or more programs are executed by the one or more processors , Enabling the one or more processors to implement the method according to any one of the foregoing first aspects.
第四方面,本申请提供一种计算机可读存储介质,包括计算机程序,所述计算机程序在计算机上被执行时,使得所述计算机执行上述第一方面中任一项所述的方法。In a fourth aspect, the present application provides a computer-readable storage medium, including a computer program, which when executed on a computer, causes the computer to execute the method described in any one of the above-mentioned first aspects.
第五方面,本申请提供一种计算机程序或包含计算机程序的计算机程序产品,当所述计算机程序被计算机执行时,用于执行上述第一方面中任一项所述的方法。In a fifth aspect, the present application provides a computer program or a computer program product containing a computer program, when the computer program is executed by a computer, it is used to execute the method described in any one of the above-mentioned first aspects.
第六方面,本申请提供一种芯片,包括处理器和存储器,所述存储器用于存储计算机程序,所述处理器用于调用并运行所述存储器中存储的计算机程序,以执行如上述第一方面中任一项所述的方法。In a sixth aspect, the present application provides a chip including a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the above-mentioned first aspect The method of any one of.
本申请的预读取文件页的方法、装置和终端设备,获取状态参数信息,该状态参数信息可以用于表示内存使用状态或I/O处理状态中至少一项,根据状态参数信息确定文件预读窗口的大小,根据文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问文件页,可以基于状态参数信息自适应的调节文件预读窗口的大小,进而根据文件预读窗口的大小进行预读操作,基于不同的文件预读窗口的大小进行预读操作的文件页的个数不同,预读操作的文件页对内存资源的占用不同,从而实现自适应调节预读操作对内存资源的占用。例如,可以基于状态参数信息确定内存使用压力较大和/或I/O处理压力较大,在内存使用压力较大和/或I/O处理压力较大时,减少预读窗口的大小,从而减少预读操作所述读取的文件页,从而可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。The method, device, and terminal device for pre-reading document pages of the present application obtain status parameter information, which can be used to indicate at least one of the memory usage status or the I/O processing status, and the file pre-determination is determined according to the status parameter information. The size of the read window, read the corresponding file page from the external storage device to the memory according to the file pre-read window, and access the file page by the application layer. The size of the file pre-read window can be adjusted adaptively based on the state parameter information, and then according to The size of the file pre-reading window is used for pre-reading operations, the number of file pages for pre-reading operations based on the size of different file pre-reading windows is different, and the file pages for pre-reading operations occupy different memory resources, thereby achieving adaptive adjustment Occupation of memory resources by pre-reading operations. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window. The read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
附图说明Description of the drawings
图1为本申请实施例的一种电子设备的硬件结构示意图;FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the application;
图2为本申请实施例的一种电子设备的软件结构示意图;2 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application;
图3为本申请实施例的一种电子设备的软件结构示意图FIG. 3 is a schematic diagram of the software structure of an electronic device according to an embodiment of the application
图4A为本申请实施例的一种预读取文件页的方法流程图;4A is a flowchart of a method for pre-reading document pages according to an embodiment of the application;
图4B为本申请实施例的一种文件预读窗口的示意图;4B is a schematic diagram of a file pre-reading window according to an embodiment of the application;
图5为本申请实施例的另一种预读取文件页的方法流程图;5 is a flowchart of another method for pre-reading document pages according to an embodiment of the application;
图6A为本申请实施例的另一种预读取文件页的方法流程图;6A is a flowchart of another method for pre-reading document pages according to an embodiment of the application;
图6B为本申请实施例的一种预读取文件页的示意图;6B is a schematic diagram of a pre-fetched document page according to an embodiment of the application;
图7为本申请实施例的另一种预读取文件页的方法流程图;FIG. 7 is a flowchart of another method for pre-reading document pages according to an embodiment of the application;
图8为本申请实施例的另一种终端设备的结构示意图。FIG. 8 is a schematic structural diagram of another terminal device according to an embodiment of the application.
具体实施方式detailed description
本申请的说明书实施例和权利要求书及附图中的术语“第一”、“第二”等仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元。方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", etc. in the specification embodiments, claims, and drawings of this application are only used for the purpose of distinguishing description, and cannot be construed as indicating or implying relative importance, nor can they be construed as indicating Or imply the order. In addition, the terms "including" and "having" and any variations of them are intended to cover non-exclusive inclusion, for example, including a series of steps or units. The method, system, product, or device need not be limited to those clearly listed steps or units, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or devices.
应当理解,在本申请中,“至少一个(项)”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,“a和b”,“a和c”,“b和c”,或“a和b和c”,其中a,b,c可以是单个,也可以是多个。It should be understood that in this application, "at least one (item)" refers to one or more, and "multiple" refers to two or more. "And/or" is used to describe the association relationship of associated objects, indicating that there can be three types of relationships, for example, "A and/or B" can mean: only A, only B, and both A and B , Where A and B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in an "or" relationship. "The following at least one item (a)" or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a). For example, at least one of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c" ", where a, b, and c can be single or multiple.
本申请实施例提供的一种预读取文件页的方法可应用于手机、平板电脑、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、手持计算机、上网本、个人数字助理(personal digital assistant,PDA)、可穿戴电子设备、虚拟现实设备等终端设备中,本申请实施例对此不做任何限制。The method for pre-reading document pages provided by the embodiments of this application can be applied to mobile phones, tablet computers, notebook computers, ultra-mobile personal computers (UMPC), handheld computers, netbooks, and personal digital assistants (personal digital assistants). Among terminal devices such as digital assistant (PDA), wearable electronic devices, and virtual reality devices, the embodiments of the present application do not impose any limitation on this.
示例性的,图1示出了终端设备100的结构示意图。Exemplarily, FIG. 1 shows a schematic structural diagram of a terminal device 100.
终端设备100可以包括:应用处理器101、微控制器单元(microcontroller unit,MCU)103、存储器105、调制解调器(modem)107、射频(radio frequency,RF)模块109、无线保真(Wireless-Fidelity,简称Wi-Fi)模块111、蓝牙模块113、传感器114、定位模块150、输入/输出(input/output,I/O)设备115等部件。这些部件可通过一根或多根通信总线或信号线进行通信。本领域技术人员可以理解,图1中示出的硬件结构并不构成对终端设备的限定,终端设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。The terminal device 100 may include: an application processor 101, a microcontroller unit (microcontroller unit, MCU) 103, a memory 105, a modem (modem) 107, a radio frequency (RF) module 109, and a wireless fidelity (Wireless-Fidelity, (Referred to as Wi-Fi) module 111, Bluetooth module 113, sensor 114, positioning module 150, input/output (input/output, I/O) device 115 and other components. These components can communicate through one or more communication buses or signal lines. Those skilled in the art can understand that the hardware structure shown in FIG. 1 does not constitute a limitation on the terminal device. The terminal device 100 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. Layout.
下面结合图1对终端设备100的各个部件进行具体的介绍:Hereinafter, each component of the terminal device 100 will be specifically introduced with reference to FIG. 1:
应用处理器101是终端设备100的控制中心,利用各种接口和总线连接终端设备100的各个部件。在一些实施例中,应用处理器101可包括一个或多个处理单元。The application processor 101 is the control center of the terminal device 100, and uses various interfaces and buses to connect various components of the terminal device 100. In some embodiments, the application processor 101 may include one or more processing units.
存储器105中存储有计算机程序,诸如图1所示的操作系统161和应用程序163。应用处理器101被配置用于执行存储器105中的计算机程序,从而实现该计算机程序定义的功能,例如应用处理器101执行操作系统161从而在终端设备100上实现操作系统的各种功能。存储器105还存储有除计算机程序之外的其他数据,诸如操作系统161和应用程序163运行过程中产生的数据。存储器105为可以包括内存和外存。内存包括但不限于随机存取存储器(Random Access Memory,RAM),只读存储器(Read-Only Memory,ROM),或高速缓存(cache)等。外存包括但不限于闪存(flash memory)、硬盘、光盘、通用串行总线(universal serial bus,USB)盘等。计算机程序通常被存储在外存上,处理器在执行计算机程序前会将该程序从外存加载到内存。The memory 105 stores computer programs, such as the operating system 161 and application programs 163 shown in FIG. 1. The application processor 101 is configured to execute a computer program in the memory 105 to implement functions defined by the computer program. For example, the application processor 101 executes an operating system 161 to implement various functions of the operating system on the terminal device 100. The memory 105 also stores other data besides computer programs, such as data generated during the running of the operating system 161 and the application program 163. The memory 105 may include internal memory and external memory. Memory includes but is not limited to random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), or cache (cache). External storage includes but is not limited to flash memory (flash memory), hard disks, optical disks, universal serial bus (USB) disks, etc. Computer programs are usually stored in external memory, and the processor loads the program from external memory to memory before executing the computer program.
存储器105可以是独立的,通过总线与应用处理器101相连接;存储器105也可以和应用处理器101集成到一个芯片子系统。The memory 105 may be independent and connected to the application processor 101 through a bus; the memory 105 and the application processor 101 may also be integrated into a chip subsystem.
MCU 103是用于获取并处理来自传感器114的数据的协处理器,MCU 103的处理能力和功耗小于应用处理器101,但具有“永久开启(always on)”的特点,可以在应用处理器101处于休眠模式时持续收集以及处理传感器数据,以极低的功耗保障传感器的正常运行。传感器114可以包括光传感器、运动传感器、陀螺仪、气压计、湿度计、温度计、红外线传感器等,在此不再赘述。MCU 103和传感器114可以集成到同一块芯片上,也可以是分离的元件,通过总线连接。 MCU 103 is a co-processor used to acquire and process data from the sensor 114. The processing power and power consumption of MCU 103 are less than that of the application processor 101, but it has the feature of "always on" and can be used in the application processor. 101 continuously collects and processes sensor data when it is in sleep mode to ensure the normal operation of the sensor with extremely low power consumption. The sensor 114 may include a light sensor, a motion sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here. The MCU 103 and the sensor 114 may be integrated on the same chip, or may be separate components, connected by a bus.
Modem 107以及射频模块109构成了终端设备100通信子系统,用于实现3GPP、ETSI等无线通信标准协议的主要功能。其中,Modem 107用于编解码、信号的调制解调、均衡等。射频模块109用于无线信号的接收和发送,射频模块109包括但不限于天线、至少一个放大器、耦合器、双工器等。射频模块109配合Modem 107实现无线通信功能。The modem 107 and the radio frequency module 109 constitute the communication subsystem of the terminal device 100, which is used to implement the main functions of the wireless communication standard protocols such as 3GPP and ETSI. Among them, Modem 107 is used for encoding and decoding, signal modulation and demodulation, and equalization. The radio frequency module 109 is used for receiving and transmitting wireless signals. The radio frequency module 109 includes but is not limited to an antenna, at least one amplifier, a coupler, a duplexer, and the like. The radio frequency module 109 cooperates with the Modem 107 to realize the wireless communication function.
终端设备100还可以使用Wi-Fi模块111,蓝牙模块113等来进行无线通信。Wi-Fi模块111用于为终端设备100提供遵循Wi-Fi相关标准协议的网络接入,终端设备100可以通过Wi-Fi模块111接入到Wi-Fi接入点,进而访问互联网。在其他一些实施例中,Wi-Fi模块111也可以作为Wi-Fi无线接入点,可以为其他终端设备提供Wi-Fi网络接入。蓝牙模块113用于实现终端设备100与其他终端设备(例如手机、智能手表等)之间的短距离通信。本申请实施例中的Wi-Fi模块111可以是集成电路或Wi-Fi芯片等,蓝牙模块113可以是集成电路或者蓝牙芯片等。The terminal device 100 may also use the Wi-Fi module 111, the Bluetooth module 113, etc. to perform wireless communication. The Wi-Fi module 111 is used to provide the terminal device 100 with network access that complies with Wi-Fi related standard protocols. The terminal device 100 can access a Wi-Fi access point through the Wi-Fi module 111 to access the Internet. In some other embodiments, the Wi-Fi module 111 can also be used as a Wi-Fi wireless access point, which can provide Wi-Fi network access for other terminal devices. The Bluetooth module 113 is used to implement short-distance communication between the terminal device 100 and other terminal devices (such as mobile phones, smart watches, etc.). The Wi-Fi module 111 in the embodiment of the present application may be an integrated circuit or a Wi-Fi chip or the like, and the Bluetooth module 113 may be an integrated circuit or a Bluetooth chip or the like.
定位模块150用于确定终端设备100的地理位置。可以理解的是,定位模块150具体可以是全球定位系统(global position system,GPS)、全球导航卫星系统(global navigation satellite system,GLONASS)、或北斗卫星导航系统(beidounavigation satellite system,BDS)等定位系统的接收器。The positioning module 150 is used to determine the geographic location of the terminal device 100. It is understandable that the positioning module 150 may specifically be a positioning system such as a global positioning system (GPS), a global navigation satellite system (GLONASS), or a Beidou satellite navigation system (BDS). Receiver.
Wi-Fi模块111,蓝牙模块113和定位模块150分别可以是单独的芯片或集成电路,也可以集成到一起。例如,在一个实施例中,Wi-Fi模块111,蓝牙模块113和定位模块150可以集成到同一芯片上。在另一个实施例中,Wi-Fi模块111,蓝牙模块113、定位模块150以及MCU 103也可以集成到同一芯片中。The Wi-Fi module 111, the Bluetooth module 113, and the positioning module 150 may be separate chips or integrated circuits, respectively, or they may be integrated together. For example, in one embodiment, the Wi-Fi module 111, the Bluetooth module 113 and the positioning module 150 may be integrated on the same chip. In another embodiment, the Wi-Fi module 111, the Bluetooth module 113, the positioning module 150, and the MCU 103 may also be integrated into the same chip.
输入/输出设备115包括但不限于:显示器151、触摸屏153,以及音频电路155等等。The input/output device 115 includes, but is not limited to: a display 151, a touch screen 153, an audio circuit 155, and so on.
其中,触摸屏153可采集终端设备100的用户在其上或附近的触摸事件(比如用户使用手指、触控笔等任何适合的物体在触摸屏153上或在触控屏触摸屏153附近的操作),并将采集到的触摸事件发送给其他器件(例如应用处理器101)。Among them, the touch screen 153 can collect touch events on or near the user of the terminal device 100 (for example, the user uses a finger, a stylus, or any other suitable object to operate on the touch screen 153 or near the touch screen 153), and Send the collected touch events to other devices (for example, the application processor 101).
显示器(也称为显示屏)151用于显示用户输入的信息或展示给用户的信息。可以采用液晶显示屏、有机发光二极管等形式来配置显示器。The display (also called a display screen) 151 is used to display information input by the user or information presented to the user. The display can be configured in the form of a liquid crystal display, an organic light-emitting diode, etc.
音频电路1155、扬声器116、麦克风117可提供用户与终端设备100之间的音频接口。音频电路109可将接收到的音频数据转换后的电信号,传输到扬声器113,由扬声器113转换为声音信号输出;另一方面,麦克风114将收集的声音信号转换为电信号,由音频电路109接收后转换为音频数据,再通过Modem 107和射频模块109将音频数据发送给比如另一终端设备,或者将音频数据输出至存储器105以便进一步处理。The audio circuit 1155, the speaker 116, and the microphone 117 may provide an audio interface between the user and the terminal device 100. The audio circuit 109 can transmit the electric signal after the conversion of the received audio data to the speaker 113, which is converted into a sound signal by the speaker 113 for output; on the other hand, the microphone 114 converts the collected sound signal into an electric signal, and the audio circuit 109 After being received, the audio data is converted into audio data, and then the audio data is sent to, for example, another terminal device through the Modem 107 and the radio frequency module 109, or the audio data is output to the memory 105 for further processing.
另外,终端设备100还可以具有指纹识别功能。例如,可以在终端设备100的背面(例如后置摄像头的下方)配置指纹采集器件,或者在终端设备100的正面(例如触摸屏153的下方)配置指纹采集器件。In addition, the terminal device 100 may also have a fingerprint recognition function. For example, a fingerprint collection device may be configured on the back of the terminal device 100 (for example, below the rear camera), or a fingerprint collection device may be configured on the front of the terminal device 100 (for example, below the touch screen 153).
进一步地,终端设备100搭载的操作系统161可以为
Figure PCTCN2020092247-appb-000001
或者其它操作系统,本申请实施例对此不作任何限制。
Further, the operating system 161 carried by the terminal device 100 may be
Figure PCTCN2020092247-appb-000001
Or other operating systems, this embodiment of the application does not impose any restriction on this.
以搭载
Figure PCTCN2020092247-appb-000002
操作系统的终端设备100为例,如图2所示,终端设备100从逻辑上可划分为硬件层21、操作系统161,以及应用层31。硬件层21包括如上所述的应用处理器101、微控制器单元103、存储器105、Modem 107、Wi-Fi模块111、传感器114、定位模块150等硬件资源。应用层31包括一个或多个应用程序,比如应用程序163,应用程序 163可以为社交类应用、电子商务类应用、浏览器等任意类型的应用程序。操作系统161作为硬件层21和应用层31之间的软件中间件,是管理和控制硬件与软件资源的计算机程序。
To carry
Figure PCTCN2020092247-appb-000002
The terminal device 100 of the operating system is taken as an example. As shown in FIG. 2, the terminal device 100 can be logically divided into a hardware layer 21, an operating system 161, and an application layer 31. The hardware layer 21 includes hardware resources such as the application processor 101, the microcontroller unit 103, the memory 105, the Modem 107, the Wi-Fi module 111, the sensor 114, and the positioning module 150 as described above. The application layer 31 includes one or more applications, such as an application 163. The application 163 may be any type of application such as a social application, an e-commerce application, or a browser. The operating system 161, as a software middleware between the hardware layer 21 and the application layer 31, is a computer program that manages and controls hardware and software resources.
在一个实施例中,操作系统161包括内核23,硬件抽象层(hardware abstraction layer,HAL)25、库和运行时(libraries and runtime)27以及框架(framework)29。其中,内核23用于提供底层系统组件和服务,例如:电源管理、内存管理、文件系统管理、线程管理、硬件驱动程序等;硬件驱动程序包括Wi-Fi驱动、传感器驱动、定位模块驱动等。硬件抽象层25是对内核驱动程序的封装,向框架29提供接口,屏蔽低层的实现细节。硬件抽象层25运行在用户空间,而内核驱动程序运行在内核空间。In one embodiment, the operating system 161 includes a kernel 23, a hardware abstraction layer (HAL) 25, a library and runtime (libraries and runtime) 27, and a framework 29. Among them, the kernel 23 is used to provide underlying system components and services, such as: power management, memory management, file system management, thread management, hardware drivers, etc.; hardware drivers include Wi-Fi drivers, sensor drivers, positioning module drivers, etc. The hardware abstraction layer 25 encapsulates the kernel driver, provides an interface to the framework 29, and shields low-level implementation details. The hardware abstraction layer 25 runs in the user space, and the kernel driver runs in the kernel space.
库和运行时27也叫做运行时库,它为可执行程序在运行时提供所需要的库文件和执行环境。The library and runtime 27 is also called the runtime library, which provides the required library files and execution environment for the executable program at runtime.
框架29用于为应用层31中的应用程序提供各种基础的公共组件和服务,比如窗口管理、位置管理等等。The framework 29 is used to provide various basic public components and services for applications in the application layer 31, such as window management, location management, and so on.
以上描述的操作系统161的各个组件的功能均可以由应用处理器101执行存储器105中存储的程序来实现。The functions of the various components of the operating system 161 described above can all be implemented by the application processor 101 executing a program stored in the memory 105.
以存储器105包括内存和外存为例,对上述操作系统161中的内核23所具有的内存管理和文件系统管理进行解释说明,如图3所示,硬件层21可以包括内存1051和外存1052,内核23可以包括内存管理231和文件系统管理232,本申请实施例的应用处理器101可以被配置用于执行存储器105中的计算机程序,从而实现本申请实施例的预读取文件页的方法,以使得内存管理231可以根据状态参数信息动态调整文件预读窗口的大小,内存管理231基于该文件预读窗口的大小向文件系统管理232下发预读请求,文件系统管理232将对应的文件页从外存1052读取至内存1051中,进而提升终端设备100的使用性能。Taking the memory 105 including memory and external memory as an example, the memory management and file system management of the kernel 23 in the above operating system 161 are explained. As shown in FIG. 3, the hardware layer 21 may include a memory 1051 and an external memory 1052. The kernel 23 may include a memory management 231 and a file system management 232. The application processor 101 of the embodiment of the present application may be configured to execute the computer program in the memory 105, thereby implementing the method for pre-reading file pages in the embodiment of the present application , So that the memory management 231 can dynamically adjust the size of the file pre-reading window based on the status parameter information. The memory management 231 issues a pre-reading request to the file system management 232 based on the size of the file pre-reading window, and the file system management 232 will assign the corresponding file Pages are read from the external storage 1052 into the memory 1051, thereby improving the performance of the terminal device 100.
需要说明的是,上述外存也可以称之为外部存储器。It should be noted that the above-mentioned external memory may also be referred to as an external memory.
所属领域的技术人员可以理解终端100可包括比图1所示的更少或更多的部件,图1所示的该终端设备仅包括与本申请实施例所公开的多个实现方式更加相关的部件。Those skilled in the art can understand that the terminal 100 may include fewer or more components than those shown in FIG. 1, and the terminal device shown in FIG. 1 only includes those that are more relevant to the multiple implementations disclosed in the embodiments of the present application. part.
本申请所述涉及的“文件”,指以存储器为载体存储在终端设备上的信息集合。文件可以是文本文档、图片、音视频、可执行程序等等。The “file” mentioned in this application refers to a collection of information stored on a terminal device using a memory as a carrier. Files can be text documents, pictures, audio and video, executable programs, and so on.
本申请所述涉及的“文件页”,指文件的组成单元,操作系统可以以文件页为单位执行对文件的I/O,以便于内存管理。如上所述的文件可以包括一个或多个文件页,每个文件页的大小相等,例如,可以是4千字节(KB)。每个文件页对应不同的序号。The “file page” mentioned in this application refers to the constituent unit of the file. The operating system can perform I/O to the file in the unit of the file page to facilitate memory management. The file as described above may include one or more file pages, and the size of each file page is equal, for example, it may be 4 kilobytes (KB). Each document page corresponds to a different serial number.
为了便于理解,本申请以下实施例将以具有图1至图3所示结构的终端设备为例,结合附图对本申请实施例提供的预读取文件页的方法进行解释说明。For ease of understanding, the following embodiments of the present application will take the terminal device having the structure shown in FIG. 1 to FIG. 3 as an example, and explain the method for pre-reading document pages provided by the embodiments of the present application in conjunction with the accompanying drawings.
图4A为本申请实施例的一种预读取文件页的方法流程图,如图4A所示,本实施例的方法可以由终端设备或终端设备的处理器执行,该处理器可以是应用处理器。该方法可以包括:FIG. 4A is a flowchart of a method for pre-reading document pages according to an embodiment of the application. As shown in FIG. 4A, the method in this embodiment may be executed by a terminal device or a processor of the terminal device, and the processor may be an application processor. Device. The method can include:
步骤101、获取状态参数信息。Step 101: Obtain status parameter information.
该状态参数信息可以用于表示内存使用状态或I/O处理状态中至少一项。该内存使用状态可以理解为计算机程序、计算机程序运行过程中所产生的数据、缓存数据(例如,缓存文件页)等对内存的占用情况,也可以理解为内存可供使用的情况。I/O处理状态可以理 解为对I/O请求的处理情况,例如,需要处理的I/O请求个数。The status parameter information can be used to indicate at least one of the memory usage status or the I/O processing status. The memory usage state can be understood as the occupancy of the memory by the computer program, data generated during the running of the computer program, cached data (for example, cache file pages), etc., and can also be understood as the situation where the memory is available for use. The I/O processing status can be understood as the processing status of the I/O request, for example, the number of I/O requests that need to be processed.
示例性的,该状态参数信息可以包括内存参数或I/O参数中至少一项。该内存参数可以包括内存占用量、内存使用率、或缺页累计次数中至少一项。该I/O参数可以包括I/O队列长度、或I/O请求数据量中至少一项。Exemplarily, the state parameter information may include at least one of a memory parameter or an I/O parameter. The memory parameter may include at least one of memory usage, memory usage, or cumulative number of page faults. The I/O parameter may include at least one of the length of the I/O queue or the amount of I/O request data.
在一些实施例中,可以在触发预读取文件页时获取上述状态参数信息;或者,以预设周期获取上述状态参数信息。示例性的,触发预读取文件页的方式可以是在处理用户态发出的文件页读请求时,判断是否缺页,该缺页指的是需要读取的文件页不在内存中,若发生缺页,则触发预读取文件页,该预读取文件页的方式也可以称为同步预读,即文件预读窗口包括了当前访问的文件页。触发预读取文件页的另一种方式可以是在顺序读场景下对当前访问文件页之后的一部分文件页提前进行预读,该预读取文件页的方式也可以称为异步预读,即在不发生缺页时也可以对当前访问文件页之后的一部分页提前进行预读。In some embodiments, the above-mentioned state parameter information may be obtained when the pre-fetching of the document page is triggered; or, the above-mentioned state parameter information may be obtained in a preset period. Exemplarily, the way to trigger the pre-reading of the file page may be to determine whether the page is missing when processing the file page read request issued by the user mode. The page missing refers to the file page that needs to be read is not in the memory. Page, the pre-fetching of the file page is triggered. This method of pre-fetching the file page can also be called synchronous pre-reading, that is, the file pre-reading window includes the currently accessed file page. Another way to trigger pre-fetching file pages can be to pre-read part of the file pages after the currently accessed file page in the sequential read scenario. This method of pre-fetching file pages can also be called asynchronous pre-reading, that is, It is also possible to pre-read part of the pages after the currently accessed file page when there is no page fault.
一种举例说明,应用层31可以通过read()、mmap()等系统调用读取文件页,操作系统161可以通过如上所述的方式确定是否触发预读取文件页,在触发预读取文件时,上述图3所示的内存管理231可以获取该状态参数信息。As an example, the application layer 31 can read the file page through system calls such as read(), mmap(), etc. The operating system 161 can determine whether to trigger the pre-fetching of the file page in the above-mentioned manner. At this time, the memory management 231 shown in FIG. 3 can obtain the state parameter information.
步骤102、根据状态参数信息确定文件预读窗口的大小。Step 102: Determine the size of the file pre-reading window according to the state parameter information.
该文件预读窗口用于表示一个文件中的一个或多个文件页的集合,例如,该文件预读窗口的一种具体形式可以是一组连续的文件页序号,该文件预读窗口的另一种具体形式可以是起始文件页序号和结束文件页序号,该文件预读窗口的再一种具体形式可以是起始文件页序号和窗口长度,该窗口长度的单位为文件页,需要说明的是,该文件预读窗口还可以是其他具体形式,例如,窗口长度和结束文件页序号等,本申请实施例不一一举例说明。以图4B对文件预读窗口进行示意性说明,如图4B所示,该文件预读窗口1从第1个文件页开始到第4个文件页结束,该文件预读窗口2从第1个文件页开始到第6个文件页结束。The file pre-reading window is used to represent a collection of one or more file pages in a file. For example, a specific form of the file pre-reading window may be a set of consecutive file page numbers, and the other A specific form can be the start file page number and the end file page number. Another specific form of the file pre-reading window can be the start file page number and the window length. The unit of the window length is the file page, which needs to be explained. However, the file pre-reading window may also be in other specific forms, such as the length of the window and the sequence number of the ending file page, etc. The embodiments of this application will not illustrate one by one. The file pre-reading window is schematically illustrated in Figure 4B. As shown in Figure 4B, the file pre-reading window 1 starts from the first file page to the end of the fourth file page, and the file pre-read window 2 starts from the first file page. The document page starts to the end of the 6th document page.
本申请实施例可以根据该状态参数信息确定文件预读窗口的大小,即窗口长度,该窗口长度可以是该文件预读窗口所包括的文件页的个数,例如,如图4B所示的文件预读窗口1的窗口长度为4。例如,根据该状态参数信息确定内存占用量大于预设阈值时,可以确定文件预读窗口的大小为一个较小的数值,例如如图4B所示的文件预读窗口1,从而在内存使用压力较大时,减少预读取的文件页。根据该状态参数信息确定内存占用量小于预设阈值时,可以确定文件预读窗口的大小为一个较大的数值,例如如图4B所示的文件预读窗口2,从而在内存空间空闲时,增加预读取的文件页。The embodiment of the present application can determine the size of the file pre-reading window, that is, the window length, according to the state parameter information, and the window length can be the number of file pages included in the file pre-reading window, for example, the file shown in FIG. 4B The window length of the pre-reading window 1 is 4. For example, when it is determined according to the state parameter information that the memory usage is greater than the preset threshold, the size of the file pre-reading window can be determined to be a small value, such as the file pre-reading window 1 shown in Figure 4B, so that the memory usage pressure When it is larger, reduce the pre-fetched file pages. When it is determined according to the state parameter information that the memory usage is less than the preset threshold, the size of the file pre-reading window can be determined to be a larger value, such as the file pre-reading window 2 shown in FIG. 4B, so that when the memory space is free, Increase the pre-read file page.
在一些实施例中,当状态参数信息指示内存使用压力或IO处理压力中至少一项处于第一级别时,减小该文件预读窗口的大小;当该状态参数信息指示该内存使用压力或IO处理压力中至少一项处于第二级别时,增大该文件预读窗口的大小;其中,该第一级别的内存使用压力或IO处理压力大于该第二级别的内存使用压力或IO处理压力。例如,该第一级别可以是指内存使用压力和/或IO处理压力较大的级别,该第二级别可以是指内存使用压力和/或IO处理压力较大的级别。例如,上述内存占用量大于预设阈值,则内存使用压力处于第一级别,内存占用量小于预设阈值,则内存使用压力处于第二级别。In some embodiments, when the state parameter information indicates that at least one of the memory usage pressure or the IO processing pressure is at the first level, the size of the file pre-reading window is reduced; when the state parameter information indicates the memory usage pressure or IO When at least one of the processing pressures is at the second level, the size of the file pre-reading window is increased; wherein the first level of memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure. For example, the first level may refer to a level where memory usage pressure and/or IO processing pressure is relatively high, and the second level may refer to a level where memory use pressure and/or IO processing pressure is relatively high. For example, if the aforementioned memory usage is greater than the preset threshold, the memory usage pressure is at the first level, and if the memory usage is less than the preset threshold, the memory usage pressure is at the second level.
上述减小该文件预读窗口的大小的一种可实现方式可以为将该文件预读窗口的大小重新设置为一个数值,该数值小于原有的大小,另一种可实现方式可以为将该文件预读窗 口的大小在原有基础上减小一个数值。One achievable way to reduce the size of the file pre-reading window above can be to reset the size of the file pre-reading window to a value that is smaller than the original size, and another achievable way can be to reset the size of the file pre-reading window to a value smaller than the original size. The size of the file pre-reading window is reduced by a value on the original basis.
对于文件预读窗口的位置,可以根据触发预读取文件页的位置确定,例如,可以根据缺页位置确定,本申请实施例不以此作为限制。The position of the file pre-reading window can be determined according to the position of triggering the pre-reading of the document page, for example, it can be determined according to the position of the page missing, which is not limited in the embodiment of the present application.
一种举例说明,上述图3所示的内存管理231获取该状态参数信息后,可以根据该状态参数信息确定文件预读窗口的大小。As an example, after the memory management 231 shown in FIG. 3 obtains the state parameter information, it can determine the size of the file pre-reading window according to the state parameter information.
步骤103、根据文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问文件页。Step 103: Read the corresponding file page from the external storage device into the memory according to the file pre-reading window, so as to access the file page by the application layer.
示例性的,上述图3所示的内存管理231确定文件预读窗口的大小后,可以基于该文件预读窗口的大小向文件系统管理232下发预读请求,文件系统管理232将对应的文件页从外存1052读取至内存1051中。Exemplarily, after the memory management 231 shown in FIG. 3 determines the size of the file pre-reading window, it may issue a pre-reading request to the file system management 232 based on the size of the file pre-reading window, and the file system management 232 will assign the corresponding file The page is read from the external memory 1052 to the memory 1051.
本申请实施例基于文件预读窗口预读取相应的文件页,可以在内存使用压力较大和/或I/O处理压力较大时,减少预读取的文件页。在内存使用压力较小和/或I/O处理压力较小时,增加预读取的文件页。即可以基于文件预读窗口自适应的调节预读操作对内存资源的占用,以提升终端设备的使用性能。The embodiment of the present application pre-reads the corresponding file pages based on the file pre-reading window, which can reduce the pre-read file pages when the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is low and/or the I/O processing pressure is low, increase the pre-fetched file pages. That is, the occupation of memory resources by the pre-reading operation can be adaptively adjusted based on the file pre-reading window, so as to improve the use performance of the terminal device.
本实施例,通过获取状态参数信息,该状态参数信息可以用于表示内存使用状态或I/O处理状态中至少一项,根据状态参数信息确定文件预读窗口的大小,根据文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问文件页,可以基于状态参数信息自适应的调节文件预读窗口的大小,进而根据文件预读窗口的大小进行预读操作,基于不同的文件预读窗口的大小进行预读操作的文件页的个数不同,预读操作的文件页对内存资源的占用不同,从而实现自适应调节预读操作对内存资源的占用。例如,可以基于状态参数信息确定内存使用压力较大和/或I/O处理压力较大,在内存使用压力较大和/或I/O处理压力较大时,减少预读窗口的大小,从而减少预读操作所述读取的文件页,从而可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。In this embodiment, by acquiring the status parameter information, the status parameter information can be used to indicate at least one of the memory usage status or the I/O processing status. The size of the file pre-reading window is determined according to the status parameter information, and the file pre-reading window is read from The external storage device reads the corresponding file page into the memory, and accesses the file page by the application layer. It can adaptively adjust the size of the file pre-reading window based on the state parameter information, and then perform the pre-reading operation according to the size of the file pre-reading window. The number of file pages for pre-reading operations based on the size of different file pre-reading windows is different, and the file pages for pre-reading operations occupies different memory resources, so as to achieve adaptive adjustment of the pre-reading operation's occupancy of memory resources. For example, it can be determined based on the state parameter information that the memory usage pressure is high and/or the I/O processing pressure is high. When the memory usage pressure is high and/or the I/O processing pressure is high, the size of the pre-reading window is reduced, thereby reducing the pre-reading window. The read operation of the read file page can alleviate the slow response and stalling of the application program, thereby improving the use performance of the terminal device.
下面采用几个具体的实施例,对图4A所示方法实施例的技术方案进行详细说明。Several specific embodiments are used below to describe in detail the technical solution of the method embodiment shown in FIG. 4A.
图5为本申请实施例的另一种预读取文件页的方法流程图,如图5所示,本实施例的方法可以由终端设备或终端设备的处理器执行,本实施例以状态参数信息包括内存参数和I/O参数为例进行举例说明,该方法可以包括:FIG. 5 is a flowchart of another method for pre-reading document pages according to an embodiment of this application. As shown in FIG. 5, the method in this embodiment may be executed by a terminal device or a processor of a terminal device. The information includes memory parameters and I/O parameters as examples. The method can include:
步骤201、获取内存参数和I/O参数。Step 201: Obtain memory parameters and I/O parameters.
该内存参数和I/O参数的具体解释说明可以参见图4A所示实施例的步骤101的解释说明,此处不再赘述。For specific explanations of the memory parameters and I/O parameters, please refer to the explanations of step 101 in the embodiment shown in FIG. 4A, which will not be repeated here.
步骤202、根据内存参数和I/O参数确定第一指标。Step 202: Determine a first index according to the memory parameter and the I/O parameter.
本申请实施例可以对内存参数和I/O参数采用求和、加权求和等方式确定第一指标,该第一指标也可以称之为综合压力指标。本申请实施例用X表示该第一指标的取值,X的取值越大,表示内存使用压力和/或I/O处理压力越大,即内存使用率越高和/或I/O队列长度越大。当然可以理解的,也可以设置X的取值越小,表示内存使用压力和/或I/O处理压力越大,即内存使用率越高和/或I/O队列长度越大。本申请实施例以X的取值越大,表示内存使用压力和/或I/O处理压力越大为例进行举例说明。In the embodiment of the present application, the first index may be determined by means of summation, weighted summation, etc. for memory parameters and I/O parameters, and the first index may also be referred to as a comprehensive pressure index. In the embodiment of this application, X represents the value of the first indicator. The larger the value of X, the greater the memory usage pressure and/or the I/O processing pressure, that is, the higher the memory usage rate and/or the I/O queue. The greater the length. Of course, it is understandable that the smaller the value of X can also be set, which means the greater the memory usage pressure and/or the I/O processing pressure, that is, the higher the memory usage and/or the larger the length of the I/O queue. In the embodiment of the present application, the larger the value of X, the larger the memory usage pressure and/or the I/O processing pressure is taken as an example for illustration.
步骤203、根据第一指标确定文件预读窗口的大小。Step 203: Determine the size of the file pre-reading window according to the first indicator.
例如,上述图3所示的内存管理231可以根据该第一指标确定文件预读窗口的大小。For example, the memory management 231 shown in FIG. 3 may determine the size of the file pre-reading window according to the first indicator.
一种可实现方式,可以设定n个阈值,X1<X2<…<Xn,该n个阈值可以将X的取值范围划分为(n+1)个数值区间,该(n+1)个数值区间可以为:[0,X1],(X1,X2],……,(Xn,∞),设置每一个数值区间对应一个窗口大小,上述(n+1)个数值区间对应的窗口大小依次减小。上述步骤203的一种可实现方式为:根据第一指标确定第一指标所属的数值区间,将第一指标所属的数值区间对应的窗口大小作为文件预读窗口的大小。An achievable way, you can set n thresholds, X1<X2<...<Xn, the n thresholds can divide the value range of X into (n+1) numerical intervals, the (n+1) The numerical interval can be: [0, X1], (X1, X2], ……, (Xn, ∞), set each numerical interval to correspond to a window size, and the above (n+1) numerical intervals correspond to the corresponding window sizes in order Reduce. One possible implementation of the above step 203 is to determine the numerical interval to which the first indicator belongs according to the first indicator, and use the window size corresponding to the numerical interval to which the first indicator belongs as the size of the file pre-reading window.
步骤204、根据文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问文件页。Step 204: Read the corresponding file page from the external storage device into the memory according to the file pre-reading window, so as to access the file page by the application layer.
其中,步骤204的解释说明可以参见图4A所示实施例的步骤103,此处不再赘述。For the explanation of step 204, refer to step 103 of the embodiment shown in FIG. 4A, which will not be repeated here.
本实施例,通过获取内存参数和I/O参数,根据内存参数和I/O参数确定第一指标,根据第一指标确定文件预读窗口的大小,根据文件预读窗口从外部存储设备读取相应的文件页至内存中,以供应用层访问文件页,实现基于内存参数和I/O参数自适应的调节预读操作对内存资源的占用,在内存使用压力较大和/或I/O处理压力较大时,减少预读窗口的大小,从而减少预读操作所述读取的文件页,从而可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。In this embodiment, by acquiring memory parameters and I/O parameters, the first index is determined according to the memory parameters and I/O parameters, the size of the file pre-reading window is determined according to the first index, and the file pre-reading window is read from the external storage device according to the first index. Corresponding file pages are stored in the memory, and the file pages are accessed at the application layer to achieve adaptive adjustments based on memory parameters and I/O parameters on the occupation of memory resources by pre-reading operations. The memory usage pressure is high and/or I/O processing When the pressure is high, the size of the pre-reading window is reduced, thereby reducing the file pages read in the pre-reading operation, so as to alleviate the slow response and freezing of the application startup, thereby improving the use performance of the terminal device.
在上述任一实施例的基础上,本申请实施例还可以使用预读模型增加预读命中率,即提升从外部存储设备读取至内存中的文件页被应用层访问的机率,从而减少无效预读。其具体实施方式可以参见下述实施例的解释说明。On the basis of any of the foregoing embodiments, the embodiments of the present application can also use the pre-reading model to increase the pre-reading hit rate, that is, to increase the probability that the file page read from the external storage device into the memory is accessed by the application layer, thereby reducing invalidity. Pre-reading. For the specific implementation, please refer to the explanation of the following examples.
上述步骤103或上述步骤204的一种可实现方式为:根据预读模型选取文件预读窗口内的至少一个文件页,作为预读取页,将预读取页从外部存储设备读取至内存中,其中,该预读模型为根据文件访问实时数据和文件访问历史数据确定的内存中的数据结构,该预读模型与文件对应,该文件访问实时数据与该文件访问历史数据不同步,该文件访问历史数据为该外部存储设备中的数据。One possible implementation of the above step 103 or the above step 204 is: select at least one file page in the file pre-reading window according to the pre-reading model as the pre-read page, and read the pre-read page from the external storage device to the memory Wherein, the pre-reading model is a data structure in the memory determined based on the file access real-time data and the file access historical data. The pre-reading model corresponds to the file. The file access real-time data is not synchronized with the file access historical data. The file access history data is the data in the external storage device.
该文件访问历史数据可以包括本次打开文件之前的读访问请求的位置、长度、或时间中至少一项。该文件访问历史数据可以来源于外部存储设备,例如,该文件访问历史数据可以包括本次打开文件之前应用层所访问的该文件的文件页序号,举例而言,该文件访问历史数据可以包括2、3和10,即表示本次打开文件之前应用层访问了该文件的序号为2、3和10的文件页。该文件访问实时数据可以包括本次打开文件之后的读访问请求的位置、长度、或时间中至少一项,例如,该文件访问实时数据可以包括本次打开文件之后至本次关闭文件之前的读访问请求的位置、长度、或时间中至少一项,即该文件访问实时数据即为应用层对文件进行访问过程中所产生的数据,例如,该文件访问实时数据可以包括应用层所访问的该文件的文件页序号,举例而言,该文件访问实时数据可以包括1、2和10,即表示应用层访问了该文件的序号为1、2和10的文件页。当然可以理解的,上述文件访问历史数据和上述文件访问实时数据也可以是比特位图,例如,该文件访问历史数据可以包括2、3和10,假设该文件访问历史数据对应的文件有11个文件页,则该文件访问历史数据可以是01100000010。The file access history data may include at least one of the location, length, or time of the read access request before the file is opened this time. The file access history data may come from an external storage device. For example, the file access history data may include the file page number of the file accessed by the application layer before the file is opened this time. For example, the file access history data may include 2 , 3, and 10, which means that the application layer has accessed the file pages with serial numbers 2, 3, and 10 before opening the file this time. The file access real-time data may include at least one of the location, length, or time of the read access request after the file is opened this time. For example, the file access real-time data may include the reading after the file is opened this time to before the file is closed this time. At least one of the location, length, or time of the access request, that is, the file access real-time data is the data generated in the process of accessing the file by the application layer. For example, the file access real-time data may include the file accessed by the application layer. The file page sequence number of the file. For example, the file access real-time data may include 1, 2, and 10, which means that the application layer has accessed the file page of the file with sequence numbers 1, 2, and 10. Of course, it is understandable that the above-mentioned file access history data and the above-mentioned file access real-time data may also be bitmaps. For example, the file access history data may include 2, 3, and 10, assuming that there are 11 files corresponding to the file access history data. File page, the file access history data can be 01100000010.
该预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的内存中的数据结构,一种可实现方式,该预读模型可以是比特位图(bitmap),例如,该预读模型可以包括N个比特位,每个比特位对应文件的一个文件页,每个比特位用于表示比特位对应的文件页是否被访问,N为大于或等于1的整数。比特位取0时表示对应的文件页未被 访问过,比特位取1时表示对应的文件页被访问过,当然可以理解的,也可以使用比特位取1时表示对应的文件页未被访问过,比特位取0时表示对应的文件页被访问过。本申请实施例以比特位取0时表示对应的文件页未被访问过,比特位取1时表示对应的文件页被访问过为例进行举例说明。被访问过或未被访问过指在应用程序启动过程中或运行过程中被访问过或未被访问过。以文件A包括15个文件页,第1、2、3和10个文件页被访问过(包括历史和实时)为例,该文件A的预读模型可以是111000000100000。The pre-reading model is a data structure in the memory determined according to at least one of the file access real-time data and the file access historical data. It is an achievable way. The pre-reading model may be a bitmap. For example, the pre-reading model may be a bitmap. The read model may include N bits, each bit corresponds to a file page of the file, and each bit is used to indicate whether the file page corresponding to the bit is accessed, and N is an integer greater than or equal to 1. When the bit is set to 0, it indicates that the corresponding file page has not been accessed. When the bit is set to 1, it means that the corresponding file page has been accessed. Of course, understandable, you can also use the bit to set 1 to indicate that the corresponding file page has not been accessed. However, when the bit is set to 0, it indicates that the corresponding file page has been accessed. In the embodiment of the present application, when the bit is set to 0, it indicates that the corresponding file page has not been accessed, and when the bit is set to 1, it indicates that the corresponding file page has been accessed as an example for illustration. Visited or unvisited means that the application has been visited or has not been visited during the startup or running of the application. Taking file A includes 15 file pages, and the first, second, third, and tenth file pages have been accessed (including historical and real-time) as an example, the pre-reading model of file A may be 111000000100000.
本申请实施例在基于状态参数信息确定文件预读窗口后,可以基于预读模型,在该文件预读窗口内选取一个或多个文件页作为预读取页,将该预读取页从外部存储设备读取至内存中。以文件A的预读模型是111000000100000为例做进一步举例说明,通过上述实施例确定的文件预读窗口为从第1个文件页起始,窗口长度11,根据该文件A的预读模型可以选取文件预读窗口内的第1、2、3和10个文件页作为预读取页,将第1、2、3和10个文件页从外部存储设备读取至内存中,而对文件A的文件预读窗口内的其余文件页不作预读操作,从而降低预读操作对内存的占用,减少无效预读。After the document pre-reading window is determined based on the state parameter information in the embodiment of the application, one or more document pages can be selected as the pre-reading page in the document pre-reading window based on the pre-reading model, and the pre-reading page is externally selected. The storage device is read into the memory. Taking the pre-reading model of file A as an example of 111000000100000 for further illustration, the file pre-reading window determined by the above embodiment starts from the first file page, and the window length is 11, which can be selected according to the pre-reading model of file A The first, second, third, and tenth file pages in the file pre-reading window are used as pre-fetch pages. The first, second, third, and tenth file pages are read from the external storage device to the internal memory. The remaining file pages in the file pre-reading window do not perform pre-reading operations, thereby reducing the memory occupation of pre-reading operations and reducing invalid pre-reading.
图6A为本申请实施例的另一种预读取文件页的方法流程图,如图6A所示,本实施例的方法可以由终端设备或终端设备的处理器执行,本实施例的方法可以包括:FIG. 6A is a flowchart of another method for pre-reading document pages according to an embodiment of this application. As shown in FIG. 6A, the method in this embodiment may be executed by a terminal device or a processor of a terminal device, and the method in this embodiment may include:
步骤301、获取状态参数信息。Step 301: Obtain status parameter information.
步骤302、根据状态参数信息确定文件预读窗口的大小。Step 302: Determine the size of the file pre-reading window according to the status parameter information.
其中,步骤301和步骤302的解释说明可以参见图4A所示实施例的步骤101和步骤102,此处不再赘述。For the explanation of step 301 and step 302, please refer to step 101 and step 102 of the embodiment shown in FIG. 4A, which will not be repeated here.
步骤303、根据预读模型选取文件预读窗口内的至少一个文件页,作为预读取页。Step 303: Select at least one document page in the document pre-reading window according to the pre-reading model as the pre-read page.
其中,该预读模型以及根据预读模型选取预读取页的解释说明可以参见上述实施例,此处不再赘述。For the explanation of the pre-reading model and the selection of pre-reading pages according to the pre-reading model, please refer to the above-mentioned embodiment, which will not be repeated here.
步骤304、判断预读取页所构成的片段的个数是否大于第一阈值,若是,则执行步骤305,若否,则执行步骤306。Step 304: Determine whether the number of fragments formed by the pre-fetched page is greater than the first threshold, if yes, execute step 305, and if not, execute step 306.
本申请所述涉及的“片段”,指一个文件中若干个序号连续的文件页。The "fragment" mentioned in this application refers to a number of consecutive document pages in a document.
如上所述一个文件中若干个序号连续的文件页可以构成一个片段,本申请实施例可以基于预读取页所构成的片段的个数确定最终预读取的文件页,以上述选取文件A的第1、2、3和10个文件页作为预读取页为例做进一步举例说明,其中,第1、2和3个文件页可以构成一个片段,第10页为一个片段,所以,该预读取页所构成的片段的个数为2个,将该预读取页所构成的片段的个数(2个)与该第一阈值比较,若大于,则通过下述步骤305读取文件预读窗口内的所有页,例如,读取文件A的第1个至第11个文件页,若小于或等于,则通过下述步骤306读取预读取的文件页,例如,读取文件A的第1、2、3、10个文件页。该第一阈值的取值可以是3、4、5等,其可以根据需求进行灵活设置。该第一阈值也可以根据当前内存使用状态和/或I/O处理状态进行动态调整。As described above, several document pages with consecutive serial numbers in a file can constitute a fragment. The embodiment of the present application can determine the final pre-read document page based on the number of fragments constituted by the pre-read page, and select the document A as described above. The first, second, third, and tenth document pages are taken as the pre-read page as an example for further illustration. Among them, the first, second, and third document pages can constitute a fragment, and the tenth page is a fragment. Therefore, the pre-read page The number of fragments formed by the read page is 2, and the number (2) of fragments formed by the pre-read page is compared with the first threshold. If it is greater, the file is read through the following step 305 Pre-read all pages in the window, for example, read the first to eleventh file pages of file A. If it is less than or equal to, read the pre-read file pages through the following step 306, for example, read the file Pages 1, 2, 3, and 10 of A. The value of the first threshold can be 3, 4, 5, etc., which can be flexibly set according to requirements. The first threshold may also be dynamically adjusted according to the current memory usage status and/or I/O processing status.
步骤305、将文件预读窗口内的所有文件页从外部存储设备读取至内存中。Step 305: Read all file pages in the file pre-reading window from the external storage device into the memory.
在预读取页所构成的片段的个数大于第一阈值时,即片段个数较多,由于较多的片段个数会导致I/O碎片化,影响I/O处理效率,所以本申请实施例在片段个数较多时,将文件预读窗口内的所有文件页从外部存储设备读取至内存中,以避免I/O碎片化。When the number of fragments constituted by the pre-fetched page is greater than the first threshold, that is, the number of fragments is large. Since a large number of fragments will cause I/O fragmentation and affect the efficiency of I/O processing, this application In the embodiment, when the number of fragments is large, all file pages in the file pre-reading window are read from the external storage device into the memory to avoid I/O fragmentation.
步骤306、将预读取页从外部存储设备读取至内存中。Step 306: Read the pre-fetched page from the external storage device into the memory.
在预读取页所构成的片段的个数小于或等于第一阈值时,可以将预读取页从外部存储设备读取至内存中,文件预读窗口内的除预读取页之外的其余文件页不作预读操作,从而降低预读操作对内存的占用,减少无效预读。When the number of fragments formed by the pre-fetch page is less than or equal to the first threshold, the pre-fetch page can be read from the external storage device into the memory, and the file pre-fetch window except for the pre-fetch page The remaining file pages do not perform pre-reading operations, thereby reducing the memory occupation of pre-reading operations and reducing invalid pre-reading.
在一些实施例中,在执行步骤305或步骤306时,本申请实施例的方法还可以根据文件预读窗口中的最后一个文件页对应的比特位确定是否将文件预读窗口外的文件页读取至内存中。举例而言,按照预读模型,文件预读窗口中的最后一个文件页对应的比特值为1,则可以越过文件预读窗口的范围,继续向后依次检查每个文件页对应的比特位值,直到确定出一个完整的片段(即找到预读窗口之后第一个值为0的比特,或者检查到文件的最后一个页),并将其中的文件页全部读取至内存中。也可以设置一个第二阈值,当本次预读选中的文件页总数(步骤305或步骤306中需要读取至内存中的文件页的个数和文件预读窗口外需要读取至内存中的文件页的个数)大于或等于该第二阈值时,则停止向后检查。In some embodiments, when step 305 or step 306 is performed, the method of the embodiment of the present application may also determine whether to read the file page outside the file pre-reading window according to the bit corresponding to the last file page in the file pre-reading window. Take it to the memory. For example, according to the pre-reading model, if the bit value corresponding to the last file page in the file pre-reading window is 1, you can go beyond the range of the file pre-reading window and continue to check the bit value corresponding to each file page in turn. , Until a complete segment is determined (that is, the first bit with a value of 0 after the pre-reading window is found, or the last page of the file is checked), and all of the file pages are read into the memory. A second threshold can also be set. When the total number of file pages selected for pre-reading this time (the number of file pages that need to be read into the memory in step 305 or step 306, and the number of file pages that need to be read into the memory outside the file pre-reading window) When the number of document pages is greater than or equal to the second threshold, the backward check is stopped.
以文件A的预读模型是[1110 0001]1111 1100为例作进一步举例说明,其中[]之内为文件预读窗口。若不设第二阈值,则将文件A的第1~3和第8~14个页选为预读取页;若第二阈值设为8,即本次预读最多选8个文件页,则将第1~3和第8~12个页选为预读取页。Take the pre-reading model of file A as [1110 0001]1111 1100 as an example for further illustration, where [] is the file pre-reading window. If the second threshold is not set, then the 1st to 3rd and 8th to 14th pages of file A will be selected as pre-read pages; if the second threshold is set to 8, that is, at most 8 document pages will be selected for pre-reading this time. Then select the 1st to 3rd and 8th to 12th pages as pre-read pages.
示例性的,上述步骤305的一种可实现方式为,判断文件预读窗口的最后一个文件页对应的比特位是否表示最后一个文件页被访问。当最后一个文件页对应的比特位表示最后一个文件页被访问时,将文件预读窗口内的所有文件页和文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中。当最后一个文件页对应的比特位表示最后一个文件页未被访问时,将文件预读窗口内的所有文件页从外部存储设备读取至内存中。其中,文件预读窗口之后的至少一个文件页与文件预读窗口的最后一个文件页属于同一片段。Exemplarily, an achievable manner of the above step 305 is to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed. When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are read from the external storage device into the memory. When the bit corresponding to the last file page indicates that the last file page has not been accessed, all file pages in the file pre-reading window are read from the external storage device into the memory. Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
可选的,将文件预读窗口内的所有文件页和文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中的一种可实现方式为,将文件预读窗口内的所有文件页和文件预读窗口之后的至少一个文件页中的M个文件页从外部存储设备读取至内存中。该M可以表示第二阈值。Optionally, an achievable way to read all the file pages in the file pre-reading window and at least one file page after the file pre-reading window from the external storage device into the memory is to read all the file pages in the file pre-reading window. The file page and the M file pages in at least one file page after the file pre-reading window are read from the external storage device into the memory. The M may represent the second threshold.
示例性的,上述步骤306的一种可实现方式,判断文件预读窗口的最后一个文件页对应的比特位是否表示该最后一个文件页被访问。当该最后一个文件页对应的比特位表示最后一个文件页被访问时,将预读取页和文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中。当该最后一个文件页对应的比特位表示该最后一个文件页未被访问时,将该预读取页从外部存储设备读取至内存中。其中,该文件预读窗口之后的至少一个文件页与该文件预读窗口的最后一个文件页属于同一片段。Exemplarily, an implementation manner of the above step 306 is to determine whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed. When the bit corresponding to the last file page indicates that the last file page is accessed, read the pre-read page and at least one file page after the file pre-read window from the external storage device into the memory. When the bit corresponding to the last file page indicates that the last file page has not been accessed, the pre-fetched page is read from the external storage device into the memory. Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
可选的,将预读取页和文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中的一种可实现方式为,将预读取页和文件预读窗口之后的至少一个文件页中的M个文件页从外部存储设备读取至内存中。Optionally, an achievable way of reading the pre-fetch page and at least one file page after the file pre-reading window from the external storage device into the memory is to read the pre-fetch page and at least one file page after the file pre-reading window. The M file pages in one file page are read from the external storage device into the memory.
以图6B做举例说明,如图6B所示,文件B的预读模型是10101100,文件预读窗口为第1~第5个文件页,其中,黑色方块表示预读模型的对应比特位为1,白色方块表示预读模型的对应比特位为0。通过上述步骤305上述可实现方式,可以确定该文件预读窗口的最后一个文件页(第5个文件页)对应的比特位表示被访问,则可以将文件预读窗口内的所有文件页(第1~第5个文件页)和文件预读窗口之后的至少一个文件页(例如第6个 文件页)从外部存储设备读取至内存中。或者,通过上述步骤306上述可实现方式,可以确定该文件预读窗口的最后一个文件页(第5个文件页)对应的比特位表示被访问,则可以将文件预读窗口内的预读取页(第1、第3和第5个文件页)和文件预读窗口之后的至少一个文件页(例如第6个文件页)从外部存储设备读取至内存中。Take Figure 6B as an example. As shown in Figure 6B, the pre-reading model of file B is 10101100, and the file pre-reading window is the first to fifth file pages. The black square indicates that the corresponding bit of the pre-reading model is 1. , The white square indicates that the corresponding bit of the pre-reading model is 0. Through the above achievable method of step 305, it can be determined that the bit corresponding to the last file page (the fifth file page) of the file pre-reading window indicates that it is accessed, and then all the file pages in the file pre-reading window (the fifth file page) 1 to 5 file pages) and at least one file page after the file pre-reading window (for example, the 6th file page) is read from the external storage device into the memory. Alternatively, through the above achievable method of step 306, it can be determined that the bit corresponding to the last file page (the fifth file page) of the file pre-reading window indicates that it is accessed, and the pre-reading in the file pre-reading window can be Pages (the first, third, and fifth file pages) and at least one file page after the file pre-reading window (for example, the sixth file page) are read from the external storage device into the memory.
本实施例,通过获取状态参数信息,根据状态参数信息确定文件预读窗口的大小,根据预读模型选取文件预读窗口内的至少一个文件页,作为预读取页,判断预读取页所构成的片段的个数是否大于第一阈值,若是,则将文件预读窗口内的所有文件页从外部存储设备读取至内存中,若否,则将预读取页从外部存储设备读取至内存中,实现基于状态参数信息自适应的调节预读操作对内存资源的占用,可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。In this embodiment, by acquiring the status parameter information, the size of the file pre-reading window is determined according to the status parameter information, and at least one file page in the file pre-reading window is selected according to the pre-reading model as the pre-read page, and the location of the pre-read page Whether the number of fragments constituted is greater than the first threshold, if yes, read all file pages in the file pre-reading window from the external storage device to the memory, if not, read the pre-fetched pages from the external storage device In the memory, it realizes the occupancy of memory resources by adaptively adjusting the pre-reading operation based on the state parameter information, which can alleviate the slow response and stalling of the application startup, thereby improving the performance of the terminal device.
并且通过比较预读取页所构成的片段的个数与第一阈值的大小,在所构成的片段的个数大于第一阈值时,将文件预读窗口内的所有文件页从外部存储设备读取至内存中,可以避免由于较多的片段个数所导致的I/O碎片化,提升I/O处理效率。在所构成的片段的个数小于或等于第一阈值时,将预读取页从外部存储设备读取至内存中,文件预读窗口内的除预读取页之外的其余文件页不作预读操作,从而降低预读操作对内存的占用,减少无效预读。And by comparing the number of fragments formed by the prefetch page with the size of the first threshold, when the number of fragments formed is greater than the first threshold, all file pages in the file preread window are read from the external storage device Fetching into the memory can avoid I/O fragmentation caused by a large number of fragments, and improve the efficiency of I/O processing. When the number of fragments formed is less than or equal to the first threshold, the pre-fetched page is read from the external storage device into the memory, and the rest of the file pages in the file pre-reading window except for the pre-fetched page are not pre-fetched. Read operation, thereby reducing the memory occupation of pre-reading operation and reducing invalid pre-reading.
通过判断文件预读窗口的最后一个文件页是否被访问,在最后一个文件页被访问时,将与最后一个文件页属于同一个片段的文件页读入内存,避免因预读窗口边界的划分造成I/O碎片化(即同一片段中部分页被划分在窗口之外,下次被访问时还要再次读入,增加I/O次数),从而可以提升I/O处理效率。By judging whether the last file page of the file pre-reading window is accessed, when the last file page is accessed, the file page belonging to the same fragment as the last file page is read into the memory to avoid the division of the pre-reading window boundary I/O fragmentation (that is, some pages in the same fragment are divided out of the window, and will be read again when they are accessed next time, increasing the number of I/Os), which can improve the efficiency of I/O processing.
在上述任一实施例的基础上,本申请的预读取文件页的方法还可以根据上述预读模型更新外部存储设备中文件对应的文件访问历史数据。需要说明的是,在使用预读模型更新之前,文件对应的文件访问历史数据可以为空。On the basis of any of the foregoing embodiments, the method for pre-reading file pages of the present application can also update the file access history data corresponding to the file in the external storage device according to the foregoing pre-reading model. It should be noted that before using the pre-reading model to update, the file access history data corresponding to the file can be empty.
一种可实现方式,通过内核线程周期性的根据预读模型更新外部存储设备中文件对应的文件访问历史数据。An achievable way is to periodically update the file access history data corresponding to the file in the external storage device according to the pre-reading model through the kernel thread.
外部存储设备可以为不同的文件分配不同的读写路径,该读写路径对应的存储空间存储有与一个文件对应的文件访问历史数据。例如,在需要选取预读取页时,文件系统管理232可以从文件的读写路径对应的存储空间读取文件访问历史数据至内存中,以基于文件访问历史数据和文件访问实时数据确定预读模型。在预读取操作之后,文件系统管理232可以将预读模型按照与文件访问历史数据相同的格式,写入该文件的读写路径对应的存储空间,即更新存储空间所存储的文件访问历史数据。The external storage device can allocate different read-write paths for different files, and the storage space corresponding to the read-write path stores file access history data corresponding to one file. For example, when the pre-read page needs to be selected, the file system management 232 can read the file access history data from the storage space corresponding to the file read and write path into the memory to determine the pre-read based on the file access history data and the file access real-time data model. After the pre-read operation, the file system management 232 can write the pre-read model into the storage space corresponding to the read/write path of the file in the same format as the file access history data, that is, update the file access history data stored in the storage space .
图7为本申请实施例的另一种预读取文件页的方法流程图,如图7所示,本实施例以应用层31和操作系统161为例对本申请实施例的方法进行解释说明,本实施例的方法可以包括:FIG. 7 is a flowchart of another method for pre-reading document pages according to an embodiment of the application. As shown in FIG. 7, this embodiment uses the application layer 31 and the operating system 161 as examples to explain the method of the embodiment of the application. The method of this embodiment may include:
步骤401、应用层触发打开一个文件。Step 401: The application layer triggers to open a file.
例如,应用层的一个应用程序启动时,触发打开一个文件。For example, when an application in the application layer starts, it triggers the opening of a file.
步骤402、创建初始化的预读模型。Step 402: Create an initialized pre-reading model.
例如,创建初始化的预读模型可以是生成一个包含N个比特位的比特位图,该N个比特位的初始值均为0。For example, creating an initialized pre-reading model can be to generate a bitmap containing N bits, and the initial values of the N bits are all 0.
步骤403、判断文件对应的读写路径对应的存储空间内是否有文件访问历史数据,若是,则执行步骤404,若否,则结束。Step 403: Determine whether there is file access history data in the storage space corresponding to the read-write path corresponding to the file, if yes, execute step 404, and if not, end.
步骤404、将文件访问历史数据读入至内存中,并将文件访问历史数据解析后填充至初始化的预读模型中。Step 404: Read the file access history data into the memory, and fill the initialized pre-reading model after parsing the file access history data.
例如,该文件访问历史数据表示第1、2、3和10个文件页被访问过,则可以将上述N个比特位中的第1、2、3和10个比特位的取值更新为1。For example, if the file access history data indicates that the first, second, third, and tenth file pages have been accessed, the value of the first, second, third, and tenth bit of the above N bits can be updated to 1. .
步骤405、应用层触发访问文件的一个文件页。Step 405: The application layer triggers access to a file page of the file.
例如,应用层可以通过read()、mmap()等系统调用读取一个文件页。For example, the application layer can read a file page through system calls such as read() and mmap().
步骤406、将访问该文件页的信息记录至预读模型中。Step 406: Record the information of accessing the file page into the pre-reading model.
例如,应用程触发访问文件的第4个文件页,则根据将上述N个比特位中的第4个比特位的取值更新为1,更新后的预读模型为11110000010000…...。For example, if the application triggers to access the fourth file page of the file, the value of the fourth bit of the above N bits is updated to 1, and the updated pre-reading model is 11110000010000....
步骤407、判断是否发生缺页,若是,则执行步骤408,若否,则结束。Step 407: Determine whether a page is missing, if yes, execute step 408, if not, end.
判断该文件的第4个文件页是否在内存中,若没有在内存中,则可以确定发生缺页。Determine whether the fourth file page of the file is in the memory. If it is not in the memory, it can be determined that a page fault has occurred.
步骤408、获取状态参数信息。Step 408: Obtain status parameter information.
步骤409、根据状态参数信息确定文件预读窗口的大小。Step 409: Determine the size of the file pre-reading window according to the status parameter information.
其中,步骤408和步骤409的解释说明可以参见图4A所示实施例的步骤101和步骤102,此处不再赘述。For the explanation of step 408 and step 409, reference may be made to step 101 and step 102 in the embodiment shown in FIG. 4A, which will not be repeated here.
步骤410、根据预读模型选取文件预读窗口内的至少一个文件页,作为预读取页,下发I/O请求。Step 410: Select at least one file page in the file pre-reading window according to the pre-reading model as the pre-read page, and issue an I/O request.
通过该I/O请求将预读取页从外部存储设备读取至内存中,以供应用层访问。The pre-fetched page is read from the external storage device into the memory through the I/O request for application-level access.
本实施例,可以实现基于状态参数信息自适应的调节预读操作对内存资源的占用,可以缓解应用程序启动响应慢、卡顿等现象,从而提升终端设备的使用性能。并且可以使用预读模型增加预读命中率,提升从外部存储设备读取至内存中的文件页被应用层访问的机率,从而减少无效预读。This embodiment can implement adaptive adjustment of the pre-reading operation based on the state parameter information to occupy the memory resources, and can alleviate the slow response of the application program and the freezing and the like, thereby improving the use performance of the terminal device. And you can use the pre-reading model to increase the pre-reading hit rate, and increase the probability that the file page read from the external storage device into the memory is accessed by the application layer, thereby reducing invalid pre-reading.
可以理解的是,终端设备为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。It can be understood that, in order to implement the above-mentioned functions, the terminal device includes hardware and/or software modules corresponding to each function. In combination with the algorithm steps of the examples described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Those skilled in the art can use different methods for each specific application in combination with the embodiments to implement the described functions, but such implementation should not be considered as going beyond the scope of the present application.
本实施例可以根据上述方法示例对终端设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In this embodiment, the terminal device may be divided into functional modules according to the foregoing method examples. For example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
在采用对应各个功能划分各个功能模块的情况下,图8示出了上述实施例中涉及的终端设备800的一种可能的组成示意图,如图8所示,该终端设备800可以包括:状态获取模块801、预读窗口确定模块802和预读模块803。In the case of dividing each functional module corresponding to each function, FIG. 8 shows a possible composition diagram of the terminal device 800 involved in the foregoing embodiment. As shown in FIG. 8, the terminal device 800 may include: state acquisition Module 801, pre-reading window determination module 802, and pre-reading module 803.
其中,状态获取模块801可以用于支持终端设备800执行上述步骤101、步骤201等,和/或用于本文所描述的技术的其他过程。Wherein, the state acquisition module 801 may be used to support the terminal device 800 to perform the above step 101, step 201, etc., and/or other processes used in the technology described herein.
预读窗口确定模块802可以用于支持终端设备800执行上述步骤102、步骤202、步骤203等,和/或用于本文所描述的技术的其他过程。The pre-reading window determination module 802 may be used to support the terminal device 800 to perform the above step 102, step 202, step 203, etc., and/or other processes used in the technology described herein.
预读模块803可以用于支持终端设备800执行上述步骤103、步骤204、步骤303、步骤304等,和/或用于本文所描述的技术的其他过程。The pre-reading module 803 may be used to support the terminal device 800 to perform the above step 103, step 204, step 303, step 304, etc., and/or other processes used in the technology described herein.
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。It should be noted that all relevant content of the steps involved in the foregoing method embodiments can be cited in the functional description of the corresponding functional module, and will not be repeated here.
本实施例提供的终端设备,用于执行上述预读取文件页的方法,因此可以达到与上述实现方法相同的效果。The terminal device provided in this embodiment is used to execute the above-mentioned method for pre-reading document pages, and therefore can achieve the same effect as the above-mentioned implementation method.
在采用集成的单元的情况下,终端设备可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对终端设备的动作进行控制管理,例如,可以用于支持终端设备执行上述状态获取模块801、预读窗口确定模块802和预读模块803执行的步骤。存储模块可以用于支持终端设备执行存储程序代码和数据等。通信模块,可以用于支持终端设备与其他设备的通信。In the case of an integrated unit, the terminal device may include a processing module, a storage module, and a communication module. The processing module can be used to control and manage the actions of the terminal device. For example, it can be used to support the terminal device to execute the steps performed by the state acquisition module 801, the pre-reading window determining module 802, and the pre-reading module 803. The storage module can be used to support the terminal device to execute the storage program code and data. The communication module can be used to support the communication between the terminal device and other devices.
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他设备交互的设备。Among them, the processing module may be a processor or a controller. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and so on. The storage module may be a memory. The communication module may specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, and other devices that interact with other devices.
在一个实施例中,当处理模块为处理器,存储模块为存储器时,本实施例所涉及的终端设备可以为具有图1所示结构的设备。In an embodiment, when the processing module is a processor and the storage module is a memory, the terminal device involved in this embodiment may be a device having the structure shown in FIG. 1.
本实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得终端设备执行上述相关方法步骤实现上述实施例中的预读取文件页的方法。This embodiment also provides a computer storage medium in which computer instructions are stored. When the computer instructions are executed on an electronic device, the terminal device is caused to execute the above-mentioned related method steps to realize the pre-reading file in the above-mentioned embodiment. Page method.
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的预读取文件页的方法。This embodiment also provides a computer program product, which when the computer program product runs on a computer, causes the computer to execute the above-mentioned related steps, so as to realize the method of pre-reading document pages in the above-mentioned embodiment.
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的预读取文件页的方法。In addition, the embodiments of the present application also provide a device. The device may specifically be a chip, component or module. The device may include a processor and a memory connected to each other. The memory is used to store computer execution instructions. When the device is running, The processor can execute the computer-executable instructions stored in the memory, so that the chip executes the method of pre-reading file pages in the foregoing method embodiments.
其中,本实施例提供的终端设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Among them, the terminal device, computer storage medium, computer program product, or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding method provided above. The beneficial effects of the method will not be repeated here.
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。Through the description of the above embodiments, those skilled in the art can understand that for the convenience and conciseness of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned function can be assigned to different functions according to needs. The function module is completed, that is, the internal structure of the device is divided into different function modules to complete all or part of the functions described above.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以 结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, for example, multiple units or components may be combined or It can be integrated into another device, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place, or they may be distributed to multiple different places. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product, and the software product is stored in a storage medium. It includes several instructions to make a device (may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods in the embodiments of the present application. The foregoing storage media include: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Claims (40)

  1. 一种预读取文件页的方法,其特征在于,包括:A method for pre-reading document pages is characterized in that it comprises:
    获取状态参数信息,所述状态参数信息用于表示内存使用状态和输入输出IO处理状态,或输入输出IO处理状态;Acquiring status parameter information, where the status parameter information is used to indicate the memory usage status and the input/output IO processing status, or the input/output IO processing status;
    根据所述状态参数信息确定文件预读窗口的大小;Determining the size of the file pre-reading window according to the state parameter information;
    根据所述文件预读窗口从外部存储设备读取相应的文件页至内存中。According to the file pre-reading window, the corresponding file page is read from the external storage device into the memory.
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述状态参数信息确定文件预读窗口的大小,包括:当所述状态参数信息指示内存使用压力和IO处理压力,或IO处理压力处于第一级别时,减小所述文件预读窗口的大小;当所述状态参数信息指示所述内存使用压力和IO处理压力,或IO处理压力处于第二级别时,增大所述文件预读窗口的大小;The method according to claim 1, wherein the determining the size of the file pre-reading window according to the state parameter information comprises: when the state parameter information indicates memory usage pressure and IO processing pressure, or IO processing pressure When it is at the first level, reduce the size of the file pre-reading window; when the status parameter information indicates the memory usage pressure and IO processing pressure, or when the IO processing pressure is at the second level, increase the file preview The size of the read window;
    其中,所述第一级别的内存使用压力或IO处理压力大于所述第二级别的内存使用压力或IO处理压力。Wherein, the first level of memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
  3. 根据权利要求1或2所述的方法,其特征在于,所述状态参数信息包括内存参数和IO参数,或IO参数,所述内存参数包括内存占用量、内存使用率、或缺页累计次数中至少一项,所述IO参数包括IO队列长度。The method according to claim 1 or 2, wherein the state parameter information includes memory parameters and IO parameters, or IO parameters, and the memory parameters include memory usage, memory usage, or cumulative number of page faults. At least one item, the IO parameter includes an IO queue length.
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述状态参数信息确定文件预读窗口的大小,包括:The method according to claim 3, wherein the determining the size of the file pre-reading window according to the state parameter information comprises:
    根据所述内存参数和所述IO参数,或根据所述IO参数确定第一指标;Determine the first index according to the memory parameter and the IO parameter, or according to the IO parameter;
    根据所述第一指标确定所述文件预读窗口的大小。The size of the file pre-reading window is determined according to the first indicator.
  5. 根据权利要求4所述的方法,其特征在于,所述根据所述第一指标确定所述文件预读窗口的大小,包括:The method according to claim 4, wherein the determining the size of the file pre-reading window according to the first indicator comprises:
    根据所述第一指标确定所述第一指标所属的数值区间;Determine the numerical interval to which the first indicator belongs according to the first indicator;
    将所述第一指标所属的数值区间对应的窗口大小作为所述文件预读窗口的大小。The size of the window corresponding to the numerical interval to which the first indicator belongs is used as the size of the file pre-reading window.
  6. 根据权利要求1至5任一项所述的方法,其特征在于,所述根据所述文件预读窗口从外部存储设备读取相应的文件页至内存中,包括:The method according to any one of claims 1 to 5, wherein the reading a corresponding file page from an external storage device into a memory according to the file pre-reading window comprises:
    根据预读模型选取所述文件预读窗口内的至少一个文件页,将所述至少一个文件页从外部存储设备读取至内存中;Selecting at least one file page in the file pre-reading window according to the pre-reading model, and reading the at least one file page from the external storage device into the memory;
    其中,所述预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的内存中的数据结构,所述预读模型与文件对应,所述文件访问实时数据与所述文件访问历史数据不同步,所述文件访问历史数据为所述外部存储设备中的数据。Wherein, the pre-reading model is a data structure in the memory determined according to at least one of file access real-time data and file access historical data, the pre-reading model corresponds to a file, and the file access real-time data corresponds to the file access The historical data is not synchronized, and the file access historical data is data in the external storage device.
  7. 根据权利要求6所述的方法,其特征在于,所述预读模型包括N个比特位,每个比特位对应所述文件的一个文件页,每个比特位用于表示所述比特位对应的文件页是否被访问,N为大于或等于1的整数。The method according to claim 6, wherein the pre-reading model includes N bits, each bit corresponds to a file page of the file, and each bit is used to indicate the corresponding bit Whether the file page is accessed, N is an integer greater than or equal to 1.
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:The method according to claim 7, wherein the method further comprises:
    判断所述至少一个文件页所构成的片段的个数是否大于第一阈值;Judging whether the number of segments formed by the at least one file page is greater than a first threshold;
    若所述至少一个文件页所构成的片段的个数大于第一阈值,则将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;If the number of fragments formed by the at least one file page is greater than the first threshold, reading all file pages in the file pre-reading window from the external storage device into the memory;
    若所述至少一个文件页所构成的片段的个数小于或等于第一阈值,则执行将所述至少一个文件页从外部存储设备读取至内存中的步骤。If the number of segments formed by the at least one file page is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is performed.
  9. 根据权利要求8所述的方法,其特征在于,所述将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中,包括:8. The method according to claim 8, wherein the reading all file pages in the file pre-reading window from an external storage device into a memory comprises:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述文件预读窗口内的所有文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are stored externally The device is read into the memory;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading all file pages in the file pre-reading window from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  10. 根据权利要求8所述的方法,其特征在于,所述将所述至少一个文件页从外部存储设备读取至内存中,包括:The method according to claim 8, wherein the reading the at least one file page from an external storage device into a memory comprises:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述至少一个文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, read the at least one file page and at least one file page after the file pre-reading window from the external storage device to the memory in;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading the at least one file page from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  11. 根据权利要求6至10任一项所述的方法,其特征在于,所述文件访问历史数据包括本次打开所述文件之前的读访问请求的位置、长度、或时间中至少一项,所述文件访问实时数据包括本次打开所述文件之后的读访问请求的位置、长度、或时间中至少一项。The method according to any one of claims 6 to 10, wherein the file access history data includes at least one of the position, length, or time of the read access request before the file is opened this time, and the The real-time file access data includes at least one of the location, length, or time of the read access request after the file is opened this time.
  12. 根据权利要求6至11任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 6 to 11, wherein the method further comprises:
    根据所述预读模型更新所述外部存储设备中的所述文件对应的文件访问历史数据。The file access history data corresponding to the file in the external storage device is updated according to the pre-reading model.
  13. 根据权利要求1至12任一项所述的方法,其特征在于,所述获取状态参数信息,包括:The method according to any one of claims 1 to 12, wherein said acquiring state parameter information comprises:
    在触发预读取文件页时获取所述状态参数信息;或者,Obtain the state parameter information when triggering the pre-fetching of the document page; or,
    以预设周期获取所述状态参数信息。The state parameter information is acquired in a preset period.
  14. 一种预读取文件页的装置,其特征在于,包括:A device for pre-reading document pages is characterized in that it comprises:
    状态获取模块,用于获取状态参数信息,所述状态参数信息用于表示内存使用状态和输入输出IO处理状态,或输入输出IO处理状态;The status acquisition module is used to acquire status parameter information, where the status parameter information is used to indicate the memory usage status and the input/output IO processing status, or the input/output IO processing status;
    预读窗口确定模块,用于根据所述状态参数信息确定文件预读窗口的大小;A pre-reading window determining module, configured to determine the size of the file pre-reading window according to the state parameter information;
    预读模块,用于根据所述文件预读窗口从外部存储设备读取相应的文件页至内存中。The pre-reading module is used to read the corresponding file page from the external storage device into the memory according to the file pre-reading window.
  15. 根据权利要求14所述的装置,其特征在于,所述预读窗口确定模块用于:当所述状态参数信息指示内存使用压力和IO处理压力,或IO处理压力处于第一级别时,减小所述文件预读窗口的大小;当所述状态参数信息指示所述内存使用压力和IO处理压力,或IO处理压力处于第二级别时,增大所述文件预读窗口的大小;The device according to claim 14, wherein the pre-reading window determination module is configured to: when the state parameter information indicates memory usage pressure and IO processing pressure, or IO processing pressure is at the first level, reduce The size of the file pre-reading window; when the state parameter information indicates the memory usage pressure and the IO processing pressure, or the IO processing pressure is at the second level, increase the size of the file pre-reading window;
    其中,所述第一级别的内存使用压力或IO处理压力大于所述第二级别的内存使用压力或IO处理压力。Wherein, the first level of memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
  16. 根据权利要求14或15所述的装置,其特征在于,所述状态参数信息包括内存参数和IO参数,或IO参数,所述内存参数包括内存占用量、内存使用率、或缺页累计次数中至少一项,所述IO参数包括IO队列长度。The device according to claim 14 or 15, wherein the state parameter information includes memory parameters and IO parameters, or IO parameters, and the memory parameters include memory usage, memory usage, or cumulative number of page faults. At least one item, the IO parameter includes an IO queue length.
  17. 根据权利要求16所述的装置,其特征在于,所述预读窗口确定模块用于:根据所述内存参数和所述IO参数,或根据所述IO参数确定第一指标;根据所述第一指标确定所述文件预读窗口的大小。The device according to claim 16, wherein the pre-reading window determination module is configured to: determine a first index according to the memory parameter and the IO parameter, or according to the IO parameter; The indicator determines the size of the file pre-reading window.
  18. 根据权利要求17所述的装置,其特征在于,所述预读窗口确定模块用于:根据所述第一指标确定所述第一指标所属的数值区间;将所述第一指标所属的数值区间对应的窗口大小作为所述文件预读窗口的大小。The device according to claim 17, wherein the pre-reading window determining module is configured to: determine the numerical interval to which the first indicator belongs according to the first indicator; and to determine the numerical interval to which the first indicator belongs The corresponding window size is used as the size of the file pre-reading window.
  19. 根据权利要求14至18任一项所述的装置,其特征在于,所述预读模块用于:根据预读模型选取所述文件预读窗口内的至少一个文件页,将所述至少一个文件页从外部存储设备读取至内存中;其中,所述预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的内存中的数据结构,所述预读模型与文件对应,所述文件访问实时数据与所述文件访问历史数据不同步,所述文件访问历史数据为所述外部存储设备中的数据。The device according to any one of claims 14 to 18, wherein the pre-reading module is configured to: select at least one document page in the document pre-reading window according to a pre-reading model, and transfer the at least one document The page is read from an external storage device into the memory; wherein the pre-reading model is a data structure in the memory determined according to at least one of file access real-time data and file access historical data, and the pre-reading model corresponds to the file, The file access real-time data is not synchronized with the file access history data, and the file access history data is data in the external storage device.
  20. 根据权利要求19所述的装置,其特征在于,所述预读模型包括N个比特位,每个比特位对应所述文件的一个文件页,每个比特位用于表示所述比特位对应的文件页是否被访问,N为大于或等于1的整数。The device according to claim 19, wherein the pre-reading model comprises N bits, each bit corresponds to a file page of the file, and each bit is used to indicate the corresponding Whether the file page is accessed, N is an integer greater than or equal to 1.
  21. 根据权利要求20所述的装置,其特征在于,所述预读模块还用于:判断所述至少一个文件页所构成的片段的个数是否大于第一阈值;若所述至少一个文件页所构成的片段的个数大于第一阈值,则将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;若所述至少一个文件页所构成的片段的个数小于或等于第一阈值,则执行将所述至少一个文件页从外部存储设备读取至内存中的步骤。The device according to claim 20, wherein the pre-reading module is further configured to: determine whether the number of segments formed by the at least one file page is greater than a first threshold; if the at least one file page is If the number of fragments constituted is greater than the first threshold, all file pages in the file pre-reading window are read from the external storage device into the memory; if the number of fragments constituted by the at least one file page is less than or If it is equal to the first threshold, execute the step of reading the at least one file page from the external storage device into the memory.
  22. 根据权利要求21所述的装置,其特征在于,所述预读模块用于:The device according to claim 21, wherein the pre-reading module is used to:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述文件预读窗口内的所有文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are stored externally The device is read into the memory;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading all file pages in the file pre-reading window from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  23. 根据权利要求21所述的装置,其特征在于,所述预读模块用于:The device according to claim 21, wherein the pre-reading module is used for:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述至少一个文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, read the at least one file page and at least one file page after the file pre-reading window from the external storage device to the memory in;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading the at least one file page from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  24. 根据权利要求19至23任一项所述的装置,其特征在于,所述文件访问历史数据包括本次打开所述文件之前的读访问请求的位置、长度、或时间中至少一项,所述文件访问实时数据包括本次打开所述文件之后的读访问请求的位置、长度、或时间中至少一项。The device according to any one of claims 19 to 23, wherein the file access history data includes at least one of the position, length, or time of the read access request before the file is opened this time, and the The file access real-time data includes at least one of the location, length, or time of the read access request after the file is opened this time.
  25. 根据权利要求19至24任一项所述的装置,其特征在于,所述预读模块还用于:根据所述预读模型更新所述外部存储设备中的所述文件对应的文件访问历史数据。The apparatus according to any one of claims 19 to 24, wherein the pre-reading module is further configured to: update the file access history data corresponding to the file in the external storage device according to the pre-reading model .
  26. 根据权利要求14至25任一项所述的装置,其特征在于,所述状态获取模块用于:在触发预读取文件页时获取所述状态参数信息;或者,以预设周期获取所述状态参数信息。The device according to any one of claims 14 to 25, wherein the status acquisition module is configured to: acquire the status parameter information when the pre-fetching of a document page is triggered; or, acquire the status parameter information in a preset period Status parameter information.
  27. 一种终端设备,其特征在于,包括:A terminal device, characterized in that it comprises:
    一个或多个处理器;One or more processors;
    存储器,用于存储一个或多个程序;Memory, used to store one or more programs;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-13中任一项所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-13.
  28. 一种计算机可读存储介质,其特征在于,包括计算机程序,所述计算机程序在计算机上被执行时,使得所述计算机执行权利要求1-13中任一项所述的方法。A computer-readable storage medium, characterized by comprising a computer program, which when executed on a computer, causes the computer to execute the method according to any one of claims 1-13.
  29. 一种计算机程序产品,其特征在于,当所述计算机程序产品被计算机执行时,用于执行权利要求1-13中任一项所述的方法。A computer program product, characterized in that, when the computer program product is executed by a computer, it is used to execute the method according to any one of claims 1-13.
  30. 一种芯片,其特征在于,包括处理器和存储器,所述存储器用于存储计算机程序,所述处理器用于调用并运行所述存储器中存储的计算机程序,以执行如权利要求1-13中任一项所述的方法。A chip, characterized by comprising a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of claims 1-13. The method described in one item.
  31. 一种预读取文件页的方法,其特征在于,包括:A method for pre-reading document pages is characterized in that it comprises:
    根据预读模型选取文件预读窗口内的至少一个文件页,将所述至少一个文件页从外部存储设备读取至内存中;Selecting at least one file page in the file pre-reading window according to the pre-reading model, and reading the at least one file page from the external storage device into the memory;
    其中,所述预读模型为根据文件访问实时数据和文件访问历史数据中至少一项确定的内存中的数据结构,所述预读模型与文件对应,所述文件访问实时数据与所述文件访问历史数据不同步,所述文件访问历史数据为所述外部存储设备中的数据。Wherein, the pre-reading model is a data structure in the memory determined according to at least one of file access real-time data and file access historical data, the pre-reading model corresponds to a file, and the file access real-time data corresponds to the file access The historical data is not synchronized, and the file access historical data is data in the external storage device.
  32. 根据权利要求31所述的方法,其特征在于,所述预读模型包括N个比特位,每个比特位对应所述文件的一个文件页,每个比特位用于表示所述比特位对应的文件页是否被访问,N为大于或等于1的整数。The method according to claim 31, wherein the pre-reading model comprises N bits, each bit corresponds to a file page of the file, and each bit is used to indicate the corresponding Whether the file page is accessed, N is an integer greater than or equal to 1.
  33. 根据权利要求32所述的方法,其特征在于,所述方法还包括:The method according to claim 32, wherein the method further comprises:
    判断所述至少一个文件页所构成的片段的个数是否大于第一阈值;Judging whether the number of segments formed by the at least one file page is greater than a first threshold;
    若所述至少一个文件页所构成的片段的个数大于第一阈值,则将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;If the number of fragments formed by the at least one file page is greater than the first threshold, reading all file pages in the file pre-reading window from the external storage device into the memory;
    若所述至少一个文件页所构成的片段的个数小于或等于第一阈值,则执行将所述至少一个文件页从外部存储设备读取至内存中的步骤。If the number of segments formed by the at least one file page is less than or equal to the first threshold, the step of reading the at least one file page from the external storage device into the memory is performed.
  34. 根据权利要求33所述的方法,其特征在于,所述将所述文件预读窗口内的所有文 件页从外部存储设备读取至内存中,包括:The method according to claim 33, wherein the reading all the file pages in the file pre-reading window from an external storage device into the memory comprises:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述文件预读窗口内的所有文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, all file pages in the file pre-reading window and at least one file page after the file pre-reading window are stored externally The device is read into the memory;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述文件预读窗口内的所有文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading all file pages in the file pre-reading window from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  35. 根据权利要求33所述的方法,其特征在于,所述将所述至少一个文件页从外部存储设备读取至内存中,包括:The method according to claim 33, wherein the reading the at least one file page from an external storage device into a memory comprises:
    判断所述文件预读窗口的最后一个文件页对应的比特位是否表示所述最后一个文件页被访问;Judging whether the bit corresponding to the last file page of the file pre-reading window indicates that the last file page is accessed;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页被访问时,将所述至少一个文件页和所述文件预读窗口之后的至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page is accessed, read the at least one file page and at least one file page after the file pre-reading window from the external storage device to the memory in;
    当所述最后一个文件页对应的比特位表示所述最后一个文件页未被访问时,将所述至少一个文件页从外部存储设备读取至内存中;When the bit corresponding to the last file page indicates that the last file page has not been accessed, reading the at least one file page from the external storage device into the memory;
    其中,所述文件预读窗口之后的至少一个文件页与所述文件预读窗口的最后一个文件页属于同一片段。Wherein, at least one file page after the file pre-reading window and the last file page of the file pre-reading window belong to the same segment.
  36. 根据权利要求31至35任一项所述的方法,其特征在于,所述文件访问历史数据包括本次打开所述文件之前的读访问请求的位置、长度、或时间中至少一项,所述文件访问实时数据包括本次打开所述文件之后的读访问请求的位置、长度、或时间中至少一项。The method according to any one of claims 31 to 35, wherein the file access history data includes at least one of the position, length, or time of the read access request before the file is opened this time, and the The file access real-time data includes at least one of the location, length, or time of the read access request after the file is opened this time.
  37. 根据权利要求31至36任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 31 to 36, wherein the method further comprises:
    根据所述预读模型更新所述外部存储设备中的所述文件对应的文件访问历史数据。The file access history data corresponding to the file in the external storage device is updated according to the pre-reading model.
  38. 根据权利要求31至37任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 31 to 37, wherein the method further comprises:
    获取状态参数信息,所述状态参数信息用于表示内存使用状态和输入输出IO处理状态,或输入输出IO处理状态;Acquiring status parameter information, where the status parameter information is used to indicate the memory usage status and the input/output IO processing status, or the input/output IO processing status;
    根据所述状态参数信息确定所述文件预读窗口的大小。Determine the size of the file pre-reading window according to the state parameter information.
  39. 根据权利要求38所述的方法,其特征在于,所述根据所述状态参数信息确定所述文件预读窗口的大小,包括:当所述状态参数信息指示内存使用压力和IO处理压力,或IO处理压力处于第一级别时,减小所述文件预读窗口的大小;当所述状态参数信息指示所述内存使用压力和IO处理压力,或IO处理压力处于第二级别时,增大所述文件预读窗口的大小;The method according to claim 38, wherein the determining the size of the file pre-reading window according to the state parameter information comprises: when the state parameter information indicates memory usage pressure and IO processing pressure, or IO When the processing pressure is at the first level, reduce the size of the file pre-reading window; when the status parameter information indicates the memory usage pressure and the IO processing pressure, or when the IO processing pressure is at the second level, increase the The size of the file pre-reading window;
    其中,所述第一级别的内存使用压力或IO处理压力大于所述第二级别的内存使用压力或IO处理压力。Wherein, the first level of memory usage pressure or IO processing pressure is greater than the second level of memory usage pressure or IO processing pressure.
  40. 一种终端设备,其特征在于,包括:A terminal device, characterized in that it comprises:
    一个或多个处理器;One or more processors;
    存储器,用于存储一个或多个程序;Memory, used to store one or more programs;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求31-39中任一项所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 31-39.
PCT/CN2020/092247 2019-08-27 2020-05-26 Method and device for pre-reading file page, and terminal device WO2021036370A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910798611.8A CN112445725A (en) 2019-08-27 2019-08-27 Method and device for pre-reading file page and terminal equipment
CN201910798611.8 2019-08-27

Publications (1)

Publication Number Publication Date
WO2021036370A1 true WO2021036370A1 (en) 2021-03-04

Family

ID=74683545

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/092247 WO2021036370A1 (en) 2019-08-27 2020-05-26 Method and device for pre-reading file page, and terminal device

Country Status (2)

Country Link
CN (1) CN112445725A (en)
WO (1) WO2021036370A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114461588A (en) * 2021-08-20 2022-05-10 荣耀终端有限公司 Method for adjusting pre-reading window and electronic equipment

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489469B (en) * 2021-07-20 2022-12-23 荣耀终端有限公司 Data reading method, electronic equipment and storage medium
CN114461589B (en) * 2021-08-24 2023-04-11 荣耀终端有限公司 Method for reading compressed file, file system and electronic equipment
CN113760191B (en) * 2021-08-31 2022-09-23 荣耀终端有限公司 Data reading method, data reading apparatus, storage medium, and program product
CN113760192B (en) * 2021-08-31 2022-09-02 荣耀终端有限公司 Data reading method, data reading apparatus, storage medium, and program product
CN116680142B (en) * 2022-11-15 2024-05-07 荣耀终端有限公司 Memory resource monitoring method, electronic device, program product and medium
CN117130952A (en) * 2023-01-10 2023-11-28 荣耀终端有限公司 Pre-reading method and pre-reading device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080091921A1 (en) * 2006-10-12 2008-04-17 Diab Abuaiadh Data prefetching in a microprocessing environment
CN101388824A (en) * 2008-10-15 2009-03-18 中国科学院计算技术研究所 File reading method and system under sliced memory mode in cluster system
CN102508638A (en) * 2011-09-27 2012-06-20 华为技术有限公司 Data pre-fetching method and device for non-uniform memory access
CN104715048A (en) * 2015-03-26 2015-06-17 浪潮集团有限公司 File system caching and pre-reading method
CN106250064A (en) * 2016-08-19 2016-12-21 深圳大普微电子科技有限公司 Solid state hard disc controls device and solid state hard disc data access method based on study
CN106951181A (en) * 2017-02-21 2017-07-14 深圳大普微电子科技有限公司 A kind of control device of data-storage system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108763104B (en) * 2018-05-23 2022-04-08 北京小米移动软件有限公司 Method and device for pre-reading file page and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080091921A1 (en) * 2006-10-12 2008-04-17 Diab Abuaiadh Data prefetching in a microprocessing environment
CN101388824A (en) * 2008-10-15 2009-03-18 中国科学院计算技术研究所 File reading method and system under sliced memory mode in cluster system
CN102508638A (en) * 2011-09-27 2012-06-20 华为技术有限公司 Data pre-fetching method and device for non-uniform memory access
CN104715048A (en) * 2015-03-26 2015-06-17 浪潮集团有限公司 File system caching and pre-reading method
CN106250064A (en) * 2016-08-19 2016-12-21 深圳大普微电子科技有限公司 Solid state hard disc controls device and solid state hard disc data access method based on study
CN106951181A (en) * 2017-02-21 2017-07-14 深圳大普微电子科技有限公司 A kind of control device of data-storage system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114461588A (en) * 2021-08-20 2022-05-10 荣耀终端有限公司 Method for adjusting pre-reading window and electronic equipment
CN114461588B (en) * 2021-08-20 2023-01-24 荣耀终端有限公司 Method for adjusting pre-reading window and electronic equipment

Also Published As

Publication number Publication date
CN112445725A (en) 2021-03-05

Similar Documents

Publication Publication Date Title
WO2021036370A1 (en) Method and device for pre-reading file page, and terminal device
CN110275841B (en) Access request processing method and device, computer equipment and storage medium
EP4109230A1 (en) Storage system, file storage and reading method, and terminal device
EP3920034A1 (en) Systems and methods for scalable and coherent memory devices
US9785545B2 (en) Method and apparatus for providing dual memory access to non-volatile memory
US9280474B2 (en) Adaptive data prefetching
KR101999132B1 (en) Method and apparatus for managing memory in virtual machine environment
US9405725B2 (en) Writing message to controller memory space
WO2014176981A1 (en) Cross-page prefetching method, device and system
EP3608790B1 (en) Modifying nvme physical region page list pointers and data pointers to facilitate routing of pcie memory requests
US20150143045A1 (en) Cache control apparatus and method
CN111143242A (en) Cache prefetching method and device
KR20170013882A (en) A multi-host power controller (mhpc) of a flash-memory-based storage device
WO2013192633A2 (en) Virtual memory module
KR20150129764A (en) Method and apparatus for preventing unauthorized access to contents of a register under certain conditions when performing a hardware table walk (hwtw)
JP2020502694A (en) Method and apparatus for accessing non-volatile memory as byte addressable memory
CN111897485A (en) Data storage method and device, electronic equipment and storage medium
CN112631504A (en) Method and device for realizing local cache by using off-heap memory
CN112612728B (en) Cache management method, device and equipment
CN114077588B (en) Pre-reading method and device
TW202230140A (en) Method to manage memory and non-transitory computer-readable medium
CN117242763A (en) Network interface card for caching file system internal structure
CN116340203A (en) Data pre-reading method and device, processor and prefetcher
US10832132B2 (en) Data transmission method and calculation apparatus for neural network, electronic apparatus, computer-readable storage medium and computer program product
CN116601616A (en) Data processing device, method and related equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20858768

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20858768

Country of ref document: EP

Kind code of ref document: A1