CN116185644A - Memory recycling control method, storage medium, processor and terminal equipment - Google Patents

Memory recycling control method, storage medium, processor and terminal equipment Download PDF

Info

Publication number
CN116185644A
CN116185644A CN202310466728.2A CN202310466728A CN116185644A CN 116185644 A CN116185644 A CN 116185644A CN 202310466728 A CN202310466728 A CN 202310466728A CN 116185644 A CN116185644 A CN 116185644A
Authority
CN
China
Prior art keywords
memory
priority
control group
target
reclamation
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.)
Pending
Application number
CN202310466728.2A
Other languages
Chinese (zh)
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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing 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 Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202310466728.2A priority Critical patent/CN116185644A/en
Publication of CN116185644A publication Critical patent/CN116185644A/en
Pending legal-status Critical Current

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/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/5022Mechanisms to release resources
    • 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/5038Allocation 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 execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The embodiment of the invention discloses a memory recycling control method, a storage medium, a processor and terminal equipment, wherein the memory recycling control method comprises the following steps: determining a priority threshold of memory reclamation; determining a target control group according to the magnitude relation between the priority value of each candidate control group and the priority threshold, wherein the priority value of the target control group is greater than or equal to the priority threshold, and the priority value of each candidate control group is a preset value; and recycling the memory pages of the target control group. The method solves the technical problem that the memory recovery method in the prior art is easy to influence the normal operation of the time-sensitive task.

Description

