CN111930513B - File pre-reading adjusting method and device, electronic equipment and storage medium - Google Patents

File pre-reading adjusting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111930513B
CN111930513B CN202010895854.6A CN202010895854A CN111930513B CN 111930513 B CN111930513 B CN 111930513B CN 202010895854 A CN202010895854 A CN 202010895854A CN 111930513 B CN111930513 B CN 111930513B
Authority
CN
China
Prior art keywords
resource
target resource
target
reading
pressure coefficient
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202010895854.6A
Other languages
Chinese (zh)
Other versions
CN111930513A (en
Inventor
李培锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology Co Ltd
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 Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN202010895854.6A priority Critical patent/CN111930513B/en
Publication of CN111930513A publication Critical patent/CN111930513A/en
Application granted granted Critical
Publication of CN111930513B publication Critical patent/CN111930513B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (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 invention discloses a method and a device for adjusting file pre-reading, an electronic device and a storage medium, belonging to the technical field of computer performance optimization, wherein the method comprises the following steps: acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources; determining whether to execute target resource recovery operation according to the resource occupancy rate; if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed; and when the target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient. By implementing the scheme, the accuracy of target resource recovery is improved according to the resource occupancy rate, and after the target resource is recovered, the pre-reading capability of the system is adjusted according to the pressure during target resource recovery, so that excessive consumption of system resources during pre-reading of file pages is avoided, and the burden of the system resources is effectively reduced.

Description

File pre-reading adjusting method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of computer performance optimization, in particular to a file pre-reading adjusting method and device, electronic equipment and a storage medium.
Background
Most of the I/O reading and writing of the disk are sequential, and the storage of the common file on the disk occupies continuous sectors, so that the moving times of a magnetic head can be reduced and the reading and writing performance can be improved when the file is read and written, and when a program reads a file, the program usually accesses from the first byte to the last byte sequentially.
In order to load an accessed file into a kernel in advance and reduce the waiting time for a process to read a page, in the related art, when the process reads the page, a system uses a read ahead mechanism to read more pages; pre-reading is to read a plurality of consecutive pages of a file from a normal file or a block device file into a memory before the data is actually accessed. However, the page of the pre-read file may include a page that is not accessed or does not need to be accessed, which causes excessive consumption of system resources in the pre-read process, increases the load of the system, and causes damage to the system.
Disclosure of Invention
The application provides a file pre-reading adjusting method and device, an electronic device and a storage medium, which can solve the technical problem that resources of a system are excessively consumed in a pre-reading process.
The first aspect of the present invention provides a method for adjusting file pre-reading, where the method includes:
acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources;
determining whether to execute target resource recovery operation according to the resource occupancy rate;
if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed;
and when the page of the target file is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient.
Optionally, the step of analyzing the resource occupancy rate corresponding to the target resource in the system resource includes:
detecting a load corresponding to a target resource in the resource system;
distributing corresponding target resources for the pre-read target file page according to the load corresponding to the target resources in the resource system;
and calculating the corresponding resource occupancy rate according to the allocated target resources.
Optionally, the step of determining whether to execute the target resource recycling operation according to the resource occupancy rate includes:
comparing the resource occupancy rate with a preset resource occupancy threshold value;
if the resource occupancy rate is greater than or equal to the resource occupancy threshold value, executing target resource recovery operation;
and if the resource occupancy rate is smaller than the resource occupancy threshold value, not executing target resource recovery operation.
Optionally, if the target resource recycling operation is executed, the step of obtaining the target resource pressure coefficient corresponding to the target resource includes:
if the target resource recycling operation is executed, recording a starting timestamp of the target resource recycling operation;
recording an ending timestamp of the target resource recovery operation until the target resource cannot be recovered;
and determining a corresponding target resource pressure coefficient after the target resource is recovered according to the ending time stamp and the starting time stamp.
Optionally, the step of adjusting the pre-reading capability of the system according to the target resource pressure coefficient includes:
acquiring the target resource pressure coefficient;
determining a resource adjusting coefficient according to the target resource pressure coefficient and a preset resource pressure threshold value;
and adjusting the pre-reading capability of the system by using the resource adjusting coefficient.
Optionally, the step of adjusting the pre-reading capability of the system according to the target resource pressure coefficient includes:
acquiring the target resource pressure coefficient;
comparing the target resource pressure coefficient with a preset first resource pressure threshold;
if the target resource pressure coefficient is greater than the first resource pressure threshold, closing the pre-reading capability of the system;
if the target resource pressure coefficient is smaller than the first resource pressure threshold, comparing the target resource pressure coefficient with a preset second resource pressure threshold;
and if the target resource pressure coefficient is greater than the second resource pressure threshold, reducing the pre-reading capability of the system.
Optionally, the method further includes:
and if the target resource recovery operation is not executed, acquiring the target resource pressure coefficient from a preset target resource pressure coefficient list according to the resource occupancy rate, wherein the target resource pressure coefficient list comprises the corresponding relation between the target resource pressure coefficient and the resource occupancy rate.
A second aspect of the present invention provides an apparatus for adjusting file pre-reading, including:
the first acquisition module is used for acquiring the resource occupancy rate corresponding to a target resource in system resources, wherein the system resources comprise a plurality of different target resources;
the determining module is used for determining whether to execute target resource recycling operation according to the resource occupancy rate;
a second obtaining module, configured to obtain a target resource pressure coefficient corresponding to a target resource if a target resource recovery operation is performed, where the target resource pressure coefficient is used to indicate a pressure when the target resource recovery operation is performed;
and the adjusting module is used for adjusting the pre-reading capability of the system according to the target resource pressure coefficient when the target file page is pre-read.
A third aspect of the present invention provides an electronic device comprising: the adjusting method comprises a memory, a processor and a communication bus, wherein the communication bus is respectively in communication connection with the memory and the processor, the memory is stored with a computer program, and the processor executes the computer program to realize each step in the adjusting method for file pre-reading in the first aspect.
A fourth aspect of the present invention provides a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium, and when being executed by a processor, the computer program implements the steps in the adjusting method for file pre-reading according to the first aspect.
The invention provides an adjusting method for file pre-reading, which comprises the following steps: acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources; determining whether to execute target resource recovery operation according to the resource occupancy rate; if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed; and when the page of the target file is pre-read, adjusting the pre-reading capability of the system according to the pressure coefficient of the target resource. By implementing the scheme, the use condition of the target resource is analyzed according to the resource occupancy rate so as to determine the recovery target resource, the accuracy of the recovery target resource is improved, after the recovery target resource is determined, the pressure when the target resource is recovered is analyzed according to the corresponding target resource pressure coefficient, the pre-reading capability of the system is adjusted according to the actual pressure of the target resource, the resource of the system is prevented from being excessively consumed when the file page is pre-read, the burden of the system resource can be effectively reduced, the damage to the system is reduced, and the pre-reading reliability is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart illustrating steps of a method for adjusting file pre-reading according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating another step of the adjusting method for file pre-reading according to the embodiment of the present invention;
FIG. 3 is a block diagram of an adjusting apparatus for pre-reading a file according to an embodiment of the present invention;
fig. 4 is an architecture diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Due to the technical problem that the pre-reading process in the prior art excessively consumes the resources of the system.
In order to solve the above technical problems, the present invention provides a method and an apparatus for adjusting file pre-reading, an electronic device, and a storage medium.
Please refer to fig. 1, which is a flowchart illustrating a method for adjusting file pre-reading according to an embodiment of the present invention. The embodiment provides a method for adjusting file pre-reading, which comprises the following steps:
step S101: and acquiring the resource occupancy rate corresponding to the target resource in the system resource, wherein the system resource comprises a plurality of different target resources.
Specifically, before the pre-reading or pre-reading is that the data is actually accessed, a processor or a data center of the system first obtains a resource space when the program or the application needs to run or pre-read, where the resource space is a space size corresponding to a target resource in system resources required by the program or the application when running. Preferably, the system resource is not limited to resources including a system memory, IO, CPU, and the like, the target resource may be one of the resources including the memory, the IO, or the CPU, taking the target resource as a memory resource, the memory is an operating memory of the system, after the system allocates the system memory resource required by the read-ahead process, the resource occupancy rate of the target resource in the system resource is obtained, that is, the resource occupancy rate of the system memory in the system resource is obtained, the resource occupancy rate may be a percentage of the system memory in the entire system memory obtained after the read-ahead process is allocated, and the resource occupancy rate may also be a percentage of the total amount of the system memory occupied by all programs, applications, software, and the like of the current system in the entire system memory after the system allocates the system memory to the read-ahead process. The occupation condition of the target resource can be obtained through the resource occupancy rate of the target resource, and the method can be used for judging whether to recycle the resource or not so as to improve the accuracy of recycling the target resource and has reliability.
Step S102: and determining whether to execute the target resource recycling operation according to the resource occupancy rate.
Most of the I/O reading and writing of the magnetic disk are sequential, and the storage of the common file on the magnetic disk occupies continuous sectors, so that the moving times of a magnetic head can be reduced and the reading and writing performance can be improved when the file is read and written; when a program reads a file, it usually accesses the file sequentially from the first byte to the last byte, so that multiple adjacent sectors on the disk in the same file are accessed by the read process.
The pre-reading or pre-reading is to read a plurality of continuous file pages from a common file or a block device file into a memory before data is really accessed, namely, a file system reads more file contents than expected for an application program once and caches the file contents in a page cache (high-speed buffer memory), so that part of the pages are directly read from the high-speed buffer memory when a next reading request comes; in most cases, the number of commands processed by the disk controller is reduced, and each command reads multiple adjacent sectors, so that the pre-reading mechanism of the kernel can obviously improve the performance of the disk, and in addition, the system response time is also improved by the pre-reading mechanism.
After the resource occupancy rate corresponding to the obtained target resource is obtained, taking the target resource as an example of a memory, when the memory resource of the system is excessively consumed, the load of the memory of the system is too large, and the system will be damaged, for example, the operation of the system is damaged or the system is disturbed, and the like, the target resource in the system resource needs to be recovered, for example, the memory of the system is recovered, in order to improve the accuracy of recovering the system resource, whether to recover the target resource is determined according to the resource occupancy rate of the target resource, and the recovery process of the target resource may be: target resources in system resources are released by recycling part of pages, compressing the memory, closing part of application processes and the like, more system resource spaces are vacated, pre-reading is facilitated, and the reliability of the system is improved.
Further, in this embodiment, step S102 includes: comparing the acquired resource occupancy rate of the target resource with a preset resource occupancy threshold value; if the resource occupancy rate is greater than or equal to the resource occupancy threshold value, executing target resource recovery operation; and if the resource occupancy rate is smaller than the resource occupancy threshold value, the target resource recycling operation is not executed. Specifically, a resource occupancy threshold is preset, and the resource occupancy threshold is used for judging the occupancy condition of system resources to determine whether to recover target resources in the system resources, and when the resource occupancy rate is greater than or equal to the resource occupancy threshold, the target resources in the system resources are determined to be recovered, and if a system has a program, an application or software running, the memory resource occupancy in the current system resources is large, the system memory resource space is small, and the pre-reading process is not facilitated, the system memory in the system resources is determined to be recovered; otherwise, when the memory resource occupation in the current system resource is small, that is, the resource occupancy rate is smaller than the preset resource occupancy threshold value, it is determined that the target resource is not recycled. Through the steps, the accuracy of recovering system resources can be improved, so that more system resource spaces are vacated, pre-reading is facilitated, and the reliability of the system is improved
Step S103: and if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed.
In step S103, the condition for determining the reclamation target resource may be: when the resource occupancy rate of the target resource is greater than the preset system resource threshold value and when the condition for determining to recover the target resource is met, the corresponding target resource pressure coefficient after the target resource is recovered is obtained, and the target resource pressure coefficient is used for reflecting the pressure when the target resource is recovered.
In one embodiment, step 103 comprises: if the target resource recovery operation is executed, recording the starting timestamp of the target resource operation; recording an ending timestamp of the target resource recovery operation until the target resource cannot be recovered; and determining a corresponding target resource pressure coefficient when the target resource is recovered according to the ending time stamp and the starting time stamp. Specifically, when determining to recycle the target resource, a start time stamp when starting to recycle the target resource is recorded or obtained, and when finishing recycling the target resource, an end time stamp when finishing recycling the target resource is recorded or obtained, where the start time stamp or the end time stamp is a character sequence for identifying a time of a certain moment, and the time stamp technology can be understood as an application of a variant of the digital signature technology. Further, a difference is made according to the start timestamp and the end timestamp, which is specifically as follows:
STALL _ TIME = end timestamp-start timestamp, which indicates the target resource pressure coefficient, i.e. the pressure indicating the memory reclamation.
Step S104: and when the target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient.
In this embodiment, the target file page refers to a file created by an operating system reflecting the size of the hard disk space of the virtual memory and using the hard disk space, and if some large-scale software consumes a large amount of memory, a part of the hard disk space needs to be separately opened up as a buffer, and an entity of the part of the hard disk space is a page file created by the software. Programs or applications are running that will access these pagefiles.
In this embodiment, the pre-reading is mainly used to aggregate small I/O into large I/O, so as to improve the utilization rate of the disk and improve the throughput of the system; I/O delay of a hidden disk of an application program is delayed so as to accelerate the program operation; and predicting the pre-reading process, for example, mainstream operating systems such as Linux, freeBSD and Solaris all follow a simple and effective principle, namely, the reading mode is divided into two categories of random reading and sequential reading, and the pre-reading is required to be predicted. The pre-reading capability refers to the pre-reading amount or the pre-reading rate when the page of the target file is pre-read, but is not limited thereto; taking the pre-reading amount as an example, when the system pre-reads the target file page, the performance of the system during pre-reading is changed by adjusting the size of the pre-reading amount of the system, specifically, after the target resource pressure coefficient is obtained through analysis, the size of the pre-reading capability of the system is adjusted in real time according to the target resource pressure coefficient, so that the pre-process conforms to the condition of the target resource in the current system resource, and the pressure on the target resource in the system resource is avoided.
In one embodiment, step S104 includes: acquiring a target resource pressure coefficient; determining a resource adjusting coefficient according to the target resource pressure coefficient and a preset resource pressure threshold value; and adjusting the pre-reading capability of the system by using the resource adjusting coefficient. Specifically, after obtaining the target resource pressure coefficient, comparing the target resource pressure coefficient with a preset resource pressure threshold to determine a resource adjustment coefficient, which may include a preset resource adjustment coefficient list if the present embodiment includes the resource adjustment coefficient including a corresponding relationship between a comparison result and a resource adjustment coefficient, where the comparison result is a comparison result between the target resource pressure coefficient and the resource pressure threshold, and if the comparison result is that the target resource pressure coefficient is greater than the resource pressure threshold, searching the resource adjustment coefficient list according to the comparison result to obtain a corresponding resource adjustment coefficient, where the resource adjustment coefficient may be a negative in-resource adjustment coefficient; or, when the comparison result is that the target resource pressure coefficient is smaller than the resource pressure threshold, searching the resource adjusting coefficient list according to the comparison result to obtain the corresponding resource adjusting coefficient, wherein the resource adjusting coefficient can be the positive in-resource adjusting coefficient. The manner of adjusting the pre-reading capability through the resource adjustment coefficient in the above implementation is only one that can implement the embodiment, and other equivalent or practically identical embodiments may also be included herein, which is not further described in this embodiment.
In another embodiment, step 104 comprises: acquiring a target resource pressure coefficient; comparing the target resource pressure coefficient with a preset first resource pressure threshold; if the target resource pressure coefficient is greater than the first resource pressure threshold, adjusting the pre-reading capability of the system to be closed, or directly closing the pre-reading capability of the system; if the target resource pressure coefficient is smaller than the first resource pressure threshold, comparing the target resource pressure coefficient with a preset second resource pressure threshold; and if the target resource pressure coefficient is larger than the second resource pressure threshold value, reducing the pre-reading capability of the system. Specifically, by setting a resource pressure threshold, the resource pressure threshold is used to determine whether to adjust the pre-reading capability of the system, for example, setting two resource pressure thresholds, including a first resource pressure threshold and a second resource pressure threshold, where the first resource pressure threshold is greater than the second resource pressure threshold, the first resource pressure threshold is used to determine whether to close or stop the pre-reading of the system, and the second resource pressure threshold is used to determine whether to adjust the pre-reading capability of the system to be smaller, that is, to determine whether to reduce the pre-reading capability of the system. Further, the obtained target resource pressure coefficient is compared with a preset first resource pressure threshold, and if the target resource pressure coefficient is greater than the preset first resource pressure threshold, it indicates that after the target resource is recovered, the target resource of the system resource still cannot meet the current pre-reading process, and may also indicate that most programs, applications, or software included in all processes of the system operation cannot be closed or stopped, so that the pressure of the resource of the target system in the current system resource is too high, at this time, the current pre-reading process should be closed or stopped, so as to prevent the phenomenon that more file contents than expected are read once and cached in a cache memory in the pre-reading process, further increase the burden of the system, and cause the phenomena of system crash, stagnation, disorder, and the like, and damage the system.
The invention provides a method for adjusting file pre-reading, which comprises the following steps: acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources; determining whether to execute target resource recovery operation according to the resource occupancy rate; if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed; and when the target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient. By implementing the scheme, the service condition of the target resource is analyzed according to the resource occupancy rate so as to determine the recovery target resource, the accuracy of the recovery target resource is improved, after the recovery target resource is determined, the pressure when the target resource is recovered is analyzed according to the corresponding target resource pressure coefficient, the pre-reading capability of the system is adjusted according to the actual pressure of the target resource, the excessive consumption of the resource of the system when the file page is pre-read is avoided, the burden of the system resource can be effectively reduced, the damage to the system is reduced, and the pre-reading reliability is improved.
Please refer to fig. 2, which is a flowchart illustrating a method for adjusting file pre-reading according to an embodiment of the present invention. Specifically, the flow of the step is as follows:
s201: and detecting the load corresponding to the target resource in the resource system.
Specifically, when the system runs the current program, application, and software, certain system resources may be occupied or consumed, the system resources are not limited to include a memory, an IO, and a CPU, and the target resource may be at least one of the memory, the IO, and the CPU, or may be a combination of multiple resources, which is not limited in this embodiment; further, the usage (load) of a target resource in the terminal system resource, such as detecting a system memory resource, IO, CPU, and the like, may be detected in real time, and the temperature of the terminal or the temperature of the processor may be detected to be used as an index for measuring the system operation condition, specifically, the system operation condition is measured according to the load corresponding to the target resource.
S202: and distributing corresponding target resources for the page of the pre-read target file according to the load corresponding to the target resources in the resource system.
Specifically, after the load of the target resource is obtained, the target resource of a corresponding size when the load distribution system of the target resource runs the read-ahead process is distributed according to the load of the target resource, and the target resource is not limited to include: the system memory resource, IO and CPU frequency enable the pre-read process to run.
S203: and calculating the corresponding resource occupancy rate according to the allocated target resources.
Specifically, after the pre-reading process runs, it is described that the system successfully allocates the target resource to the pre-reading process, and at this time, the occupation of the system resource after the pre-reading process is executed may be analyzed to determine the resource occupancy rate corresponding to the allocated target resource, where the resource occupancy rate may be the percentage of the system memory, which is obtained after the pre-reading process is allocated, in the total system memory, which is occupied by all programs, applications, software and the like of the current system in the percentage of the total system memory, after the system allocates the system memory to the pre-reading process.
It should be noted that steps S201 to S203 in this embodiment are an implementation of S101 in the previous embodiment, but the present invention is not limited to this, and the occupancy rate of the target resource in the system resource may also be obtained in other similar manners.
S204: and determining whether to execute the target resource recycling operation according to the resource occupancy rate.
Specifically, if it is determined that the target resource recycling operation is executed, step S205 is executed; if it is determined that the target resource reclamation operation is not performed, step S206 is performed.
S205: and if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed.
Specifically, if the target resource recovery operation is determined to be executed, a target resource pressure coefficient corresponding to the target resource is obtained; after step S205, the execution step executes steps S207 to S208.
S206: and if the target resource recovery operation is determined not to be executed, acquiring a target resource pressure coefficient from a preset target resource pressure coefficient list according to the resource occupancy rate, wherein the target resource pressure coefficient list comprises the corresponding relation between the target resource pressure coefficient and the resource occupancy rate.
Specifically, in step S204, when the system reads a target file page in advance, whether to recycle the target resource is determined according to the acquired resource occupancy rate of the target resource, if it is determined that the target resource is not to be recycled, this step S206 is executed, specifically, a target resource pressure coefficient list is set, where the target resource pressure coefficient list includes a corresponding relationship between a target resource pressure coefficient and a resource occupancy rate, and if the resource occupancy rate of the target resource is relatively small, the target resource of the system resource is in a low-pressure state or a no-pressure state, and the target resource does not need to be recycled, since the STALL _ TIME = end TIME-start TIME, the STALL _ TIME represents TIME consumed by recycling of the target resource, the target resource is used as a memory, if a process applies for the memory, when the memory is insufficient, the memory recycling needs to be directly performed, and at this TIME, the process can run the process or execute the next step of the process only when the memory needs to be recycled to a preset memory threshold; the STALL _ TIME represents the TIME from the beginning of the memory recovery to the preset threshold, and if the STALL _ TIME is larger, the difficulty of the memory recovery is larger. The STALL _ TIME represents the target resource pressure coefficient in this embodiment, and at this TIME, the STALL _ TIME is set to 0 according to a preset target resource pressure coefficient list, that is, the STALL _ TIME =0, so as to avoid erroneous judgment in the pre-reading process.
It is understood that, after the step S206 is completed, the steps S207 to S208 are executed, which is not further described in this embodiment.
S207: and when the target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient.
Specifically, the method steps described in steps S204, S205 and S207 are similar to or similar to the method steps described in step S102, step S103 and step S104, and the content description of the partial flow is consistent with the content description of step S102 to step S104, which is not further described in this embodiment.
S208: and pre-reading the file page according to the adjusted pre-reading capability.
Specifically, after the pre-reading capability of the system is adjusted, the adjusted pre-reading capability is obtained, and the target file page is pre-read according to the pre-reading capability. It should be noted that, when the manner of adjusting the pre-reading capability is not limited to include: reducing the pre-reading capability, closing the pre-reading, and when the pressure of target resources in system resources is too large and the pre-reading process needs to be closed, the adjusted pre-reading capability can be understood as 0, and at the moment, the pre-reading is not performed, namely the pre-reading process is closed; if the pre-reading capability is only reduced, the system performs pre-reading according to the adjusted pre-reading capability. By executing this step, pre-reading or closing pre-reading can be performed to reduce the pressure of the target resource, thereby reducing the system burden.
Referring to fig. 3, a block diagram of an adjusting apparatus for pre-reading a file according to an embodiment of the present invention is shown; the invention also provides a device for adjusting the file pre-reading, which comprises:
a first obtaining module 301, configured to obtain a resource occupancy rate corresponding to a target resource in a system resource, where the system resource includes a plurality of different target resources;
a determining module 302, configured to determine whether to execute a target resource recycling operation according to the resource occupancy rate;
a second obtaining module 303, configured to obtain a target resource pressure coefficient corresponding to a target resource if a target resource recovery operation is performed, where the target resource pressure coefficient is used to indicate a pressure when the target resource recovery operation is performed;
and the adjusting module 304 is configured to adjust the pre-reading capability of the system according to the target resource pressure coefficient when the target document page is pre-read.
The invention provides an adjusting device for file pre-reading, comprising: a first obtaining module 301, a determining module 302, a second obtaining module 303 and an adjusting module 304; specifically, a first obtaining module 301 obtains a resource occupancy rate corresponding to a target resource in a system resource, where the system resource includes a plurality of different target resources; determining whether to execute target resource recycling operation according to the acquired resource occupancy rate through a determination module 302; the second obtaining module 303 is configured to, if a target resource recovery operation is executed, obtain a target resource pressure coefficient corresponding to the target resource recovery; when the target document page is pre-read, the pre-reading capability of the system is adjusted by the adjusting module 304 according to the target resource pressure coefficient. By implementing the scheme, the use condition of the target resource is analyzed according to the resource occupancy rate so as to determine the recovery target resource, the accuracy of the recovery target resource is improved, after the recovery target resource is determined, the pressure when the target resource is recovered is analyzed according to the corresponding target resource pressure coefficient, the pre-reading capability of the system is adjusted according to the actual pressure of the target resource, the resource of the system is prevented from being excessively consumed when the file page is pre-read, the burden of the system resource can be effectively reduced, the damage to the system is reduced, and the pre-reading reliability is improved.
In an implementation manner of this embodiment, the first obtaining module 301 is specifically configured to: detecting a load corresponding to a target resource in a resource system; distributing corresponding target resources for the page of the pre-read target file according to the load corresponding to the target resources in the resource system; and calculating the corresponding resource occupancy rate according to the allocated target resources.
In an implementation manner in this embodiment, the determining module 302 specifically uses the following: comparing the acquired resource occupancy rate of the target resource with a preset resource occupancy threshold value; if the resource occupancy rate is greater than or equal to the resource occupancy threshold value, executing target resource recovery operation; and if the resource occupancy rate is less than the resource occupancy threshold value, the target resource recovery operation is not executed.
In an implementation manner in this embodiment, the second obtaining module 303 specifically uses the following: if the target resource recovery operation is executed, recording the initial timestamp of the target resource recovery; recording an ending time stamp of the target resource until the target resource cannot be recovered; and determining a corresponding target resource pressure coefficient after the target resource is recovered according to the ending time stamp and the starting time stamp.
In another implementation manner of this embodiment, the second obtaining module 303 is further specifically configured to: and if the target resource recovery operation is not executed, acquiring a target resource pressure coefficient from a preset target resource pressure coefficient list according to the resource occupancy rate, wherein the target resource pressure coefficient list comprises the corresponding relation between the target resource pressure coefficient and the resource occupancy rate.
In an implementation manner of this embodiment, the purpose of the adjusting module 304 is specifically as follows: acquiring a target resource pressure coefficient; determining a resource adjusting coefficient according to the target resource pressure coefficient and a preset resource pressure threshold value; and adjusting the pre-reading capability of the system by using the resource adjusting coefficient.
In another implementation manner of this embodiment, the adjusting module 304 is further specifically configured to: acquiring a target resource pressure coefficient; comparing the target resource pressure coefficient with a preset first resource pressure threshold; if the target resource pressure coefficient is greater than the first resource pressure threshold, adjusting the pre-reading capability of the system to be closed; if the target resource pressure coefficient is smaller than the first resource pressure threshold, comparing the target resource pressure coefficient with a preset second resource pressure threshold; and if the target resource pressure coefficient is larger than the second resource pressure threshold value, reducing the pre-reading capability of the system.
In an embodiment of the adjusting apparatus for file pre-reading provided by the present invention, the adjusting apparatus includes: the analyzing module 301, the determining module 302, the obtaining module 303, and the adjusting module 304, where the upper module is a device module corresponding to the embodiment of the adjusting method for file pre-reading provided by the present invention, and the content description of the relevant module is consistent with the corresponding content description in the embodiment of the adjusting method for file pre-reading provided by the present invention, which is not further described in this embodiment.
Further, the apparatus further comprises:
and a pre-reading module 305, configured to pre-read the file page according to the adjusted pre-reading capability.
Specifically, after the pre-reading capability of the system is adjusted, the adjusted pre-reading capability is obtained, and the pre-reading module 305 pre-reads the target file page according to the pre-reading capability. It should be noted that, when the manner of adjusting the pre-reading capability is not limited to include: the pre-reading capability is reduced, the pre-reading is closed, when the pressure of the target resource in the system resource is too large and the pre-reading process needs to be closed, the size of the adjusted pre-reading capability can be understood as 0, at this time, the pre-reading is not performed, that is, the pre-reading process is closed through the pre-reading module 305; if the read-ahead capability is just reduced, the read-ahead module 305 performs read-ahead according to the adjusted read-ahead capability. The module can execute pre-reading or close pre-reading to reduce the pressure of target resources, thereby reducing the burden of the system.
The present invention provides an electronic device, please refer to fig. 4, which is an architecture diagram of the electronic device according to an embodiment of the present invention, and the electronic device includes: the adjusting method includes a memory 401, a processor 402, and a communication bus 403, where the communication bus 403 is connected to the memory 401 and the processor 402 in a communication manner, respectively, the memory 401 is coupled to the processor 402, the memory 401 stores a computer program, and when the processor 402 executes the computer program, the adjusting method implements each step in the adjusting method for file pre-reading according to any one of the above embodiments.
Illustratively, the computer program of the adjusting method for file pre-reading mainly comprises: acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources; determining whether to execute target resource recovery operation according to the resource occupancy rate; if the target resource recovery operation is executed, acquiring a target resource pressure coefficient corresponding to the target resource, wherein the target resource pressure coefficient is used for indicating the pressure when the target resource recovery operation is executed; and when the target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient. In addition, the computer program may also be divided into one or more modules, which are stored in the memory and executed by the processor to accomplish the present invention. One or more of the modules may be a series of computer program instruction segments capable of performing certain functions, the instruction segments being used to describe the execution of a computer program in a computing device. For example, the computer program may be divided into a first obtaining module 301, a determining module 302, a second obtaining module 303, an adjusting module 304, and a read-ahead module 305 as shown in fig. 3.
The Processor 402 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The present invention further provides a storage medium, where the storage medium is a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the adjusting method for file pre-reading according to any of the above embodiments are implemented.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that for simplicity and convenience of description, the above-described method embodiments are shown as a series of combinations of acts, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no acts or modules are necessarily required of the invention.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the above description, for a person skilled in the art, according to the idea of the embodiment of the present invention, there are variations in the specific implementation and application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (7)

1. An adjusting method for file pre-reading is characterized by comprising the following steps:
acquiring resource occupancy rates corresponding to target resources in system resources, wherein the system resources comprise a plurality of different target resources;
comparing the resource occupancy rate with a preset resource occupancy threshold value, wherein the resource occupancy threshold value is used for judging the occupancy condition of the system resource so as to determine whether to recover the target resource in the system resource; if the resource occupancy rate is greater than or equal to the resource occupancy threshold value, executing target resource recovery operation; if the resource occupancy rate is smaller than the resource occupancy threshold value, target resource recovery operation is not executed;
if the target resource recovery operation is executed, recording an initial timestamp of the target resource recovery operation; recording an ending time stamp of the target resource recovery operation until the target resource cannot be recovered; determining a corresponding target resource pressure coefficient during target resource recovery according to the ending timestamp and the starting timestamp, wherein the target resource pressure coefficient is used for indicating the pressure during target resource recovery operation; when a target file page is pre-read, adjusting the pre-reading capability of the system according to the target resource pressure coefficient;
and if the target resource recovery operation is not executed, acquiring the target resource pressure coefficient from a preset target resource pressure coefficient list according to the resource occupancy rate, wherein the target resource pressure coefficient list comprises the corresponding relation between the target resource pressure coefficient and the resource occupancy rate.
2. The method for adjusting file pre-reading according to claim 1, wherein the step of obtaining the resource occupancy rate corresponding to the target resource in the system resource includes:
detecting the load corresponding to the target resource in the system resource;
distributing corresponding target resources for the page of the pre-read target file according to the load corresponding to the target resources in the system resources;
and calculating the corresponding resource occupancy rate according to the allocated target resources.
3. The method for adjusting file read-ahead according to claim 1, wherein the step of adjusting the read-ahead capability of the system according to the target resource pressure coefficient comprises:
acquiring the target resource pressure coefficient;
determining a resource adjusting coefficient according to the target resource pressure coefficient and a preset resource pressure threshold value;
and adjusting the pre-reading capacity of the system by using the resource adjusting coefficient.
4. The method for adjusting file read-ahead according to claim 1, wherein the step of adjusting the read-ahead capability of the system according to the target resource pressure coefficient comprises:
comparing the target resource pressure coefficient with a preset first resource pressure threshold;
if the target resource pressure coefficient is greater than the first resource pressure threshold, closing the pre-reading capability of the system;
if the target resource pressure coefficient is smaller than the first resource pressure threshold, comparing the target resource pressure coefficient with a preset second resource pressure threshold;
and if the target resource pressure coefficient is greater than the second resource pressure threshold, reducing the pre-reading capability of the system.
5. An apparatus for adjusting the pre-reading of a document, the apparatus comprising:
the first acquisition module is used for acquiring the resource occupancy rate corresponding to a target resource in system resources, wherein the system resources comprise a plurality of different target resources;
the determining module is used for comparing the resource occupancy rate with a preset resource occupancy threshold value, wherein the resource occupancy threshold value is used for judging the occupancy condition of the system resource so as to determine whether to recover the target resource in the system resource; if the resource occupancy rate is greater than or equal to the resource occupancy threshold value, executing target resource recovery operation; if the resource occupancy rate is smaller than the resource occupancy threshold value, target resource recovery operation is not executed;
the second acquisition module is used for recording the starting timestamp of the target resource recycling operation if the target resource recycling operation is executed; recording an ending time stamp of the target resource recovery operation until the target resource cannot be recovered; determining a corresponding target resource pressure coefficient during target resource recovery according to the ending timestamp and the starting timestamp, wherein the target resource pressure coefficient is used for indicating the pressure during target resource recovery operation;
the adjusting module is used for adjusting the pre-reading capability of the system according to the target resource pressure coefficient when pre-reading the target file page;
the second obtaining module is further configured to, if a target resource recovery operation is not performed, obtain the target resource pressure coefficient from a preset target resource pressure coefficient list according to the resource occupancy rate, where the target resource pressure coefficient list includes a corresponding relationship between the target resource pressure coefficient and the resource occupancy rate.
6. An electronic device, comprising: a memory, a processor and a communication bus, wherein the communication bus is respectively connected to the memory and the processor in a communication manner, the memory stores a computer program, and the processor executes the computer program to realize each step of the adjusting method for file pre-reading according to any one of claims 1 to 4.
7. A storage medium, which is a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps in the adjusting method for file pre-reading according to any one of claims 1 to 4.
CN202010895854.6A 2020-08-31 2020-08-31 File pre-reading adjusting method and device, electronic equipment and storage medium Active CN111930513B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010895854.6A CN111930513B (en) 2020-08-31 2020-08-31 File pre-reading adjusting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010895854.6A CN111930513B (en) 2020-08-31 2020-08-31 File pre-reading adjusting method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111930513A CN111930513A (en) 2020-11-13
CN111930513B true CN111930513B (en) 2023-02-28

Family

ID=73309758

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010895854.6A Active CN111930513B (en) 2020-08-31 2020-08-31 File pre-reading adjusting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111930513B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112558866B (en) * 2020-12-03 2022-12-09 Oppo(重庆)智能科技有限公司 Data pre-reading method, mobile terminal and computer readable storage medium
CN113485855B (en) * 2021-08-02 2024-05-10 安徽文香科技股份有限公司 Memory sharing method and device, electronic equipment and readable storage medium
CN113760191B (en) * 2021-08-31 2022-09-23 荣耀终端有限公司 Data reading method, data reading apparatus, storage medium, and program product

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1280063A2 (en) * 2001-07-27 2003-01-29 Fujitsu Limited Cache control methods and apparatus for hard disk drives
CN101853218A (en) * 2010-05-12 2010-10-06 中兴通讯股份有限公司 Method and system for reading redundant array of inexpensive disks (RAID)
CN105487987A (en) * 2015-11-20 2016-04-13 深圳市迪菲特科技股份有限公司 Method and device for processing concurrent sequential reading IO (Input/Output)
CN105955821A (en) * 2016-04-21 2016-09-21 北京小米移动软件有限公司 Method and device for pre-reading
CN110727606A (en) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device and electronic equipment
CN111338796A (en) * 2020-02-18 2020-06-26 广州虎牙科技有限公司 Application memory optimization method and device, terminal equipment and readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175078B (en) * 2019-05-30 2020-12-01 口碑(上海)信息技术有限公司 Service processing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1280063A2 (en) * 2001-07-27 2003-01-29 Fujitsu Limited Cache control methods and apparatus for hard disk drives
CN101853218A (en) * 2010-05-12 2010-10-06 中兴通讯股份有限公司 Method and system for reading redundant array of inexpensive disks (RAID)
CN105487987A (en) * 2015-11-20 2016-04-13 深圳市迪菲特科技股份有限公司 Method and device for processing concurrent sequential reading IO (Input/Output)
CN105955821A (en) * 2016-04-21 2016-09-21 北京小米移动软件有限公司 Method and device for pre-reading
CN110727606A (en) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device and electronic equipment
CN111338796A (en) * 2020-02-18 2020-06-26 广州虎牙科技有限公司 Application memory optimization method and device, terminal equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种支持并发访问流的文件预取算法;吴峰光等;《软件学报》;20100815(第08期);第1820-1833页 *

Also Published As

Publication number Publication date
CN111930513A (en) 2020-11-13

Similar Documents

Publication Publication Date Title
CN111930513B (en) File pre-reading adjusting method and device, electronic equipment and storage medium
US20190361609A1 (en) Data storage method, apparatus and storage medium
CN108920387B (en) Method and device for reducing read delay, computer equipment and storage medium
CN108733306B (en) File merging method and device
US8108649B2 (en) Method of memory management for server-side scripting language runtime system
CN111324303B (en) SSD garbage recycling method, SSD garbage recycling device, computer equipment and storage medium
KR20090026296A (en) Predictive data-loader
CN103473150A (en) Fragment rewriting method for data repetition removing system
US11886743B2 (en) Method for enhancing quality of service of solid-state drive and solid-state drive
CN105117351A (en) Method and apparatus for writing data into cache
US20190188189A1 (en) Heterogeneous file optimization
WO2023029971A1 (en) Heterogeneous memory-based data migration method
CN114035750A (en) File processing method, device, equipment, medium and product
CN114968839A (en) Hard disk garbage recycling method, device and equipment and computer readable storage medium
CN116225334A (en) Cold and hot data storage method, device and medium
US20240070120A1 (en) Data processing method and apparatus
CN112181870B (en) Memory page management method, device and equipment and readable storage medium
CN115079936A (en) Data writing method and device
CN103064762B (en) Heavily delete restoration methods and the device of Backup Data
CN113360527B (en) Buffer size processing method and device and computer equipment
Park et al. OFTL: Ordering-aware FTL for maximizing performance of the journaling file system
EP3296878B1 (en) Electronic device and page merging method therefor
CN114974365A (en) SSD (solid State disk) limited window data deduplication identification method and device and computer equipment
JP4558003B2 (en) Data access processing method and storage control device
CN108762679B (en) Method for combining online DDP (distributed data processing) and offline DDP (distributed data processing) and related device thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant