CN113176958A - Memory sharing method, device, equipment and storage medium - Google Patents

Memory sharing method, device, equipment and storage medium Download PDF

Info

Publication number
CN113176958A
CN113176958A CN202110476028.2A CN202110476028A CN113176958A CN 113176958 A CN113176958 A CN 113176958A CN 202110476028 A CN202110476028 A CN 202110476028A CN 113176958 A CN113176958 A CN 113176958A
Authority
CN
China
Prior art keywords
memory
area
sharing
memory sharing
frequency
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.)
Granted
Application number
CN202110476028.2A
Other languages
Chinese (zh)
Other versions
CN113176958B (en
Inventor
薛飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies 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 Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202110476028.2A priority Critical patent/CN113176958B/en
Publication of CN113176958A publication Critical patent/CN113176958A/en
Application granted granted Critical
Publication of CN113176958B publication Critical patent/CN113176958B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • 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

Abstract

The application discloses a memory sharing method, a device, equipment and a storage medium, wherein the method comprises the following steps: collecting memory access data of an application program; determining a memory sharing area meeting a preset standard in a memory according to memory access data; the preset standard at least comprises that the read-write type of the memory page is a read-only type; scanning target memory pages with the same data content in the memory sharing area; and merging the target memory pages. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured. In addition, the application also provides a memory sharing device, equipment and a storage medium, and the beneficial effects are as described above.

Description

Memory sharing method, device, equipment and storage medium
Technical Field
The present application relates to the field of cloud computing, and in particular, to a memory sharing method, apparatus, device, and storage medium.
Background
A certain number of application programs are often operated in server equipment in a current cloud computing scenario, and the operation of the application programs often needs to occupy memory resources of the server equipment to a certain extent.
In a high-load operation scene, a plurality of application programs compete with each other for memory resources in the server device, which may result in insufficient idle memory resources in the server device, and further data generated during the operation of the application programs cannot be cached, which results in reduced system performance and difficulty in ensuring the stability of the operation of the application programs in the server device.
Therefore, it is a problem to be solved by those skilled in the art to provide a memory sharing method to relatively ensure the stability of the application program running in the server device.
Disclosure of Invention
The application aims to provide a memory sharing method, a memory sharing device, memory sharing equipment and a memory medium, so as to relatively ensure the running stability of an application program in server equipment.
To solve the above technical problem, the present application provides a memory sharing method, including:
collecting memory access data of an application program;
determining a memory sharing area meeting a preset standard in a memory according to memory access data; the preset standard at least comprises that the read-write type of the memory page is a read-only type;
scanning target memory pages with the same data content in the memory sharing area;
and merging the target memory pages.
Preferably, the scanning of the target memory pages with the same data content in the memory sharing area includes:
and scanning the target memory pages with the same data content in the memory sharing area according to a preset scanning frequency.
Preferably, before scanning the target memory pages with the same data content in the memory sharing area according to the preset scanning frequency, the method further includes:
acquiring the occupation amount of computing resources;
and determining a preset scanning frequency according to the occupation amount of the operation resources.
Preferably, the determining the preset scanning frequency according to the occupation amount of the computing resources comprises:
adjusting the preset scanning frequency in real time according to the occupation amount of the operation resources; wherein, the occupation amount of the computing resources has negative correlation with the preset scanning frequency.
Preferably, the preset criterion further comprises that the writing frequency of the memory pages is lower than the preset writing frequency.
Preferably, after determining the memory sharing area meeting the preset criterion in the memory according to the memory access data, the method further includes:
determining a target memory area in which the write-in frequency of the memory page reaches a preset write-in frequency in the memory sharing area;
and removing the target memory area in the memory sharing area so as to merge the target memory pages based on the updated memory sharing area.
Preferably, after merging the target memory page, the method further includes:
determining a target memory area with the merging frequency of the memory pages lower than a preset merging frequency in the memory sharing area;
and removing the target memory area in the memory sharing area so as to merge the target memory pages based on the updated memory sharing area.
In addition, the present application also provides a memory sharing device, including:
the access collection module is used for collecting the memory access data of the application program;
the shared area determining module is used for determining a memory shared area meeting a preset standard in a memory according to the memory access data; the preset standard at least comprises that the read-write type of the memory page is a read-only type;
the memory page scanning module is used for scanning target memory pages with the same data content in the memory sharing area;
and the memory page merging module is used for merging the target memory pages.
In addition, the present application also provides a memory sharing device, including:
a memory for storing a computer program;
the processor is configured to implement the steps of the memory sharing method when executing the computer program.
In addition, the present application also provides a computer readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the memory sharing method as described above.
The memory sharing method includes the steps of firstly collecting memory access data of an application program, then determining a memory sharing area meeting preset standards in a memory according to the memory access data, wherein the preset standards at least include that the read-write type of memory pages is a read-only type, further scanning target memory pages with the same data content in the memory sharing area on the basis, and then merging the target memory pages. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured. In addition, the application also provides a memory sharing device, equipment and a storage medium, and the beneficial effects are as described above.
Drawings
In order to more clearly illustrate the embodiments of the present application, the drawings needed for the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a schematic view of an application scenario of memory sharing in a cloud computing system disclosed in an embodiment of the present application;
fig. 2 is a flowchart of a memory sharing method disclosed in the present application;
fig. 3 is a flowchart of a memory sharing method disclosed in the present application;
fig. 4 is a flowchart of a memory sharing method disclosed in the present application;
fig. 5 is a flowchart of a memory sharing method disclosed in the present application;
fig. 6 is a flowchart of a memory sharing method disclosed in the present embodiment;
fig. 7 is a schematic flow chart illustrating memory sharing in a scenario embodiment disclosed in the present application;
fig. 8 is a schematic structural diagram of a memory sharing device according to an embodiment of the present disclosure;
fig. 9 is a schematic diagram of a hardware structure of a memory sharing device according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the present application.
In a high-load operation scene, a plurality of application programs compete with each other for memory resources in the server device, which may result in insufficient idle memory resources in the server device, and further data generated during the operation of the application programs cannot be cached, which results in reduced system performance and difficulty in ensuring the stability of the operation of the application programs in the server device.
Therefore, the core of the application is to provide a memory sharing method to relatively ensure the stability of the operation of the application program in the server device.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings.
The scene suitable for the technical scheme of the application includes but is not limited to a cloud computing system scene or a common network scene and the like. Taking a cloud computing system as an example, the cloud computing system is composed of physical server devices, and a cloud computing cluster is formed by running a plurality of application programs (such as virtual machine programs) in the server devices, so that the server devices are formed into cloud computing devices with a cloud computing function, and one or more cloud computing devices may further form the cloud computing system. In the above scenario, the execution subject of the technical scheme of the application is the server device constituting the cloud computing system, and the server device combines the memory pages stored in the memory by the application program, so as to reduce the memory occupation degree of the application program on the server device.
Fig. 1 is a schematic view of an application scenario of memory sharing in a cloud computing system according to an embodiment of the present application, where in fig. 1, a cloud computing system formed by three server devices is taken as an example, and operations of each server device for memory sharing are similar. In fig. 1, for example, one server device includes 3 application processes, which are an application process 1, an application process 2, and an application process 3. The application process 1 uses the memory area 1, the memory area 2 and the memory area 3, the application process 2 uses the memory area 2, the memory area 3 and the memory area 4, and the application process 3 uses the memory area 2, the memory area 3, the memory area 4 and the memory area 5. At this time, the memory areas commonly used by the application process 1, the application process 2, and the application process 3 are the memory area 2 and the memory area 3.
Assuming that the application program 1, the application process 2, and the application process 3 have a high writing frequency to the memory area 2, and the application program 1, the application process 2, and the application process 3 perform a read-only operation on the memory area 3, at this time, the memory area 3 may be used as a memory sharing area of the application program 1, the application process 2, and the application process 3. The memory area 3 includes M memory pages, and it is assumed that the first N memory pages are memory pages with the same content (N is an integer greater than or equal to 2 and less than or equal to M). For the sake of distinction, the memory pages with the same content may be referred to as target memory pages. At this time, only 1 target memory page can be reserved for storage, and further, the occupation of the memory space by the N-1 target memory pages is reduced, so that the memory resources are saved, and the occurrence of insufficient memory resources is reduced.
As shown in fig. 2, an embodiment of the present application discloses a memory sharing method, including:
step S20: and collecting memory access data of the application program.
The application in this step refers to a program having a specific function loaded or run in the server apparatus. Since the application program generates data such as variable parameters or code compiling parameters when the application program is loaded or run in the server device to support normal operation of the application program, the application program needs to store the data in the memory in the form of a memory page.
In this step, the memory access data of the application program is collected, and according to different scenes, the memory access data of a plurality of application programs may be collected, or the memory access data of one application degree may be accessed, which is not specifically limited herein.
In addition, the memory access data in this step refers to access parameters of the application program to the memory of the server device, and the read-write behavior of the application program to the memory, the read-write permission of the memory page stored in the memory, and the like can be obtained through the memory access data, so that the purpose is to select a specific memory area to perform the combination of the same memory page in the subsequent steps.
Step S21: and determining a memory sharing area meeting a preset standard in the memory according to the memory access data.
The preset standard at least comprises that the read-write type of the memory page is a read-only type.
After the memory access data of the application program is collected, the step further determines a memory sharing area meeting a preset standard in the memory according to the memory access data, where the preset standard at least includes that the read-write type of the memory page is a read-only type, that is, the step at least selects the memory area with the read-write type of the memory page being the read-only type as the memory sharing area in the memory according to the memory access data. The memory sharing region is essentially a specific address interval in the memory, memory pages stored in the address interval and in the address interval are considered to be in the memory sharing region, and the purpose of determining the memory sharing region is to merge memory pages with the same content in the memory sharing region in the subsequent steps.
It should be noted that, because the content of the memory page whose read-write type is the read-only type is not changed in the process of running the application program, after the same memory pages of the read-only type are merged, a new memory page does not need to be copied to record changed data, and memory usage can be reduced to the greatest extent.
In addition, it is emphasized that, when memory sharing is implemented only for a certain specific application program, a memory sharing area meeting a preset standard is determined in a memory according to memory access data, specifically, the memory sharing area meeting the preset standard is determined in a memory area occupied by the specific application program; when memory sharing is realized among a plurality of application programs, a memory sharing area meeting a preset standard is determined in a memory according to memory access data, specifically, the memory sharing area meeting the preset standard is determined in a memory area commonly occupied by the corresponding application programs.
Step S22: and scanning target memory pages with the same data content in the memory sharing area.
Step S23: and merging the target memory pages.
After determining a memory sharing area meeting a preset standard in a memory according to memory access data, in this embodiment, target memory pages with the same data content in the memory sharing area are further scanned and merged, so as to store N (N is an integer greater than or equal to 2) target memory pages with the same content in the memory sharing area as 1 target memory page, thereby reducing the memory space occupied by N-1 target memory pages.
In addition, in this embodiment, it may be specifically configured to scan target memory pages with the same data content in the memory sharing area through a KSM (Kernel page sharing) mechanism, and merge the target memory pages, so as to relatively ensure reliability of memory sharing.
The memory sharing method includes the steps of firstly collecting memory access data of an application program, then determining a memory sharing area meeting preset standards in a memory according to the memory access data, wherein the preset standards at least include that the read-write type of memory pages is a read-only type, further scanning target memory pages with the same data content in the memory sharing area on the basis, and then merging the target memory pages. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured.
On the basis of the foregoing embodiment, as a preferred implementation manner, the preset criterion further includes that the writing frequency of the memory page is lower than a preset writing frequency.
It should be noted that, in this embodiment, when determining, according to the memory access data, a memory sharing area that meets the preset standard in the memory, specifically, a memory area in which the read-write type of the memory page in the memory is the read-only type is used as the memory sharing area, and a memory area in which the write frequency of the memory page in the memory is lower than the preset write frequency is used as the memory sharing area. The preset write frequency is a frequency standard for defining whether the memory page modification frequency is at a lower level, and is determined according to actual requirements.
Considering that the frequency of sending data to the memory page with the writing frequency lower than the preset writing frequency is low and is similar to a read-only memory page, the embodiment further uses the memory area where the memory page with the low modification frequency is located as the memory sharing area, so as to further improve the range of the memory sharing area, further increase the amount of memory resources saved in the process of merging the memory pages, further avoid the occurrence of insufficient memory resources, and further relatively ensure the stability of the operation of the application program in the server device.
As shown in fig. 3, an embodiment of the present application discloses a memory sharing method, including:
step S30: and collecting memory access data of the application program.
Step S31: and determining a memory sharing area meeting a preset standard in the memory according to the memory access data.
The preset standard comprises that the read-write type of the memory page is a read-only type, or the write frequency of the memory page is lower than the preset write frequency.
Step S32: and scanning target memory pages with the same data content in the memory sharing area.
Step S33: and merging the target memory pages.
Step S34: and determining a target memory area in which the write-in frequency of the memory page reaches a preset write-in frequency in the memory sharing area.
Step S35: and removing the target memory area in the memory sharing area so as to merge the target memory pages based on the updated memory sharing area.
It should be noted that, in consideration of that after a memory area in which the write frequency of a memory page in the memory is lower than the preset write frequency is taken as a memory shared area, the write frequency of the corresponding memory page may change according to an actual situation, the present embodiment is mainly characterized in that after the memory shared area meeting the preset standard is determined in the memory according to the memory access data, the memory shared area is adjusted according to the write frequency of the memory page in the memory shared area, that is, a target memory area in which the write frequency of the memory page reaches the preset write frequency is determined in the memory shared area, and the target memory area in the memory shared area is removed, so as to ensure that the memory page in the memory shared area is always lower than the preset write frequency, and then the target memory page is merged based on the updated memory shared area. After the target memory area is determined, a dynamic feedback mechanism is further provided in this embodiment, and the target memory area is dynamically adjusted based on the write frequency fed back by the memory page in the target memory area, so that the accuracy of the target memory area is further ensured.
As shown in fig. 4, an embodiment of the present application discloses a memory sharing method, including:
step S40: and collecting memory access data of the application program.
Step S41: and determining a memory sharing area meeting a preset standard in the memory according to the memory access data.
The preset standard at least comprises that the read-write type of the memory page is a read-only type.
Step S42: and scanning the target memory pages with the same data content in the memory sharing area according to a preset scanning frequency.
Step S43: and merging the target memory pages.
It should be noted that, in the present embodiment, the memory sharing area is scanned according to a preset scanning frequency, that is, after the memory sharing area is determined, the memory sharing area is scanned at a specific time interval, where the scanning of the memory sharing area is essentially to traverse memory pages in the memory sharing area. Because the operation resources of the server equipment need to be occupied when the memory shared area is scanned every time, the memory shared area is scanned every certain time interval, so that the continuous occupation of the operation resources in the server equipment can be relatively avoided, and the overall stability of the server equipment can be further ensured.
On the basis of the foregoing embodiment, as a preferred implementation manner, before scanning, according to a preset scanning frequency, target memory pages in the memory sharing area, which have the same data content, the method further includes:
acquiring the occupation amount of computing resources;
and determining a preset scanning frequency according to the occupation amount of the operation resources.
It should be noted that, the important point of the present embodiment is to determine the preset scanning frequency, that is, to obtain the occupied amount of the operation resource, before scanning the target memory pages with the same data content in the memory sharing area according to the preset scanning frequency, and then determine the preset scanning frequency according to the occupied amount of the operation resource. The operation resource occupation referred to herein includes, but is not limited to, the operation resource load of a Central Processing Unit (CPU). The preset scanning frequency is determined according to the occupation amount of the operation resources, namely the preset scanning frequency is changed according to the change of the load amount of the operation resources, so that the controllability of the preset scanning frequency can be relatively ensured, and the flexibility of scanning the target memory pages in the memory sharing area is further ensured.
As shown in fig. 5, an embodiment of the present application discloses a memory sharing method, including:
step S50: and collecting memory access data of the application program.
Step S51: and determining a memory sharing area meeting a preset standard in the memory according to the memory access data.
The preset standard at least comprises that the read-write type of the memory page is a read-only type.
Step S52: and acquiring the occupation amount of the operation resources.
Step S53: and adjusting the preset scanning frequency in real time according to the occupation amount of the operation resources.
Wherein, the occupation amount of the computing resources has negative correlation with the preset scanning frequency.
It should be noted that, in this embodiment, before scanning a target memory page with the same data content in a memory sharing area according to a preset scanning frequency, first acquiring an occupied amount of an operation resource, and further adjusting the preset scanning frequency in real time according to the occupied amount of the operation resource on the basis, where there is a negative correlation between the occupied amount of the operation resource and the preset scanning frequency, that is, when the occupied amount of the operation resource is increased compared with a previous time, the preset scanning frequency is correspondingly decreased, so as to reduce consumption of the operation resource by the scanning operation; when the occupation amount of the operation resources is reduced compared with the previous time, the preset scanning frequency is correspondingly increased, so that the frequency of scanning operation is improved, the memory sharing efficiency is increased, and the preset scanning frequency is further ensured.
Step S54: and scanning the target memory pages with the same data content in the memory sharing area according to a preset scanning frequency.
Step S55: and merging the target memory pages.
The embodiment further ensures the accuracy of adjusting and determining the preset scanning frequency in real time according to the occupation amount of the operation resources, thereby further ensuring the operation stability of the server equipment while ensuring the flexibility of scanning the target memory pages in the memory sharing area.
As shown in fig. 6, an embodiment of the present application discloses a memory sharing method, including:
step S60: and collecting memory access data of the application program.
Step S61: and determining a memory sharing area meeting a preset standard in the memory according to the memory access data.
The preset standard at least comprises that the read-write type of the memory page is a read-only type.
Step S62: and scanning target memory pages with the same data content in the memory sharing area.
Step S63: and merging the target memory pages.
Step S64: and determining a target memory area with the merging frequency of the memory pages lower than the preset merging frequency in the memory sharing area.
Step S65: and removing the target memory area in the memory sharing area so as to merge the target memory pages based on the updated memory sharing area.
It should be noted that, considering that when the merging frequency of a certain memory page in the memory sharing area is lower than the preset merging frequency, the repetition frequency of the memory page in the memory sharing area is relatively low, and the memory page merging often cannot be performed to achieve the memory sharing effect, but the process of scanning the memory page needs to occupy a certain operation resource, in this embodiment, after the target memory pages are merged, a dynamic feedback mechanism is further provided, according to the merging frequency fed back by the memory pages, the target memory area in which the merging frequency of the memory pages is lower than the preset merging frequency is statistically determined in the memory sharing area, and the target memory area in the memory sharing area is removed, so as to merge the target pages based on the updated memory sharing area, relatively ensuring the accuracy of the memory sharing area, and avoiding the process resource waste of scanning the memory sharing area, and the running stability of the application program in the server device is relatively ensured.
In order to further deepen understanding of the above embodiments of the present application, the present application further provides a scene embodiment in a specific application scenario for further explanation. Fig. 7 is a schematic diagram illustrating a memory sharing process according to an embodiment of the present disclosure.
As shown in fig. 7, the system first needs to collect the memory access data of the target program, the application range of the memory sharing technology has a certain limitation, and the memory area with higher writing frequency is not suitable for being shared, because the system needs to create a new copy for the written memory when the shared memory is written, otherwise, other user data using the shared memory will be damaged. The memory sharing technology is suitable for being used for a memory area with read-only or low memory writing frequency, and the performance of the memory area with high memory writing frequency is reduced due to extra CPU (central processing unit) overhead, so that the aim of saving the memory cannot be achieved. The aim of the memory access data collection module is to acquire memory area information with low program writing frequency.
The use modes of the memory of each program are different, data collection needs to be carried out in the program running process, and the collection of memory write-in data needs to carry out write protection on the memory used by the program, so that the program generates CPU (Central processing Unit) abnormity during memory writing and is captured by a system, and extra performance overhead is generated, and the performance of the program is reduced. Therefore, the memory access data collection needs to be completed before the business program is formally operated, the operation is configured by using the parameters same as the actual environment, the memory write protection is started, and the memory write information of the program is collected, wherein the memory write information mainly comprises the write frequency of each memory area.
2. KSM (Kernel Samepage Merging, Kernel common page sharing) memory region registration
According to the program memory writing frequency information acquired by the program memory data collection module, the KSM memory region registration module registers a memory region with lower writing frequency to the kernel, and the memory region registered by the KSM memory region registration module is used as a memory sharing region of the KSM module.
3. KSM module
The KSM module periodically scans the registered memory sharing area and merges the memory pages with the same content, thereby achieving the purposes of saving physical memory and improving the use efficiency of the memory.
4. Dynamic feedback of memory sharing strategies
The process of the KSM module executing the memory sharing mechanism may generate CPU performance overhead, and the larger the candidate memory area is, the higher the candidate memory scanning frequency is, and the higher the frequency of the merged memory being written into is, the larger the CPU performance overhead is. The memory sharing strategy dynamic feedback module dynamically adjusts the execution parameters of the KSM module according to the dynamic change of the system CPU load, reduces the scanning frequency of the KSM module when the system CPU load is higher, reduces the CPU consumption of the KSM module and improves the overall performance of the system; when the CPU load of the system is low, the scanning frequency of the KSM module is properly improved, the memory sharing efficiency is improved, and the overall performance of the system is improved.
In addition, in the process of repeatedly scanning the candidate memory area by the KSM, if the frequency of sharing a certain memory area is very low or the frequency of writing the memory area is high, the memory sharing policy dynamic feedback module needs to remove the memory area from the memory sharing area, so as to optimize the subsequent execution efficiency of the KSM module.
Referring to fig. 8, an embodiment of the present application discloses a memory sharing device, including:
the access collection module 10 is used for collecting the memory access data of the application program;
a shared area determining module 11, configured to determine, according to the memory access data, a memory shared area that meets a preset standard in the memory; the preset standard at least comprises that the read-write type of the memory page is a read-only type;
a memory page scanning module 12, configured to scan target memory pages with the same data content in a memory sharing area;
a memory page merging module 13, configured to merge the target memory pages.
In one embodiment, the memory page scanning module 12 includes:
and the frequency scanning module is used for scanning the target memory pages with the same data content in the memory sharing area according to a preset scanning frequency.
In one embodiment, the apparatus further comprises:
the occupation amount acquisition module is used for acquiring the occupation amount of the operation resources;
and the frequency determination module is used for determining the preset scanning frequency according to the occupation amount of the operation resources.
In one embodiment, the frequency determination module includes:
the frequency adjusting module is used for adjusting the preset scanning frequency in real time according to the occupation amount of the operation resources; wherein, the occupation amount of the computing resources has negative correlation with the preset scanning frequency.
In one embodiment, the predetermined criteria further includes that the write frequency of the memory pages is lower than a predetermined write frequency.
In one embodiment, an apparatus comprises:
a write frequency region determining module, configured to determine, in the memory shared region, a target memory region where a write frequency of the memory page reaches a preset write frequency;
and the region removing module is used for removing the target memory region in the memory sharing region so as to merge the target memory pages based on the updated memory sharing region.
In one embodiment, the apparatus further comprises:
a merging frequency determination module, configured to determine, in a memory shared region, a target memory region where a merging frequency of a memory page is lower than a preset merging frequency;
and the region removing module is used for removing the target memory region in the memory sharing region so as to merge the target memory pages based on the updated memory sharing region.
The memory sharing device provided by the application firstly collects memory access data of an application program, and then determines a memory sharing area meeting a preset standard in a memory according to the memory access data, wherein the preset standard at least comprises that the read-write type of a memory page is a read-only type, and further scans a target memory page with the same data content in the memory sharing area on the basis, and then merges the target memory page. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured.
Based on the hardware implementation of the program module, and in order to implement the memory sharing method according to the embodiment of the present application, an embodiment of the present application further provides a memory sharing device, where a virtual machine runs and a communication connection is established between the virtual machine and a virtual machine disk corresponding to the virtual machine, and fig. 9 is a schematic diagram of a hardware structure of the memory sharing device according to the embodiment of the present application, and as shown in fig. 9, the memory sharing device includes:
a communication interface 1 capable of information interaction with other devices such as network devices and the like;
and the processor 2 is connected with the communication interface 1 to realize information interaction with other equipment, and is used for executing the memory sharing method provided by one or more technical schemes when running a computer program. And the computer program is stored on the memory 3.
Of course, in practice, the various components of the memory sharing device are coupled together by the bus system 4. It will be appreciated that the bus system 4 is used to enable connection communication between these components. The bus system 4 comprises, in addition to a data bus, a power bus, a control bus and a status signal bus. For the sake of clarity, however, the various buses are labeled as bus system 4 in fig. 9.
The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the memory sharing device. Examples of such data include: any computer program for operating on a memory sharing device.
It will be appreciated that the memory 3 may be either volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced DRAM), Synchronous Dynamic Random Access Memory (SLDRAM), Direct Memory (DRmb Access), and Random Access Memory (DRAM). The memory 2 described in the embodiments of the present application is intended to comprise, without being limited to, these and any other suitable types of memory.
The memory sharing method disclosed in the embodiment of the present application may be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip having signal processing capabilities. In the implementation process, the steps of the memory sharing method may be implemented by an integrated logic circuit of hardware in the processor 2 or instructions in the form of software. The processor 2 described above may be a general purpose processor, a DSP, or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The processor 2 may implement or execute the memory sharing methods, steps and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the memory sharing method disclosed in the embodiments of the present application may be directly implemented as the execution of a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium located in the storage 3, and the processor 2 reads the program in the storage 3 and completes the steps of the foregoing memory sharing method in combination with the hardware thereof.
When the processor 2 executes the program, the corresponding processes in each memory sharing method according to the embodiment of the present application are realized, and for brevity, are not described herein again.
In an exemplary embodiment, the present application further provides a storage medium, specifically a computer-readable storage medium, for example, a storage 3 storing a computer program, where the computer program is executable by a processor 2 to perform the steps of the foregoing memory sharing method. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus, terminal and memory sharing method may be implemented in other ways. The above-described device embodiments are only illustrative, for example, the division of the unit is only one logical function division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical 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, that is, may be located in one place, or may be distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps of implementing the memory sharing method embodiment may be implemented by hardware related to program instructions, where the program may be stored in a computer-readable storage medium, and when executed, the program performs the steps including the memory sharing method embodiment; and the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a memory sharing device (which may be a personal computer, a server, or a network device) to execute all or part of the memory sharing methods of the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
The memory sharing device provided by the application firstly collects memory access data of an application program, and then determines a memory sharing area meeting a preset standard in a memory according to the memory access data, wherein the preset standard at least comprises that the read-write type of a memory page is a read-only type, and further scans a target memory page with the same data content in the memory sharing area on the basis, and then merges the target memory page. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured.
In addition, an embodiment of the present application further discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the memory sharing method as described above are implemented.
The computer-readable storage medium provided by the application first collects memory access data of an application program, and then determines a memory sharing area meeting a preset standard in a memory according to the memory access data, wherein the preset standard at least includes that a read-write type of a memory page is a read-only type, and further scans target memory pages with the same data content in the memory sharing area on the basis, and then merges the target memory pages. According to the method and the device, the memory sharing area which can be used for data sharing in the memory is obtained by collecting the memory access data generated when the application program accesses the memory, and on the basis, the target memory pages with the same data in the memory sharing area are combined, so that the memory resources are saved, the situation that the memory resources are insufficient is relatively avoided, and the running stability of the application program in the server equipment is relatively ensured.
The above detailed description is provided for a memory sharing method, apparatus, device and storage medium provided by the present application. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A memory sharing method, comprising:
collecting memory access data of an application program;
determining a memory sharing area meeting a preset standard in a memory according to the memory access data; the preset standard at least comprises that the read-write type of the memory page is a read-only type;
scanning target memory pages with the same data content in the memory sharing area;
and merging the target memory pages.
2. The memory sharing method according to claim 1, wherein the scanning for the target memory pages with the same data content in the memory sharing region comprises:
and scanning the target memory pages with the same data content in the memory sharing area according to a preset scanning frequency.
3. The method according to claim 2, wherein before the scanning for the target memory pages with the same data content in the memory sharing region according to the preset scanning frequency, the method further comprises:
acquiring the occupation amount of computing resources;
and determining the preset scanning frequency according to the occupation amount of the operation resources.
4. The memory sharing method according to claim 3, wherein the determining the predetermined scanning frequency according to the computational resource occupancy comprises:
adjusting the preset scanning frequency in real time according to the occupation amount of the operation resources; and the occupation amount of the computing resources has negative correlation with the preset scanning frequency.
5. The memory sharing method according to claim 1, wherein the predetermined criteria further includes that the write frequency of the memory pages is lower than a predetermined write frequency.
6. The memory sharing method according to claim 5, further comprising, after determining a memory sharing area satisfying a predetermined criterion in the memory according to the memory access data:
determining a target memory area in the memory sharing area, wherein the write-in frequency of the memory page reaches the preset write-in frequency;
and removing the target memory area in the memory sharing area, so as to merge the target memory page based on the updated memory sharing area.
7. The memory sharing method according to any one of claims 1 to 6, further comprising, after the merging the target memory page:
determining a target memory area in the memory sharing area, wherein the merging frequency of the memory pages is lower than a preset merging frequency;
and removing the target memory area in the memory sharing area, so as to merge the target memory page based on the updated memory sharing area.
8. A memory sharing device, comprising:
the access collection module is used for collecting the memory access data of the application program;
the shared area determining module is used for determining a memory shared area meeting a preset standard in a memory according to the memory access data; the preset standard at least comprises that the read-write type of the memory page is a read-only type;
a memory page scanning module, configured to scan target memory pages with the same data content in the memory sharing area;
and a memory page merging module, configured to merge the target memory pages.
9. A memory sharing device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the memory sharing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the memory sharing method according to any one of claims 1 to 7.
CN202110476028.2A 2021-04-29 2021-04-29 Memory sharing method, device, equipment and storage medium Active CN113176958B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110476028.2A CN113176958B (en) 2021-04-29 2021-04-29 Memory sharing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110476028.2A CN113176958B (en) 2021-04-29 2021-04-29 Memory sharing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113176958A true CN113176958A (en) 2021-07-27
CN113176958B CN113176958B (en) 2024-02-23

