CN114995993A - Memory recovery method and device - Google Patents

Memory recovery method and device Download PDF

Info

Publication number
CN114995993A
CN114995993A CN202210429570.7A CN202210429570A CN114995993A CN 114995993 A CN114995993 A CN 114995993A CN 202210429570 A CN202210429570 A CN 202210429570A CN 114995993 A CN114995993 A CN 114995993A
Authority
CN
China
Prior art keywords
memory
memory object
target
target memory
preset
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
CN202210429570.7A
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 China Co Ltd
Original Assignee
Alibaba China 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 Alibaba China Co Ltd filed Critical Alibaba China Co Ltd
Priority to CN202210429570.7A priority Critical patent/CN114995993A/en
Publication of CN114995993A publication Critical patent/CN114995993A/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

An embodiment of the present specification provides a memory recovery method and a device, where the memory recovery method includes: scanning a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets a preset memory size, determining a first memory object from the target memory object according to the reference counting information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object with reference counting lower than a preset threshold value. The method comprises the steps of selecting a target memory object meeting the preset memory size, determining a first memory object from the target memory objects according to the reference count, judging whether the target memory object needs to be recycled according to the preset recycling condition so as to recycle a part of the target memory objects, reducing the performance loss of the system, and improving the stability of the system due to the fact that the target memory object which is used less is selected for recycling.

Description