Memory recycling control method, storage medium, processor and terminal equipment
Technical Field
The present invention relates to the field of memory reclamation, and in particular, to a memory reclamation control method, a storage medium, a processor, and a terminal device.
Background
In the existing memory reclamation technology, in the process of performing memory reclamation, for each Cgroup (Control Group, the memory resource controller of the Control Group is used to Control the memory usage of a Group of processes, the Control Group of the memory resource controller is enabled to be the memory Control Group, the english name is MemoryControl Group, referred to as memcg), memory pages are averagely reclaimed, in the scene of mixing high-priority tasks and low-priority tasks, the high-priority tasks are sensitive to time delay, the low-priority tasks are relatively insensitive to time delay, and if the memory pages of each Cgroup are averagely reclaimed, the time delay is possibly caused to the high-priority tasks, so that the normal operation of the high-priority tasks is affected.
Therefore, the memory recovery method in the prior art is easy to influence the normal operation of the delay sensitive task. In view of the above problems, no effective solution has been proposed at present.
The above information disclosed in the background section is only for enhancement of understanding of the background of the technology described herein. Accordingly, the background art may contain some information that is not otherwise known to those of skill in the art.
Disclosure of Invention
The embodiment of the invention provides a memory recycling control method, a storage medium, a processor and terminal equipment, which at least solve the technical problem that the memory recycling method in the prior art is easy to influence the normal operation of a delay sensitive task.
According to a first aspect of an embodiment of the present invention, there is provided a memory reclamation control method, including: determining a priority threshold of memory reclamation; determining a target control group according to the magnitude relation between the priority value of each candidate control group and the priority threshold, wherein the priority value of the target control group is greater than or equal to the priority threshold, and the priority value of each candidate control group is a preset value; and recycling the memory pages of the target control group.
Further, determining the priority threshold for memory reclamation includes: acquiring priority values of each candidate control group; determining the priority threshold as the maximum value of the plurality of priority values that meets a target requirement, the target requirement comprising: when the priority value is used as the priority threshold value for memory reclamation, the quantity of the recyclable memory pages reaches the target quantity.
Further, determining the priority threshold as the maximum of the plurality of priority values that meets the target requirement comprises: sequentially determining temporary thresholds according to the sequence of the priority values from big to small; determining whether the sum of the numbers of the recoverable memory pages in the control group to be recovered reaches the target number or not every time the temporary threshold value is determined, wherein the control group to be recovered is a candidate control group with the priority value larger than or equal to the temporary threshold value; and determining the current temporary threshold value as the priority threshold value until the sum of the quantity of the recoverable memory pages in the control group to be recovered reaches the target quantity.
Further, reclaiming the memory pages of the target control group includes: determining the number of target control groups; according to the number of the target and the number of the target control groups, calculating the number of memory pages to be recovered of each target control group; and recycling the memory pages of each target control group according to the number of the memory pages to be recycled of each target control group.
Further, after reclaiming the memory pages of the target control group, the memory reclaiming control method further includes: determining whether the number of recovered memory pages reaches a target number; and under the condition that the number of the recovered memory pages does not reach the target number, reducing the priority threshold value, re-determining the target control group, and recovering the memory pages of the newly determined target control group until the number of the recovered memory pages reaches the target number.
Further, the memory page is an anonymous page or a file page, wherein: the priority threshold is a first threshold when the memory page is an anonymous page, and a second threshold when the memory page is a file page; and/or, when the memory page is an anonymous page, the priority value of each control group is a corresponding swappeness value, the swappeness value represents the priority of recovering the anonymous page and the file page during memory recovery, and the higher the swappeness value is, the higher the priority of recovering the anonymous page during memory recovery is.
Further, before determining the target control group according to the magnitude relation between the priority value and the priority threshold value of each candidate control group, the memory reclamation control method further comprises: receiving a reclamation range control instruction, wherein the reclamation range control instruction indicates the action range of memory reclamation; a candidate control group is determined from the plurality of control groups in accordance with the reclamation range control instruction.
According to a second aspect of the embodiment of the present invention, there is further provided a nonvolatile storage medium, where the nonvolatile storage medium includes a stored program, and when the program runs, the device on which the nonvolatile storage medium is controlled to execute the above memory reclamation control method.
According to a third aspect of the embodiment of the present invention, there is further provided a processor, where the processor is configured to run a program, and the memory reclamation control method is executed when the program runs.
According to a fourth aspect of the embodiment of the present invention, there is also provided a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the memory reclamation control method described above when executing the computer program.
When the memory recovery control method of the embodiment of the invention recovers the memory pages of the plurality of candidate control groups, the priority threshold value of the memory recovery is determined first, and is compared with the priority value preset by each candidate control group, and the candidate control group with the priority value larger than or equal to the priority threshold value is determined as the target control group, so that the memory pages are recovered. The memory reclamation mode adopting the priority control can set a priority value for the candidate control group corresponding to each task, and realize the memory reclamation of the specific candidate control group by controlling the priority threshold. For the high-priority task with time delay sensitivity, only the priority value of the corresponding candidate control group is required to be set to be a smaller value, so that the priority threshold value is larger than the priority value, and the recovery of the memory pages of the candidate control group can be prevented, thereby ensuring the smooth operation of the high-priority task with time delay sensitivity, and solving the technical problem that the normal operation of the time delay sensitive task is easily influenced by the memory recovery method in the prior art.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
FIG. 1 is a flow chart of a memory reclamation control method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a memory reclamation control apparatus according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating memory reclamation performed by a memory reclamation control method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of high-priority task throughput without priority reclamation control (left) and with priority reclamation control (right);
fig. 5 is a diagram illustrating memory reclamation overhead without (upper) and with (lower) priority reclamation control.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region, and provide corresponding operation entries for the user to select authorization or rejection. The terms first, second and the like in the description and in the claims and drawings are used for distinguishing between different objects and not for limiting the specified sequence.
Fig. 1 is a memory reclamation control method according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, determining a priority threshold of memory reclamation;
step S104, determining a target control group according to the magnitude relation between the priority value of each candidate control group and the priority threshold, wherein the priority value of the target control group is greater than or equal to the priority threshold, and the priority value of each candidate control group is a preset value;
step S106, the memory pages of the target control group are recycled.
When the memory recycling control method of the scheme is used for recycling the memory pages of the candidate control groups, a priority threshold value of memory recycling is determined first, the priority threshold value is compared with a priority value preset by each candidate control group, and the candidate control group with the priority value being greater than or equal to the priority threshold value is determined as a target control group, so that the memory pages are recycled. The memory reclamation mode adopting the priority control can set a priority value for the candidate control group corresponding to each task, and realize the memory reclamation of the specific candidate control group by controlling the priority threshold value, thereby improving the flexibility of the memory reclamation control. For the high-priority task with time delay sensitivity, only the priority value of the corresponding candidate control group is required to be set to be a smaller value, so that the priority threshold value is larger than the priority value, and the recovery of the memory pages of the candidate control group can be prevented, thereby ensuring the smooth operation of the high-priority task with time delay sensitivity, and solving the technical problem that the normal operation of the time delay sensitive task is easily influenced by the memory recovery method in the prior art.
Wherein, the control group, i.e. Cgroup, is the abbreviation of control group, and Cgroup may refer to the whole Cgroup technology or a specific process group. The control group (Cgroup) of the memory resource controllers is used to control the memory usage of a set of processes, and the control group that enables the memory resource controllers is referred to as the memory control group (memcg, memory control group) that provides management of the memory behavior of a set of processes in the system.
As described above, the priority threshold is used to compare with the priority values of the candidate control groups, so as to determine the target control group, so that the control effect of memory reclamation is directly affected by the determined quality of the priority threshold. In practice, the determination of the priority threshold may be implemented in a variety of different manners, such as manually inputting the priority threshold, calculating the priority threshold based on a preset algorithm based on the number of memory pages reclaimed, and so on. In a preferred embodiment, determining the priority threshold for memory reclamation includes: acquiring priority values of each candidate control group; determining the priority threshold as the maximum value of the plurality of priority values that meets a target requirement, the target requirement comprising: when the priority value is used as the priority threshold value for memory reclamation, the quantity of the recyclable memory pages reaches the target quantity.
In this embodiment, in the process of determining the priority threshold, the priority value of each candidate control group is first obtained, and then the maximum value meeting the target requirement is selected as the priority threshold, where the target requirement includes: when the priority value is used as a priority threshold value for memory reclamation, the quantity of the recyclable memory pages reaches the target quantity. That is, in determining the priority threshold, it is necessary to perform overall judgment from the number of recoverable memory pages, so that the finally determined priority threshold is not only large enough, but also the number of memory pages that can be recovered can meet the requirement of the target number. The method can ensure that the candidate control groups with higher memory recycling priority are recycled on the basis of ensuring the memory recycling effect. For example, the priority value of the time delay sensitive task is lower, the priority of the time delay insensitive task is higher, and by adopting the priority threshold determining mode, the memory pages which are all the recovered test insensitive tasks can be ensured on the basis of ensuring the recovery quantity of the memory pages, so that the smooth operation of the time delay sensitive high-priority task is ensured. It should be noted that, the priority value and the priority threshold refer to the priority of memory reclamation, and a larger priority value indicates that the memory of the control group is easier to be reclaimed. The above-mentioned high-priority task refers to a task that needs to be processed at a higher priority or needs to be guaranteed to run smoothly.
In a specific embodiment, determining the priority threshold as the maximum of the plurality of priority values that meets the target requirement comprises: sequentially determining temporary thresholds according to the sequence of the priority values from big to small; determining whether the sum of the numbers of the recoverable memory pages in the control group to be recovered reaches the target number or not every time the temporary threshold value is determined, wherein the control group to be recovered is a candidate control group with the priority value larger than or equal to the temporary threshold value; and determining the current temporary threshold value as the priority threshold value until the sum of the quantity of the recoverable memory pages in the control group to be recovered reaches the target quantity.
That is, in this embodiment, a maximum value is determined from the plurality of priority values as a temporary threshold, and it is determined whether the sum of the recoverable memory pages reaches the target number, if not, a value next to the maximum value is selected from the other priority thresholds as the temporary threshold, and it is again determined whether the sum of the recoverable memory pages reaches the target number, until the sum of the recoverable memory pages reaches the target number.
As described above, in the embodiment of the present application, different from the manner of average memory page reclamation for each candidate control group in the prior art, a priority threshold is used to screen out a portion of target control groups for memory reclamation, so that differentiated memory page reclamation is implemented according to the priority condition of a task, and the flexibility of reclamation control is higher. Since the number of the reclaimed control groups is reduced, in order to ensure that the number of memory pages meeting the requirement can be reclaimed, in this embodiment, reclaiming the memory pages of the target control group includes: determining the number of target control groups; according to the number of the target and the number of the target control groups, calculating the number of memory pages to be recovered of each target control group; and recycling the memory pages of each target control group according to the number of the memory pages to be recycled of each target control group.
In this embodiment, the number of memory pages to be recovered allocated to each target control group is calculated according to the number of target control groups and the target number, and then memory page recovery is performed on the corresponding target control groups according to the number of memory pages to be recovered, so that under the condition that the number of recovered control groups is reduced, it is ensured that enough memory pages are recovered at one time, and the situation that the memory pages recovered after executing the recovery logic once are insufficient and the recovery of the memory pages is triggered repeatedly is avoided, thereby ensuring the high efficiency of the system.
By adopting the memory reclamation control method in the setting manner, whether a sufficient number of memory pages can be reclaimed by adopting the corresponding priority threshold value can be determined in advance when the priority threshold value is determined, but when the reclamation logic is actually executed, the problem that the actual situation is inconsistent with the expectations can also occur, for example, if a plurality of processes synchronously reclaim the memory pages, a part of the memory pages are reclaimed by other processes, the current process cannot reclaim the memory pages conforming to the expected number. In order to ensure that the number of memory pages reclaimed reaches the target number requirement, in this embodiment, after reclaiming the memory pages of the target control group, the memory reclaiming control method further includes: determining whether the number of recovered memory pages reaches a target number; and under the condition that the number of the recovered memory pages does not reach the target number, reducing the priority threshold value, re-determining the target control group, and recovering the memory pages of the newly determined target control group until the number of the recovered memory pages reaches the target number.
That is, after the memory page reclaiming operation is executed, whether the number of the memory pages received reaches the target number is again confirmed, if not, the priority threshold is lowered, so as to determine more target control groups, and the memory pages are reclaimed again for the newly determined target control groups, so that more memory pages are reclaimed until the number of the memory pages actually reclaimed reaches the requirement of the target number.
In actual implementation, the priority values of the candidate control groups can be flexibly set according to the processing priorities of the corresponding tasks. In a preferred embodiment, the memory page is an anonymous page or a file page, wherein: the priority threshold is a first threshold when the memory page is an anonymous page, and a second threshold when the memory page is a file page; and/or, when the memory page is an anonymous page, the priority value of each control group is a corresponding swappeness value, the swappeness value represents the priority of recovering the anonymous page and the file page during memory recovery, and the higher the swappeness value is, the higher the priority of recovering the anonymous page during memory recovery is.
In this embodiment, the memory page may be an anonymous page or a file page, where the anonymous page is a page without a file background (a memory page without any mapping relationship with a disk file), such as a stack, a heap, a data segment, a shared memory, and the like; file pages are memory pages (pages with file background) that have mapping relation with disk files, such as process code segments, mapping pages of files, etc., and they have corresponding hard disk files. Because the memory pages of the control groups corresponding to different tasks are used differently, some control groups may have most of the memory pages anonymous pages, while some control groups may have more file pages. In this embodiment, the anonymous page reclamation and the file page reclamation are divided, if the anonymous page reclamation is performed, the first threshold is used as a priority threshold, and if the file page reclamation is performed, the second threshold is used as a priority threshold, so that the anonymous page and the file page reclamation can be independently controlled, thereby realizing finer-granularity memory page reclamation control, and further improving the flexibility of the memory reclamation control.
In the case of recovering an anonymous page, in this embodiment, a swappeness value may be multiplexed, where the swappeness value characterizes the priority of recovering the anonymous page and the file page during memory recovery, and the greater the swappeness value, the higher the priority of recovering the anonymous page during memory recovery, so that the swappeness value may represent a tendency of recovering the anonymous page, and may be used as a priority value of recovering the anonymous page, thereby simplifying a memory recovery control method. For a file page, a value (e.g., a file-page_priority value) may be redefined as the priority value.
In a preferred embodiment, before determining the target control group according to the magnitude relation between the priority value and the priority threshold value of each candidate control group, the memory reclamation control method further includes: receiving a reclamation range control instruction, wherein the reclamation range control instruction indicates the action range of memory reclamation; a candidate control group is determined from the plurality of control groups in accordance with the reclamation range control instruction. The embodiment sets the function of recycling range control, and can limit the recycling range of the memory by inputting recycling range control instructions, so that candidate control groups needing to recycle the memory are selected from a plurality of control groups. For example, the Cgroup is a tree structure, and the memory page reclamation can be performed on the child nodes of the corresponding node by opening the memory reclamation control switch at each node of the Cgroup; for another example, a memory reclamation control switch is turned on at the root node of the Cgroup, so that global memory page reclamation is realized, and the flexibility of memory page reclamation control is effectively improved.
The following describes a memory reclamation control method according to an embodiment of the present application, and fig. 3 is a schematic diagram of memory reclamation performed by the memory reclamation control method according to an embodiment of the present invention. As shown in fig. 3, in the process of performing memory reclamation on anonymous pages, under the condition that the memory reclamation condition is met, initializing a priority threshold, in this embodiment, the priority threshold is expressed by swappeness_limit, and is assigned to max_ SWAPPINESS during initialization, that is, the maximum value of swappeness in a candidate control group is assigned to the priority threshold as a temporary threshold, and then it is determined whether the sum of the number of recoverable memory pages in the control group to be reclaimed reaches the requirement of the target number at this time, if not, the temporary threshold is reduced and retried until the sum of the number of recoverable memory pages in the control group to be reclaimed reaches the requirement of the target number. Wherein, the initialization and reassignment of the swappness_limit can be realized by calling the adjust_swap_priority interface. And then continuing to execute the memory page reclamation logic downwards by adopting the priority threshold, wherein the Shrink node executes corresponding operation to initialize the value. Shrink node memcgs each Cgroup is independently recovered, and memcgs is independently recovered for each list below the own Cgroup. The method comprises the steps that a Shrink list is divided into an anonymous page list and a file page list, for the anonymous page recycling process, the Shrink list lists the swappiness of each control group to be recycled, whether the memory page of the control group to be recycled can be recycled is determined by comparing the swappiness with swappiness_limit, and if the swappiness of one control group to be recycled is greater than or equal to swappiness_limit, the memory page of one control group to be recycled can be recycled, otherwise, the memory page of one control group to be recycled cannot be recycled. After the memory page reclaiming operation is executed, judging whether enough memory pages are reclaimed, if not, returning to the assignment step of the swappeteness_limit, reducing the value of the swappeteness_limit and retrying. In the process of recovering the anonymous page, the value of swappeness can be obtained through the get_scan_count interface, and if swappeness of a certain control group to be recovered is 0, it is indicated that the anonymous page is not recovered in the process of recovering the memory of the control group to be recovered, and then the step of recovering the anonymous page can be skipped.
Fig. 4 and fig. 5 show the actual effects of the memory reclamation control method according to the embodiment of the present application, and fig. 4 is a schematic diagram of the throughput of a high-priority task without using priority reclamation control (left) and using priority reclamation control (right), which can be seen that, after the above-mentioned priority reclamation control method is adopted, the throughput of the high-priority task is obviously higher, so that the technical problem that the memory reclamation method in the prior art is easy to affect the normal operation of the delay-sensitive task can be solved. Fig. 5 is a schematic diagram of memory reclamation overhead without (upper) and with (lower) priority reclamation control, and it can be seen that after the priority control is turned on, no additional memory reclamation times and time overhead are caused, and no performance rollback of memory reclamation is caused.
Next, as shown in fig. 2, an embodiment of the present invention further provides a memory reclamation control device, including: the first determining unit is used for determining a priority threshold value of memory reclamation; a second determining unit, configured to determine a target control group according to a magnitude relation between a priority value and a priority threshold of each candidate control group, where the priority value of the target control group is greater than or equal to the priority threshold, and the priority value of each candidate control group is a preset value; and the recovery unit is used for recovering the memory pages of the target control group. When the memory reclamation control device adopting the setting mode is used for reclaiming the memory pages of a plurality of candidate control groups, the first determining unit firstly determines the priority threshold value of the memory reclamation and compares the priority threshold value with the priority values preset by the candidate control groups, and the second determining unit determines the candidate control groups with the priority values larger than the priority threshold value as target control groups, so that the memory pages are reclaimed through the reclaiming unit. The memory reclamation mode adopting the priority control can set a priority value for the candidate control group corresponding to each task, and realize the memory reclamation of the specific candidate control group by controlling the priority threshold. For the high-priority task with time delay sensitivity, only the priority value of the corresponding candidate control group is required to be set to be a smaller value, so that the priority threshold value is larger than the priority value, and the recovery of the memory pages of the candidate control group can be prevented, thereby ensuring the smooth operation of the high-priority task with time delay sensitivity, and solving the technical problem that the memory recovery device in the prior art is easy to influence the normal operation of the time delay sensitive task.
In a specific embodiment, the first determining unit comprises: the acquisition module is used for acquiring the priority value of each candidate control group; a first determining module, configured to determine a priority threshold as a maximum value meeting a target requirement among a plurality of priority values, where the target requirement includes: when the priority value is used as a priority threshold value for memory reclamation, the quantity of the recyclable memory pages reaches the target quantity;
the first determination module includes: the first determining submodule is used for sequentially determining temporary thresholds according to the sequence from the big priority value to the small priority value; a second determining submodule, configured to determine whether a sum of numbers of recoverable memory pages in a control group to be recovered reaches a target number or not, where the control group to be recovered is a candidate control group whose priority value is greater than or equal to the temporary threshold value; a third determining submodule, configured to determine a current temporary threshold as a priority threshold until a sum of numbers of memory pages recoverable in the control group to be recovered reaches a target number;
the recovery unit includes: a second determining module, configured to determine the number of target control groups; the calculation module is used for calculating the number of memory pages to be recovered of each target control group according to the number of targets and the number of target control groups; the recovery module is used for recovering the memory pages of each target control group according to the number of the memory pages to be recovered of each target control group;
the memory reclamation device further comprises: a third determining unit, configured to determine, after reclaiming the memory pages of the target control group, whether the number of the reclaimed memory pages reaches the target number; a retry unit, configured to, when the number of recovered memory pages does not reach the target number, reduce a priority threshold, redetermine the target control group, and recover the memory pages of the newly determined target control group until the number of recovered memory pages reaches the target number;
the memory page is an anonymous page or a file page, wherein: the priority threshold is a first threshold when the memory page is an anonymous page, and a second threshold when the memory page is a file page; and/or, under the condition that the memory page is an anonymous page, the priority value of each control group is a corresponding swappeness value, the swappeness value represents the priority of recovering the anonymous page and the file page during memory recovery, and the higher the swappeness value is, the higher the priority of recovering the anonymous page during memory recovery is;
the memory reclamation device further comprises: the receiving unit is used for receiving a recovery range control instruction before determining the target control group according to the magnitude relation between the priority value and the priority threshold value of each candidate control group, wherein the recovery range control instruction indicates the action range of memory recovery; and a fourth determining unit configured to determine a candidate control group from the plurality of control groups according to the reclamation range control instruction.
In addition, the embodiment of the invention also provides a nonvolatile storage medium, wherein the nonvolatile storage medium comprises a stored program, and the device where the nonvolatile storage medium is controlled to execute the memory reclamation control method when the program runs.
The embodiment of the invention also provides a processor, wherein the processor is used for running a program, and the memory reclamation control method is executed when the program runs.
Finally, the embodiment of the invention also provides a terminal device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the memory reclamation control method is realized when the processor executes the computer program.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments. Moreover, the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that herein.
In the foregoing embodiments of the present invention, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed technology content may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, for example, may be a logic function division, and may be implemented in another manner, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform 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 Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (10)