Family

ID=76925402

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110476028.2A Active CN113176958B (en) 2021-04-29 2021-04-29 Memory sharing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113176958B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114661497A (en) * 2022-03-31 2022-06-24 慧之安信息技术股份有限公司 Memory sharing method and system for partition of operating system
WO2023011388A1 (en) * 2021-08-02 2023-02-09 朱玉荣 Memory sharing method and apparatus, electronic device, and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104050189A (en) * 2013-03-14 2014-09-17 华为技术有限公司 Page sharing processing method and device
US20150178127A1 (en) * 2013-12-19 2015-06-25 International Business Machines Corporation Optimally provisioning and merging shared resources to maximize resource availability
CN106155933A (en) * 2016-07-06 2016-11-23 乾云众创(北京)信息科技研究院有限公司 A kind of virutal machine memory sharing method combined based on KSM and Pass through
CN106557365A (en) * 2015-09-25 2017-04-05 联发科技股份有限公司 Self adaptation same page internal memory merging method and its electronic installation
CN106874119A (en) * 2017-02-25 2017-06-20 郑州云海信息技术有限公司 Merging method and device based on the scanning of homogeneity internal memory
CN109271247A (en) * 2017-07-12 2019-01-25 珠海市魅族科技有限公司 Memory Optimize Method, device, computer installation and storage medium
US20200257634A1 (en) * 2019-02-13 2020-08-13 International Business Machines Corporation Page sharing for containers

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104050189A (en) * 2013-03-14 2014-09-17 华为技术有限公司 Page sharing processing method and device
US20150178127A1 (en) * 2013-12-19 2015-06-25 International Business Machines Corporation Optimally provisioning and merging shared resources to maximize resource availability
CN106557365A (en) * 2015-09-25 2017-04-05 联发科技股份有限公司 Self adaptation same page internal memory merging method and its electronic installation
CN106155933A (en) * 2016-07-06 2016-11-23 乾云众创(北京)信息科技研究院有限公司 A kind of virutal machine memory sharing method combined based on KSM and Pass through
CN106874119A (en) * 2017-02-25 2017-06-20 郑州云海信息技术有限公司 Merging method and device based on the scanning of homogeneity internal memory
CN109271247A (en) * 2017-07-12 2019-01-25 珠海市魅族科技有限公司 Memory Optimize Method, device, computer installation and storage medium
US20200257634A1 (en) * 2019-02-13 2020-08-13 International Business Machines Corporation Page sharing for containers

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023011388A1 (en) * 2021-08-02 2023-02-09 朱玉荣 Memory sharing method and apparatus, electronic device, and readable storage medium
CN114661497A (en) * 2022-03-31 2022-06-24 慧之安信息技术股份有限公司 Memory sharing method and system for partition of operating system