Memory recovery method and device
Technical Field
The embodiment of the specification relates to the technical field of computers, in particular to a memory recovery method.
Background
At present, cold memory recycling based on user mode pages (pagecache, anon) is realized, the over-selling memory resources can be rescheduled to a new instance, and meanwhile, the increase of idle memory greatly improves the system stability. However, as the user state cold memory is continuously recycled, the amount of the slab memory in the system is increasing, and the slab memory is recycled only when the memory is insufficient. In an on-line cluster, after a period of cold memory is placed, there may be a large amount of slab memory, and most of them are inactive. If the slab memory accumulates for a long time, the stability of the system can be greatly influenced.
The method for recycling the slab memory objects comprises the following steps: all the slab memories are recycled through an interface provided by an operating system for recycling the slab memories, so that the cores can reallocate the slab memories again, the system performance is reduced, and the system stability is influenced.
Disclosure of Invention
In view of this, embodiments of the present disclosure provide a memory reclamation method. One or more embodiments of the present disclosure also relate to a memory recycling apparatus, a computing device, a computer-readable storage medium, and a computer program, so as to solve the technical problems in the prior art.
According to a first aspect of embodiments herein, there is provided a memory reclamation method, including:
scanning a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets the preset memory size;
and determining a first memory object from the target memory objects according to the reference count information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object with a reference count lower than a preset threshold value.
According to a second aspect of the embodiments of the present specification, there is provided a memory recovery apparatus, including:
the data acquisition module is configured to scan a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets a preset memory size;
and the memory recycling module is configured to determine a first memory object from the target memory objects according to the reference count information, and recycle the first memory object meeting a preset recycling condition, wherein the first memory object is a memory object with a reference count lower than a preset threshold.
According to a third aspect of embodiments herein, there is provided a computing device comprising:
a memory and a processor;
the memory is used for storing computer-executable instructions, and the processor is used for executing the computer-executable instructions, and the computer-executable instructions realize the steps of the memory recovery method when being executed by the processor.
According to a fourth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions, which when executed by a processor, implement the steps of the memory reclamation method described above.
According to a fifth aspect of the embodiments of the present specification, there is provided a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the memory recovery method.
An embodiment of the present specification provides a memory recovery method and a device, where the memory recovery method includes: scanning a target memory object to obtain reference count information of the target memory object, wherein the memory size of the target memory object meets a preset memory size, determining a first memory object from the target memory object according to the reference count information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object of which the reference count is lower than a preset threshold value. The method comprises the steps of selecting a target memory object meeting the preset memory size, determining a first memory object from the target memory objects according to the reference count, judging whether the target memory object needs to be recycled according to the preset recycling condition so as to recycle a part of the target memory objects, reducing the performance loss of the system, and improving the stability of the system due to the fact that the target memory object which is used less is selected for recycling.
Drawings
Fig. 1 is a flowchart of a memory reclamation method according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram illustrating a memory reclamation method according to an embodiment of the present disclosure;
fig. 3 is another schematic diagram of a memory reclamation method according to an embodiment of the present disclosure;
fig. 4 is a flowchart illustrating a processing procedure of a memory reclamation method according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a memory recycling device according to an embodiment of the present disclosure;
fig. 6 is a block diagram of a computing device according to an embodiment of the present disclosure.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present specification. This description may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, as those skilled in the art will be able to make and use the present disclosure without departing from the spirit and scope of the present disclosure.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first can also be referred to as a second and, similarly, a second can also be referred to as a first without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
First, the noun terms referred to in one or more embodiments of the present specification are explained.
slab is a memory allocation mechanism in the operating system, and is used for allocating and releasing objects with the size smaller than 4k, such as descriptors of processes, dentry, inode and the like;
kidled: is a thread identified by a kernel-state background cold memory.
Cold memory: refers to objects or pages that have not been accessed for a continuous period of time;
kernel mode page: the memory allocated in the kernel is different from the user mode page, for example: slab memory objects, vmalloc pages, and the like.
A user mode page: refers to the pages allocated by the user's process, which are usually released as the process exits, for example: file pages and anonymous pages.
Thread (English: thread): is the smallest unit that the operating system can perform operation scheduling. It is included in the process and is the actual unit of operation in the process. A thread refers to a single sequential control flow in a process, multiple threads can be concurrently executed in a process, and each thread executes different tasks in parallel.
Reference counting: the memory management technology in computer programming language is a process of storing the referred times of resources (which may be objects, memory or disk space, etc.) and releasing the referenced times when the referred times become zero.
Object (English): is a memory address that holds a value to which the address may point with an identifier.
In the present specification, a memory recycling method is provided, and the present specification relates to a memory recycling apparatus, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments one by one.
Referring to fig. 1, fig. 1 is a flowchart illustrating a memory reclamation method according to an embodiment of the present disclosure, which specifically includes the following steps.
Step 102: scanning a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets the preset memory size.
The target memory object may be understood as a slab memory object in the above noun explanation, for example, the variable b may be referred to as a slab memory object; the reference count information may be the number of times that the target memory object is referred to, for example, if the reference count information of the variable b is 5, it indicates that the variable b is referred to 5 times; the memory size of the target memory object satisfying the preset memory size may be understood as a memory object having a memory size smaller than 4kb (kilobyte).
In practical application, referring to fig. 2, fig. 2 shows a schematic diagram of a memory recovery method provided according to an embodiment of the present disclosure, where a user-mode service includes a database and a remote dictionary parsing service, and in a kernel mode, cold memory identification and cold memory recovery based on a user-mode page (a document page and an anonymous page) are currently implemented, and a over-selling memory resource thereof may be rescheduled to a new instance, and meanwhile, an increase in idle memory greatly improves system stability. However, as the user-mode cold memory is continuously recycled, the number of the slab pages (slab memory) in the system is increasing, and the slab pages (slab memory) are recycled only when the memory is insufficient. The hot and cold identification of the slab memory is now added to the reclamation of the cold slab memory.
Specifically, referring to fig. 3, fig. 3 shows another schematic diagram of a memory recycling method provided according to an embodiment of the present specification, where the original user-state service includes a database and a remote dictionary parsing service, and a cold memory background service is added, and in a kernel state, a lightweight cold-slab memory identification may be implemented according to an existing kidled framework, and a specific slab cache, such as a node cache (incodec), a directory entry cache (dentry caches), a buffer header cache (bufferaadcache), and a radix tree cache (radix tree cache), may be scanned and identified by a kidled thread (memory identification thread). And records the reference count (age) of the memory objects in each cache. Then, the cold memory object is reclaimed based on the memory reclamation thread.
For example, the memory objects in the node caches (inodebaces) are target memory objects, which include a target memory object b and a target memory object a, and reference count information of the target memory object b is 9 and reference count information of the target memory object a is 5.
In the embodiment of the specification, a kidled thread is used for scanning the memory object, so that the resource consumption of the system is reduced, and the performance of the system is improved.
In an implementation manner, the memory object may be scanned at a set time point, and whether recycling is required or not may be determined according to the obtained multiple reference count information for the target memory object. The specific embodiment is as follows.
The scanning the target memory object to obtain the reference count information of the target memory object includes:
and triggering a scanning task of the target memory object at a set time node, and acquiring reference counting information of the target memory object of the set time node.
The set time node may be a time node of a time period or a time node not of a time period, for example, the set time node is a time node of one cycle every 5 seconds, or the set time node may be a time node set at the 3 rd second or a time node set at the 5 th second.
For example, setting the time node as a cycle time node every 5 seconds, triggering a scan task on the target memory object from the time nodes such as 0 second, 5 seconds, 10 seconds … … and the like, which are set from the beginning of setting the time node, for example, triggering the scan on the memory objects in the node cache (inodebaceses) at the 5 th second, where the memory objects include a target memory object b and a target memory object a, and obtaining reference count information of the target memory object b as 9 and reference count information of the target memory object a as 5.
For another example, setting the time node as a time node such as 0 second, 6 seconds, 10 seconds … … from the start of setting the time node triggers the scan task for the target memory object, e.g., triggering the scan task for the memory objects in the node cache (inodaches) at the 5 th second, where the memory objects include a target memory object b and a target memory object a, the reference count information of the target memory object b is obtained as 9, and the reference count information of the target memory object a is obtained as 5.
In the embodiments of the present description, the memory object is scanned and the reference count of the memory object is obtained, so that the cold and hot memory attributes of the memory object can be determined subsequently.
Step 104: and determining a first memory object from the target memory objects according to the reference count information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object with a reference count lower than a preset threshold value.
The first memory object may be a cold slab memory object, that is, a slab memory object whose access frequency is less than a set frequency, for example, if the reference access frequency of the target memory object b is 0, it is determined that the target memory object b is the first memory object; the preset recovery condition may be understood as a condition for recovering the memory object, for example, recovering the cold memory every ten minutes; the preset threshold may be a numerical value such as 10, 5, 0, etc., and the preset threshold is not limited in the embodiments of the present specification.
In practical application, whether the memory object is a cold memory object can be determined according to the reference count information, so that the cold memory object is recycled.
For example, if the preset threshold is 0, including the target memory object b, the target memory object a, and the target memory object c, scanning the target memory object b, the target memory object a, and the target memory object c, and if reference count information of the target memory object b is 9, reference count information of the target memory object a is 5, and reference count information of the target memory object c is 0, it is determined that the target memory object c is the first memory object, that is, the cold memory object, and the cold memory object is recovered according to a preset recovery condition.
In one implementation, the determining a first memory object from the target memory objects based on the reference count information includes:
executing a scanning task at a current set time node to obtain current reference counting information, and determining a target memory object corresponding to the current reference counting information as the first memory object under the condition that the current reference counting information is less than or equal to a preset numerical value.
In practical applications, in the case of scanning memory objects multiple times, cold memory objects need to be determined each time, so as to be recycled in a subsequent step according to a preset recycling condition.
For example, if the preset threshold is 0, including the target memory object b, the target memory object a, and the target memory object c, and the target memory object b, the target memory object a, and the target memory object c are scanned, reference count information of the target memory object b is 9, reference count information of the target memory object a is 5, and reference count information of the target memory object c is 0, it is determined that the target memory object c is the first memory object, that is, the cold memory object.
In an implementation manner, the recycling the first memory object that meets the preset recycling condition includes:
updating a count of the target memory object determined to be the first memory object;
obtaining a recovery threshold value according to the preset recovery condition, and determining whether the count meets the recovery threshold value or not under the condition that the memory object is completely scanned;
and under the condition that the count meets the first memory threshold, recovering the target memory object corresponding to the count.
The count that the target memory object is determined to be the first memory object may be understood as the number of times that the memory object is determined to be the cold memory object, and the first memory threshold is used to determine whether to recycle the memory object, for example, if the count that the memory object a is determined to be the cold memory object is 5 times, and if the count is 6 times, the memory object a is not recycled.
In practical applications, after the memory object is scanned, a determination is made once to determine whether to recycle the cold memory object.
For example, the preset threshold is 0, the first memory threshold is 5, and includes a target memory object b, a target memory object a, and a target memory object c, after the 4 th scan is completed, the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, the target memory object c is determined to be a cold memory object, the number of times that the target memory object c is determined to be a cold memory object is increased by 1, the number of times that the target memory object c is determined to be a cold memory object is 4 times in total, and if the first memory threshold is not met, the target memory object c is not cleared. After the 5 th scan is completed, the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, the target memory object c is determined to be a cold memory object, the number of times that the target memory object c is determined to be a cold memory object is increased by 1, the number of times that the target memory object c is determined to be a cold memory object is 5 times in total, and the target memory object c is cleared if a first memory threshold is met.
In the embodiment of the present specification, when a memory object is recycled, the number of times the memory object is used is considered, so that a cold memory object is recycled, and the influence on the system stability is reduced.
In another implementation, whether to perform memory object reclamation may also be determined based on the size of the cold memory object. The specific implementation is as follows.
The recovering the first memory object meeting the preset recovering condition includes:
and acquiring a memory size threshold according to the preset recovery condition, and recovering the first memory object under the condition that the memory size of the first memory object meets the memory size threshold.
The memory size threshold is a threshold used to determine whether to recycle the cold memory object, for example, if the memory size threshold is 15G (gigabytes), the cold memory object is recycled if the size of the cold memory object is 15G.
In practical application, the cold memory objects can be recycled according to the size of the cold memory objects, so that the slab memory can be conveniently recycled according to the memory resources.
For example, the memory size threshold is 15G, and includes a target memory object b, a target memory object a, and a target memory object c, after the 5 th scan is completed, if the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, then the target memory object c is determined to be a cold memory object, and if the size of the memory space occupied by the target memory object c is 14G, then the target memory object c is not cleared. After the 6 th scan is completed, if the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, the target memory object c is determined to be a cold memory object, the size of the memory space occupied by the target memory object c is 16G, and the memory size threshold is met, the target memory object c is cleared.
In an implementation, processing resources of the system are monitored, and the set time node is adjusted according to the processing resources.
Wherein, the processing resource of the system can be understood as the resource of the processor of the system, for example, the processor utilization rate of the system at this time is 50%; monitoring the processing resources of the system may be understood as acquiring the usage of the processors of the system at intervals, for example, acquiring the usage of the processors at intervals of 0.5 seconds.
In practical application, the scanning time interval of the memory object is adjusted according to the processing resource of the system, the scanning times of the memory object are increased under the condition that the processing resource of the system is sufficient, and the scanning times of the memory object are correspondingly reduced under the condition that the processing resource of the system is tense. The specific embodiment is as follows.
In one implementation, the adjusting the set time node based on the system processing resources includes:
reducing the adjacent scanning interval under the condition that the processing resource is larger than a preset resource threshold;
or, under the condition that the processing resource is smaller than a preset resource threshold, increasing the adjacent scanning interval.
The adjacent scanning interval may be understood as a time interval between two times of scanning the memory object, for example, if the first time of scanning the memory object and the second time of scanning the memory object are separated by 4 seconds, the adjacent scanning interval is 4 seconds.
For example, the preset resource threshold is 70%, and when the processor usage rate of the system is 50%, the adjacent scanning interval is decreased, and the adjacent scanning interval is decreased from 5 seconds to 4 seconds, and when the processor usage rate of the system is 80%, the adjacent scanning interval is increased, and the adjacent scanning interval is increased from 4 seconds to 5 seconds.
It should be noted that, preset resource threshold values may be set for the case of decreasing the adjacent scanning interval and the case of increasing the adjacent scanning interval, respectively, a first preset resource threshold value is set for the case of decreasing the adjacent scanning interval, and a second preset resource threshold value is set for the case of increasing the adjacent scanning interval, that is, in a normal case, the adjacent scanning interval may not be increased and the adjacent scanning interval may not be decreased. In the case of being smaller than the first preset threshold, the adjacent scanning interval may be reduced to increase the number of times of scanning the memory object, making full use of the processing resources of the system. And under the condition that the scanning frequency is larger than the second preset threshold value, the adjacent scanning interval can be increased to reduce the scanning frequency of the memory object, and the processing resource of the system is relieved.
For example, a first preset resource threshold is set for a case of decreasing the adjacent scanning interval, a second preset resource threshold is set for a case of increasing the adjacent scanning interval, where the first preset resource threshold is 50%, the second preset resource threshold is 80%, the utilization rate of the processor of the system is obtained every 0.5 second, the original adjacent scanning interval is increased to 8 seconds when the utilization rate of the processor of the system exceeds 80%, the adjacent scanning interval is decreased to 4 seconds when the utilization rate of the processor of the system is less than 50%, and the adjacent scanning interval is adjusted to 6 seconds when the utilization rate of the processor of the system is 80% to 50%.
In one implementation, the first memory object is reclaimed in response to a memory reclaim instruction.
The memory recovery instruction is an instruction for recovering a memory object.
In practical application, the memory objects can be automatically recycled, and can also be manually recycled.
For example, the preset threshold is 0, the first memory threshold is 5, and includes a target memory object b, a target memory object a, and a target memory object c, after the 4 th scan is completed, the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, the target memory object c is determined to be a cold memory object, the number of times that the target memory object c is determined to be a cold memory object is increased by 1, the number of times that the target memory object c is determined to be a cold memory object is 4 times in total, and if the first memory threshold is not met, the target memory object c is not cleared. However, when the memory reclamation instruction is received, all the cold memory objects are reclaimed, that is, the target memory object c is reclaimed.
Furthermore, not only can the cold memory objects be recycled, but also the memory objects in a specified cache can be recycled. The specific embodiment is as follows.
The recycling the first memory object includes:
determining a memory object to be recovered from the first memory object according to a memory object identifier carried in the memory recovery instruction;
and recovering the memory objects to be recovered.
The memory object identifier may be a name of the cache, or may be an identifier of the memory object, for example, node caches (incobecaces) or the memory object b.
For example, when a memory recycle instruction is received, a memory object identifier is obtained from the memory recycle instruction, where the memory object identifier is a node cache, that is, a memory object in the node cache is recycled.
It should be noted that, the memory objects in the node cache are recycled, the cold memory objects therein may be recycled, or all the memory objects therein may be recycled. The examples in this specification are not intended to be limiting. When the memory object identifier is an identifier of a memory object, the memory object in all caches may be recovered, or the memory object in a certain cache may be recovered.
An embodiment of the present specification provides a memory recovery method and a device, where the memory recovery method includes: scanning a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets a preset memory size, determining a first memory object from the target memory object according to the reference counting information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object with reference counting lower than a preset threshold value. The method comprises the steps of selecting a target memory object meeting the preset memory size, determining a first memory object from the target memory objects according to the reference count, judging whether the target memory object needs to be recycled according to the preset recycling condition so as to recycle a part of the target memory objects, reducing the performance loss of the system, and improving the stability of the system due to the fact that the target memory object which is used less is selected for recycling.
The following will further describe the memory recovery method by taking an application of the memory recovery method provided in this specification to a server as an example with reference to fig. 4. Fig. 4 shows a flowchart of a processing procedure of a memory reclamation method according to an embodiment of the present disclosure, which specifically includes the following steps.
Step 402: and the server triggers a scanning task of the target memory object at a set time node, and acquires reference counting information of the target memory object of the set time node.
The set time node may be a time node of a time period or a time node not of the time period, for example, the set time node is a cycle time node every 5 seconds, or a time node set in the 3 rd second and a time node set in the 5 th second; the target memory object may be understood as a slab memory object in the above noun explanation, for example, the variable b may be referred to as a slab memory object; the reference count information may be the number of times that the target memory object is referred to, for example, if the reference count information of the variable b is 5, it indicates that the variable b is referred to 5 times; the memory size of the target memory object satisfying the preset memory size may be understood as a memory object having a memory size smaller than 4kb (kilobyte).
For example, setting the time node as a cycle time node every 5 seconds, triggering a scan task on the target memory object from the time nodes such as 0 second, 5 seconds, 10 seconds … … and the like, which are set from the beginning of setting the time node, for example, triggering the scan on the memory objects in the node cache (inodebaceses) at the 5 th second, where the memory objects include a target memory object b and a target memory object a, and obtaining reference count information of the target memory object b as 9 and reference count information of the target memory object a as 5.
Step 404: the server executes a scanning task at a current set time node to obtain current reference counting information, and determines a target memory object corresponding to the current reference counting information as the first memory object when the current reference counting information is less than or equal to a preset value.
The first memory object may be a cold slab memory object, that is, a slab memory object whose access frequency is less than a set frequency, for example, if the reference access frequency of the target memory object b is 0, it is determined that the target memory object b is the first memory object; the preset recycling condition may be understood as a condition for recycling the memory object, for example, recycling the cold memory every ten minutes; the preset threshold may be a numerical value such as 10, 5, 0, etc., and the preset threshold is not limited in the embodiments of the present specification.
In practical applications, in the case of scanning memory objects for multiple times, it is necessary to determine cold memory objects each time, so as to recycle the cold memory objects according to preset recycling conditions in the following steps.
Along the above example, the preset threshold is 0, and includes a target memory object b, a target memory object a, and a target memory object c, and the target memory object b, the target memory object a, and the target memory object c are scanned, so that reference count information of the target memory object b is 9, reference count information of the target memory object a is 5, and reference count information of the target memory object c is 0, and it is determined that the target memory object c is the first memory object, that is, the cold memory object.
Step 406: the server updates a count of the target memory object determined to be the first memory object.
Following the above example, after the 4 th scan is completed, the reference count for target memory object a is 6, the reference count for target memory object b is 1, and the reference count for target memory object c is 0, then target memory object c is determined to be a cold memory object, and the number of times target memory object c is determined to be a cold memory object is increased by 1.
Step 408: and the server obtains a recovery threshold value according to the preset recovery condition, and determines whether the count meets the recovery threshold value or not under the condition that the memory object is completely scanned.
Following the above example, the number of times the target memory object c is determined to be a cold memory object is 4 in total, and if the first memory threshold is not met, the target memory object c is not cleared. After the 5 th scan is completed, the reference count of the target memory object a is 6, the reference count of the target memory object b is 1, and the reference count of the target memory object c is 0, the target memory object c is determined to be a cold memory object, and the number of times that the target memory object c is determined to be a cold memory object is increased by 1, the number of times that the target memory object c is determined to be a cold memory object is 5 times in total, and the first memory threshold is satisfied.
Step 410: and the server recovers the target memory object corresponding to the count under the condition that the count meets the first memory threshold value.
Following the above example, the target memory object c is determined to be a cold memory object a total of 5 times, and if the first memory threshold is met, the target memory object c is cleared.
In the embodiment of the present description, a target memory object that meets a preset memory size is selected, a first memory object is determined from the target memory objects according to a reference count, and whether the target memory object needs to be recycled is determined according to a preset recycling condition, so as to recycle a part of the target memory objects, thereby reducing performance loss of the system.
Corresponding to the foregoing method embodiment, this specification further provides an embodiment of a memory recovery device, and fig. 3 illustrates a schematic structural diagram of a memory recovery device provided in an embodiment of this specification. As shown in fig. 3, the apparatus includes:
a data obtaining module 502 configured to scan a target memory object to obtain reference count information of the target memory object, where a memory size of the target memory object satisfies a preset memory size;
the memory recycling module 504 is configured to determine a first memory object from the target memory objects according to the reference count information, and recycle the first memory object meeting a preset recycling condition, where the first memory object is a memory object whose reference count is lower than a preset threshold.
Further, the data obtaining module 502 is further configured to:
and triggering a scanning task of the target memory object at a set time node, and acquiring reference counting information of the target memory object of the set time node.
Further, the memory reclamation module 504 is further configured to:
executing a scanning task at a current set time node to obtain current reference counting information, and determining a target memory object corresponding to the current reference counting information as the first memory object under the condition that the current reference counting information is less than or equal to a preset value.
Further, the memory reclamation module 504 is further configured to:
updating a count of the target memory object determined to be the first memory object;
obtaining a recovery threshold value according to the preset recovery condition, and determining whether the count meets the recovery threshold value or not under the condition that the memory object is completely scanned;
and under the condition that the count meets the first memory threshold, recovering the target memory object corresponding to the count.
Further, the memory reclamation module 504 is further configured to:
and acquiring a memory size threshold according to the preset recovery condition, and recovering the first memory object under the condition that the memory size of the first memory object meets the memory size threshold.
Further, the memory reclamation module 504 is further configured to:
and monitoring the processing resources of the system, and adjusting the set time node according to the processing resources.
Further, the memory reclamation module 504 is further configured to:
reducing the adjacent scanning interval under the condition that the processing resource is larger than a preset resource threshold;
or, under the condition that the processing resource is smaller than a preset resource threshold, increasing the adjacent scanning interval.
Further, the memory reclamation module 504 is further configured to:
and responding to a memory recovery instruction, and recovering the first memory object.
Further, the memory reclamation module 504 is further configured to:
determining a memory object to be recovered from the first memory object according to a memory object identifier carried in the memory recovery instruction;
and recovering the memory object to be recovered.
An embodiment of the present specification provides a memory recovery device, where the memory recovery device scans a target memory object to obtain reference count information of the target memory object, where a memory size of the target memory object satisfies a preset memory size, determines a first memory object from the target memory object according to the reference count information, and recovers the first memory object satisfying a preset recovery condition, where the first memory object is a memory object whose reference count is lower than a preset threshold. The method comprises the steps of selecting a target memory object meeting the preset memory size, determining a first memory object from the target memory objects according to the reference count, judging whether the target memory object needs to be recycled according to the preset recycling condition so as to recycle a part of the target memory objects, reducing the performance loss of the system, and improving the stability of the system due to the fact that the target memory object which is used less is selected for recycling.
The foregoing is a schematic solution of the memory recycling apparatus in this embodiment. It should be noted that the technical solution of the memory recovery apparatus and the technical solution of the memory recovery method belong to the same concept, and details of the technical solution of the memory recovery apparatus, which are not described in detail, can be referred to the description of the technical solution of the memory recovery method.
FIG. 6 illustrates a block diagram of a computing device 600 provided in accordance with one embodiment of the present specification. The components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is coupled to the memory 610 via a bus 630 and a database 650 is used to store data.
Computing device 600 also includes access device 640, access device 640 enabling computing device 600 to communicate via one or more networks 660. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 640 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the above-described components of computing device 600, as well as other components not shown in FIG. 6, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 6 is for purposes of example only and is not limiting as to the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smartphone), wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 600 may also be a mobile or stationary server.
The processor 620 is configured to execute computer-executable instructions, and when executed by the processor, the computer-executable instructions implement the steps of the memory reclamation method.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the memory recovery method belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the memory recovery method.
An embodiment of the present specification further provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the memory reclamation method are implemented.
The above is an illustrative scheme of a computer-readable storage medium of the embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the memory recovery method belong to the same concept, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the memory recovery method.
An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the memory recovery method.
The above is an illustrative scheme of a computer program of the present embodiment. It should be noted that the technical solution of the computer program and the technical solution of the memory recovery method belong to the same concept, and details that are not described in detail in the technical solution of the computer program can be referred to the description of the technical solution of the memory recovery method.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer-readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
It should be noted that, for the sake of simplicity, the foregoing method embodiments are described as a series of combinations of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the embodiments. Further, those skilled in the art should also appreciate that the embodiments described in this specification are preferred embodiments and that acts and modules referred to are not necessarily required for an embodiment of the specification.
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.
The preferred embodiments of the present specification disclosed above are intended only to aid in the description of the specification. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, and to thereby enable others skilled in the art to best understand the specification and utilize the specification. The specification is limited only by the claims and their full scope and equivalents.