1. A memory reclamation control method, comprising:
determining a priority threshold of memory reclamation;
determining a target control group according to the magnitude relation between the priority value of each candidate control group and the priority threshold, wherein the priority value of the target control group is larger than or equal to the priority threshold, and the priority value of each candidate control group is a preset value;
and recycling the memory pages of the target control group.
2. The memory reclamation control method of claim 1, wherein determining a priority threshold for memory reclamation comprises:
acquiring the priority value of each candidate control group;
determining the priority threshold as the maximum value of a plurality of priority values that meets a target requirement, the target requirement comprising: and when the priority value is used as the priority threshold value to carry out memory reclamation, the quantity of the recyclable memory pages reaches the target quantity.
3. The memory reclamation control method according to claim 2, wherein determining the priority threshold as the maximum value satisfying a target requirement among the plurality of priority values comprises:
sequentially determining temporary thresholds according to the sequence of the priority values from big to small;
determining whether the sum of the numbers of recoverable memory pages in a control group to be recovered reaches the target number or not every time the temporary threshold is determined, wherein the control group to be recovered is the candidate control group with the priority value larger than or equal to the temporary threshold;
and determining the current temporary threshold value as the priority threshold value until the sum of the quantity of the recoverable memory pages in the control group to be recovered reaches the target quantity.
4. The memory reclamation control method of claim 2, wherein reclaiming the memory pages of the target control group comprises:
determining the number of the target control groups;
according to the target quantity and the quantity of the target control groups, calculating the quantity of memory pages to be recovered of each target control group;
and recycling the memory pages of each target control group according to the number of the memory pages to be recycled of each target control group.
5. The memory reclamation control method according to claim 2, wherein after reclaiming the memory pages of the target control group, the memory reclamation control method further comprises:
determining whether the number of the recovered memory pages reaches the target number;
and under the condition that the number of the recovered memory pages does not reach the target number, the priority threshold is reduced, the target control group is redetermined, and the memory pages of the newly determined target control group are recovered until the number of the recovered memory pages reaches the target number.
6. The memory reclamation control method according to any one of claims 1 to 5, wherein the memory page is an anonymous page or a file page, wherein:
the priority threshold is a first threshold when the memory page is the anonymous page, and is a second threshold when the memory page is the file page; and/or the number of the groups of groups,
and under the condition that the memory pages are anonymous pages, the priority values of the control groups are corresponding swappesiness values, the swappesiness values represent the priorities of recovering the anonymous pages and the file pages during memory recovery, and the larger the swappesiness values are, the higher the priorities of recovering the anonymous pages during memory recovery are.
7. The memory reclamation control method according to any one of claims 1 to 5, wherein before determining a target control group according to a magnitude relation between a priority value of each candidate control group and the priority threshold, the memory reclamation control method further comprises:
receiving a reclamation range control instruction, wherein the reclamation range control instruction indicates the action range of memory reclamation;
and determining the candidate control group from a plurality of control groups according to the recycling range control instruction.
8. A nonvolatile storage medium, wherein the nonvolatile storage medium includes a stored program, wherein the program, when executed, controls a device in which the nonvolatile storage medium is located to execute the memory reclamation control method according to any one of claims 1 to 7.
9. A processor, wherein the processor is configured to execute a program, wherein the program executes the memory reclamation control method according to any one of claims 1 to 7.
10. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the memory reclamation control method according to any of claims 1 to 7 when executing the computer program.
CN202310466728.2A 2023-04-26 2023-04-26 Memory recycling control method, storage medium, processor and terminal equipment Pending CN116185644A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310466728.2A CN116185644A (en) 2023-04-26 2023-04-26 Memory recycling control method, storage medium, processor and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310466728.2A CN116185644A (en) 2023-04-26 2023-04-26 Memory recycling control method, storage medium, processor and terminal equipment