Also Published As

Publication number Publication date
CN113176958B (en) 2024-02-23

Similar Documents

Publication Publication Date Title
US9058212B2 (en) Combining memory pages having identical content
CN113176958A (en) Memory sharing method, device, equipment and storage medium
CN111782656B (en) Data reading and writing method and device
CN113064859B (en) Metadata processing method and device, electronic equipment and storage medium
KR20050043291A (en) Apparatus and method for garbage collection
US8296270B2 (en) Adaptive logging apparatus and method
JPH07271674A (en) Method for optimization of cache
CN113590508B (en) Dynamic reconfigurable memory address mapping method and device
US20240086332A1 (en) Data processing method and system, device, and medium
CN113377291A (en) Data processing method, device, equipment and medium of cache equipment
KR20170002866A (en) Adaptive Cache Management Method according to the Access Chracteristics of the User Application in a Distributed Environment
CN109558456A (en) A kind of file migration method, apparatus, equipment and readable storage medium storing program for executing
CN110795213A (en) Active memory prediction migration method in virtual machine migration process
US8656120B2 (en) Device, method and computer-readable medium relocating remote procedure call data in heterogeneous multiprocessor system on chip
CN107632779B (en) Data processing method and device and server
JP2017204101A (en) Storage control apparatus, storage system, and storage device control program
CN110753040B (en) Request processing method and device
CN106484314B (en) Cache data control method and device
CN115905049A (en) Hot and cold memory graded migration method based on Itanium memory
CN115114239A (en) Distributed system data processing method, device, equipment and medium
KR101643278B1 (en) Method, apparatus, and computer program stored in computer readable medium for managing storage server in database system
CN114064725A (en) Data processing method, device, equipment and storage medium
CN108845959B (en) Memory data processing method and device and electronic equipment
KR101359034B1 (en) Apparatus and method for storage of statistical data in network system
CN114327260B (en) Data reading method, system, server and storage medium

Legal Events

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