Claims (12)

1. A memory reclamation method, comprising:
scanning a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets the preset memory size;
and determining a first memory object from the target memory objects according to the reference count information, and recovering the first memory object meeting a preset recovery condition, wherein the first memory object is a memory object with a reference count lower than a preset threshold value.
2. The method of claim 1, wherein scanning the target memory object to obtain reference count information of the target memory object comprises:
and triggering a scanning task of the target memory object at a set time node, and acquiring reference counting information of the target memory object of the set time node.
3. The method of claim 2, the determining a first memory object from the target memory objects based on the reference count information, comprising:
executing a scanning task at a current set time node to obtain current reference counting information, and determining a target memory object corresponding to the current reference counting information as the first memory object under the condition that the current reference counting information is less than or equal to a preset value.
4. The method according to claim 3, wherein the recovering the first memory object satisfying the preset recovering condition comprises:
updating a count of the target memory object determined to be the first memory object;
obtaining a recovery threshold according to the preset recovery condition, and determining whether the count meets the recovery threshold or not under the condition that the memory object is completely scanned;
and under the condition that the count meets the first memory threshold, recovering the target memory object corresponding to the count.
5. The method according to claim 1, wherein the recovering the first memory object satisfying a preset recovery condition comprises:
and acquiring a memory size threshold according to the preset recovery condition, and recovering the first memory object under the condition that the memory size of the first memory object meets the memory size threshold.
6. The method of claim 2, further comprising:
and monitoring the processing resources of the system, and adjusting the set time node according to the processing resources.
7. The method of claim 6, the adjusting the set time node according to the processing resources, comprising:
reducing the adjacent scanning interval under the condition that the processing resource is larger than a preset resource threshold;
or, under the condition that the processing resource is smaller than a preset resource threshold, increasing the adjacent scanning interval.
8. The method of claim 1, further comprising:
and responding to a memory recovery instruction, and recovering the first memory object.
9. The method of claim 8, wherein the reclaiming the first memory object comprises:
determining a memory object to be recovered from the first memory object according to a memory object identifier carried in the memory recovery instruction;
and recovering the memory object to be recovered.
10. A memory reclamation apparatus comprising:
the data acquisition module is configured to scan a target memory object to obtain reference counting information of the target memory object, wherein the memory size of the target memory object meets a preset memory size;
and the memory recycling module is configured to determine a first memory object from the target memory objects according to the reference count information, and recycle the first memory object meeting a preset recycling condition, wherein the first memory object is a memory object with a reference count lower than a preset threshold.
11. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions and the processor is configured to execute the computer-executable instructions, which when executed by the processor, implement the steps of the memory reclamation method of any of claims 1 to 9.
12. A computer readable storage medium storing computer executable instructions which, when executed by a processor, carry out the steps of the memory reclamation method as claimed in any one of claims 1 to 9.
CN202210429570.7A 2022-04-22 2022-04-22 Memory recovery method and device Pending CN114995993A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210429570.7A CN114995993A (en) 2022-04-22 2022-04-22 Memory recovery method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210429570.7A CN114995993A (en) 2022-04-22 2022-04-22 Memory recovery method and device