Publications (1)

Publication Number Publication Date
CN116185644A true CN116185644A (en) 2023-05-30

Family

ID=86444640

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310466728.2A Pending CN116185644A (en) 2023-04-26 2023-04-26 Memory recycling control method, storage medium, processor and terminal equipment

Country Status (1)

Country Link
CN (1) CN116185644A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103500121A (en) * 2013-09-29 2014-01-08 深圳Tcl新技术有限公司 Process managing method and device
US20170286288A1 (en) * 2016-03-30 2017-10-05 Sandisk Technologies Llc Method and System for Blending Data Reclamation and Data Integrity Garbage Collection
CN108073458A (en) * 2017-12-28 2018-05-25 努比亚技术有限公司 Method for recovering internal storage, mobile terminal and computer readable storage medium
CN110162396A (en) * 2018-02-14 2019-08-23 阿里巴巴集团控股有限公司 Method for recovering internal storage, device, system and storage medium
CN114443277A (en) * 2020-10-31 2022-05-06 华为终端有限公司 Memory management method and device, electronic equipment and computer readable storage medium
CN114968558A (en) * 2022-04-29 2022-08-30 深圳Tcl新技术有限公司 Memory cleaning method and related equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103500121A (en) * 2013-09-29 2014-01-08 深圳Tcl新技术有限公司 Process managing method and device
US20170286288A1 (en) * 2016-03-30 2017-10-05 Sandisk Technologies Llc Method and System for Blending Data Reclamation and Data Integrity Garbage Collection
CN108073458A (en) * 2017-12-28 2018-05-25 努比亚技术有限公司 Method for recovering internal storage, mobile terminal and computer readable storage medium
CN110162396A (en) * 2018-02-14 2019-08-23 阿里巴巴集团控股有限公司 Method for recovering internal storage, device, system and storage medium
CN114443277A (en) * 2020-10-31 2022-05-06 华为终端有限公司 Memory management method and device, electronic equipment and computer readable storage medium
CN114968558A (en) * 2022-04-29 2022-08-30 深圳Tcl新技术有限公司 Memory cleaning method and related equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
宋平波;李云;杨豪杰;: "Android内存管理机制研究", 移动通信, no. 07 *