Publications (1)

Publication Number Publication Date
CN114995993A true CN114995993A (en) 2022-09-02

Family

ID=83025224

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210429570.7A Pending CN114995993A (en) 2022-04-22 2022-04-22 Memory recovery method and device

Country Status (1)

Country Link
CN (1) CN114995993A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107925A (en) * 2023-04-10 2023-05-12 阿里云计算有限公司 Data storage unit processing method
CN117093408A (en) * 2023-10-20 2023-11-21 恒生电子股份有限公司 Data processing method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107925A (en) * 2023-04-10 2023-05-12 阿里云计算有限公司 Data storage unit processing method
CN116107925B (en) * 2023-04-10 2023-09-26 阿里云计算有限公司 Data storage unit processing method
CN117093408A (en) * 2023-10-20 2023-11-21 恒生电子股份有限公司 Data processing method and device
CN117093408B (en) * 2023-10-20 2024-01-23 恒生电子股份有限公司 Data processing method and device

Similar Documents

Publication Publication Date Title
US11531625B2 (en) Memory management method and apparatus
CN114995993A (en) Memory recovery method and device
CN110321448B (en) Image retrieval method, device and storage medium
CN111381902B (en) APP starting acceleration method based on embedded heterogeneous network with attributes
EP3822795B1 (en) Data storage and acquisition method and device
CN114661248B (en) Data processing method and device
EP4369191A1 (en) Memory scanning method and apparatus
CN114416310A (en) Multiprocessor load balancing method, computing device and storage medium
CN106570153A (en) Data extraction method and system for mass URLs
CN111949389A (en) Slurm-based information acquisition method and device, server and computer-readable storage medium
US20200242467A1 (en) Calculation method and calculation device for sparse neural network, electronic device, computer readable storage medium, and computer program product
CN116107925B (en) Data storage unit processing method
CN112783656B (en) Memory management method, medium, device and computing equipment
US20190266191A1 (en) Graph partitioning method and apparatus
CN113873025B (en) Data processing method and device, storage medium and electronic equipment
EP4357916A1 (en) Job processing method and apparatus, computer device, and storage medium
CN114168589A (en) Index construction method and device
CN113849550A (en) Data processing method and device
CN114510332A (en) Method for processing large file by using thread, processing device and computing equipment
CN113901077A (en) Method and system for producing entity object label, storage medium and electronic equipment
CN112835932A (en) Batch processing method and device of service table and nonvolatile storage medium
US12032578B1 (en) Data compression, store, and search system
US20210365416A1 (en) Mount parameter in file systems
CN115759233B (en) Model training method, graph data processing device and electronic equipment
CN116541482A (en) Text object indexing method, object storage system and related equipment

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