Similar Documents

Publication Publication Date Title
EP1164491A2 (en) Ressource management method and apparatus for information processing system of multitasking facility
CN111338796B (en) Application memory optimization method and device, terminal equipment and readable storage medium
CN101351772A (en) Method and system for sharing files among different virtual machine images
US7818749B2 (en) Data processing method, data processing apparatus, and data processing program
US10901890B2 (en) Memory reclaiming method and apparatus
CN108205472B (en) Memory release method, release device, computer device and readable storage medium
CN116185644A (en) Memory recycling control method, storage medium, processor and terminal equipment
CN111522659B (en) Space use method and device
CN112286559A (en) Upgrading method and device for vehicle-mounted intelligent terminal
CN111338981A (en) Memory fragmentation prevention method and system and storage medium
CN115941758A (en) Cloud service console deployment method, system and storage medium based on dynamic programming
CN113626203A (en) Memory environment real-time optimization method and system for android system
US20170090820A1 (en) Method and device for operating a many-core system
CN114609892A (en) Rapid redundancy method of multi-task control system
CN109639639B (en) Fusion control method and device for multi-platform monitoring system
CN104572036B (en) Event processing method and device
CN113467901A (en) Task scheduling method and related equipment
CN111078357A (en) Virtual machine backup method and equipment
CN113127180A (en) Memory optimization method, intelligent terminal and storage medium
CN112988287B (en) Application program running method and device
CN114217922A (en) Crawler service processing method and equipment
CN107247641B (en) Method and device for restoring operating system on line
CN109885330B (en) Virtual machine generation method and device
CN109947548B (en) Method and device for distributing time slices and method and device for controlling task execution
CN107729211A (en) A kind of condition responsive method of MCU system

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20230530