EP-4435611-B1 - METHOD AND DEVICE WITH DYNAMIC ADJUSTMENT OF SWAPPING
Inventors
- SHIN, YOUNGSAM
- BAEK, WOONG KI
- HAN, MYEONGGYUN
- OH, DEOK JAE
- Park, Eunseong
Dates
- Publication Date
- 20260506
- Application Date
- 20240320
Claims (16)
- A method of managing a virtual memory using a first memory (110, 221) comprising a main memory space (111) and a first swap pool (112) and a second memory (120) comprising a second swap pool (121), the method comprising: based on a quality of service, QoS, of tasks or on a system efficiency corresponding to execution of the tasks, adaptively adjusting (301) a distribution state of the first memory (110) or a size of the first swap pool (112); and based on the adaptively adjusted distribution state of the first memory (110) or the adaptively adjusted size of the first swap pool (112), performing (302) swap-out of a first page of the tasks from the main memory space (111) to the first swap pool (112) or the second swap pool (121) or performing swap-in of a second page of the tasks from the first swap pool (112) or the second swap pool (121) to the main memory space (111); wherein the performing (302) of the swap-out of the first page or the swap-in of the second page comprises: based on a characteristic of the first page, the first swap pool (112), or the second swap pool (121), selecting (1010), from among the first swap pool (112) and the second swap pool (121), a target swap pool of the first page for performing the swap out of the first page; and performing (1020) the swap-out of the first page based on the selected target swap pool of the first page.
- The method of claim 1, wherein the selecting (1010) of the target swap pool of the first page comprises: based on a characteristic of the first page, the first swap pool (112), or the second swap pool (121), determining (403) a first score of the first page; selecting (405) the target swap pool of the first page according to a result of comparing the first score of the first page to a first threshold value.
- The method of claim 1 or 2, wherein the first swap pool (112) comprises a compressed swap pool wherein pages are compressed when written to the first swap pool (112) and wherein pages are decompressed when read from the first swap pool (112), or wherein the performing of the swap-out of the first page or the swap-in of the second page comprises: based on a characteristic of the second page, the first swap pool (112), or the second swap pool (121), determining (1110) a swap-in type of the second page, the swap-in type corresponding to whether to duplicatively store the second page in the main memory space (111) and in a swap pool which can be either the first swap pool (112) or the second swap pool (121); and performing (1120)the swap-in of the second page based on the determined swap-in type of the second page.
- The method of claim 3, wherein the determining (1110) of the swap-in type of the second page comprises based on the characteristic of the second page, the first swap pool (112), or the second swap pool (121), determining a second score (504) of the second page; and determining (506) the swap-in type of the second page according to a result of comparing the second score of the second page to a second threshold value, and wherein the second score is proportional to hotness of the second page, a compression ratio of the second page, and an available space of the swap pool storing the second page, and wherein the second score is inversely proportional to performance of a swap pool storing the second page, or wherein the determining (1110) of the swap-in type of the second page comprises in response to the swap-in of the second page occurring due to a memory fault in the main memory space (111) caused by a write operation on the second page, determining the swap-in type of the second page to be a single-storage type for the main memory space (111).
- The method of one of claims 1 to 4, wherein the adaptively adjusting (301) the distribution state of the first memory (110) or the size of the first swap pool (112) comprises: determining, in an adaptation mode, the adaptive distribution state of the first memory (110) and the adaptive pool size of the first swap pool (112) based on a change of the QoS and the system efficiency resulting from adjustment of the distribution state of the first memory (110) and the size of the first swap pool (112); monitoring, in an idle mode, a change of the QoS or the system efficiency while operating the first memory (110) and the first swap pool (112) in the adaptive distribution state with the adaptive pool size; and performing the adaptation mode again based on the change of the QoS or the system efficiency.
- The method of claim 5, wherein the tasks comprise a first task (151) having a required QoS level and a second task (152) not having the required QoS level, and wherein the determining (301) of the adaptive distribution state of the first memory (110) and the adaptive pool size of the first swap pool (112) comprises: in response to a first QoS value of the first task (151) satisfying the required QoS level of the first task (151), varying a first adaptive memory size of a first partial space (110a) of the first task (151) while reducing a size of the first partial space (110a) in the first memory (110) for the first task (151); and in response to the first QoS value not satisfying the required QoS level according to the varying of the first adaptive memory size, varying a first adaptive pool size of the first task (151) while adjusting a size of a first partial pool (112a) in the first swap pool (112) for the first task (151).
- The method of claim 6, wherein the determining of the adaptive distribution state of the first memory (110) and the adaptive pool size of the first swap pool (112) comprises: determining a second adaptive memory size of a second partial space (110b) in the first memory (110) for the second task (152) based on a difference between a size of the first memory (110) and the first adaptive memory size of the first partial space (110a); and varying a second adaptive pool size of the second task (152) while adjusting a size of a second partial pool (112b) in the first swap pool (112) for the second task (152) so that the system efficiency increases in a state where the first QoS value satisfies the required QoS level.
- The method of one of claims 1 to 7, wherein the adaptively adjusting (301) of the distribution state of the first memory (110) or the size of the first swap pool (112) comprises: in response to an indication that the size of the first swap pool (112) is to be reduced (801), selecting a victim page from among pages stored in the first swap pool (112); and performing (802) eviction on the victim page, and wherein the performing of the eviction on the victim page comprises: based on whether the victim page is a duplicated page or not, determining whether to evict the victim page by performing invalidation on the victim page or whether to evict the victim page by storing the victim page in the second swap pool (121).
- A computer-readable storage medium storing instructions that, when executed by a processor (910) of an electronic device (900), cause the processor (910) to perform the method of: based on a quality of service, QoS, of tasks or on a system efficiency corresponding to execution of the tasks, adaptively adjust (301) a portion of a distribution state of a first memory (110) or a size of a first swap pool (112); and based on the adaptively adjusted distribution state of the first memory (110) or the adaptively adjusted size of the first swap pool (112), perform swap-out (302) of a first page of the tasks from the main memory space (111) to the first swap pool (112) or the second swap pool (121) or perform swap-in of a second page of the tasks from the first swap pool (112) or the second swap pool (121) to the main memory space (111); wherein the instructions are further configured to cause the processor (910) to, in order to perform the swap-out (302) of the first page or the swap-in of the second page: based on a characteristic of the first page, the first swap pool 8112), or the second swap pool (121), select (1010), from among the first swap pool (112) and the second swap pool (121), a target swap pool of the first page for performing the swap-out of the first page; and perform the swap-out (1020= of the first page based on the selected target swap pool of the first page.
- The computer-readable storage medium of claim 9, wherein pages are compressed when provided to the first swap pool (112) and are decompressed when obtained from the first swap pool (112), or wherein the instructions are further configured to cause the processor (910) to, in order to perform (301) the swap-out of the first page or the swap-in of the second page: based on a characteristic of the second page, the first swap pool (112), or the second swap pool (121), determine (1110) a swap-in type of the second page, the swap-in type corresponding to whether to duplicatively store the second page in both the main memory space (111) and either the first swap pool (112) or the second swap pool (121); and perform the swap-in (1120) of the second page based on the determined swap-in type of the second page.
- The computer-readable storage medium of claim 9 or 10, wherein the instructions are further configured to cause the processor (910) to, in order to adaptively adjust (301) the distribution state of the first memory (110) or the size of the first swap pool (112): determine, in an adaptation mode, the adaptive distribution state of the first memory (110) and the adaptive pool size of the first swap pool (112) based on a change of the QoS or the system efficiency resulting from adjustment of the distribution state of the first memory (110) and the size of the first swap pool (112); monitor, in an idle mode, a change of the QoS or the system efficiency while operating the first memory (110) and the first swap pool (112) in the adaptive distribution state with the adaptive pool size; and perform the adaptation mode again based on the change of the QoS or the system efficiency, and wherein the tasks comprise a first task (151) having a required QoS level and a second task (152) not having the required QoS level, and wherein the instructions are further configured to cause the processor (910) to, to determine the adaptive distribution state of the first memory (110) and the adaptive pool size of the first swap pool (112): in response to a first QoS value of the first task (151) satisfying the required QoS level of the first task (151), vary a first adaptive memory size of a first partial space (110a) of the first task (151) while reducing a size of the first partial space (110a) in the first memory (110) for the first task (151); in response to the first QoS value not satisfying the required QoS level according to the adjustment of the first adaptive memory size, vary a first adaptive pool size of the first task (151) while adjusting a size of a first partial pool (112a) in the first swap pool (112) for the first task (151); determine a second adaptive memory size of a second partial space (110b) in the first memory (110) for the second task (152) based on a difference between a size of the first memory (110) and the first adaptive memory size of the first partial space (110a); and explore a second adaptive pool size of the second task (152) while adjusting a size of a second partial pool (112b) in the first swap pool (112) for the second task (152) so that the system efficiency increases in a state where the first QoS satisfies the first required QoS level.
- The computer-readable storage medium of one of claims 9 to 11, wherein the instructions are further configured to cause the processor (910) to adaptively adjust (301) the distribution state of the first memory (110) or the size of the first swap pool (112) by: in response to an indication that the size of the first swap pool (112) is to be reduced (801), select a victim page from among pages stored in the first swap pool (112); and perform eviction (802) on the victim page.
- An electronic device (200) comprising: a first memory (221) comprising a main memory space (111) and a first swap pool (222); a second memory (223) comprising a second swap pool (224); and a processor (210) configured to: based on a quality of service, QoS, of tasks or on a system efficiency corresponding to execution of the tasks, adaptively adjust (301) a distribution state of the first memory (221) or a size of the first swap pool (222); and based on the adaptively adjusted distribution state of the first memory (221) or the adaptively adjusted size of the first swap pool (222), perform swap-out (302) of a first page of the tasks from the main memory space (111) to the first swap pool (222) or the second swap pool (224) or performing swap-in of a second page of the tasks from the first swap pool (222) or the second swap pool (224) to the main memory space (111), comprising: based on a characteristic of a first page, the first swap pool (222), or the second swap pool (224), select (1010), according to swap-out of the first page, a target swap pool from among the first swap pool (222) and the second swap pool (224); and perform swap-out (1020) of the first page based on the selected target swap pool.
- The electronic device (200) of claim 13, wherein the processor (210) is further configured to: based on a characteristic of a second page, the first swap pool (222), or the second swap pool (224), determine (1110) a swap-in type of the second page, the swap-in type corresponding to whether to duplicatively store the second page in the main memory space (111) and a swap pool, where the swap pool can be either of the first swap pool (222) or the second swap pool (224); and perform swap-in (1120) of the second page based on the determined swap-in type of the second page.
- The electronic device (200) of claim 13 or 14, wherein the processor (210) is configured to, in order to select the target swap pool: based on the characteristic of the first page, the first swap pool (222), or the second swap pool (224), determine a first score of the first page; and select the target swap pool according to a result of comparing the first score of the first page to a first threshold value, and wherein the first score is proportional to hotness of the first page, a compression ratio of the first page, performance of the first swap pool (222), and available space of the first swap pool (222).
- The electronic device (200) of claim 14, wherein the processor (210) is configured to: in order to determine the swap-in type of the second page: based on the characteristic of the second page, the first swap pool (222), or the second swap pool (224), determine a second score of the second page; and determine a swap-in type of the second page according to a result of comparing the second score of the second page to a second threshold value, and wherein the second score is proportional to hotness of the second page, a compression ratio of the second page, an available space of the swap pool storing the second page, and wherein the second score is inversely proportional to performance of a swap pool storing the second page, or in order to determine the swap-in type of the second page: in response to the swap-in of the second page occurring due to a memory fault in the main memory space (111), determine the swap-in type of the second page as a single storage type for the main memory space (111), wherein the memory fault occurs due to a write operation on the second page.
Description
BACKGROUND 1. Field The following description relates to a method of managing a memory and a device using the method. 2. Description of Related Art Memory swapping allows a computer operating system, for example, to provide a virtual memory with an address space that is significantly larger than the physical memory (e.g., a main/host storage device) backing the virtual memory. When a system is low on physical memory in RAM, some pieces of data in the RAM may be temporarily moved, as swap data, to an auxiliary storage device (e.g., a solid state drive (SDD)) serving as a swap device. This allows the system to continue running. Through memory swapping, an effect of adding more physical memory (without having to do so) may be exhibited and the system may use a swap space as a virtual memory. Accessing a space or device in which swap data is usually slower than accessing data stored in RAM. Memory swapping is an aspect of operating systems, for example, that may be used to efficiently manage memory resources and provide a trade-off between performance and memory usage. US 2010/023565 A1 discloses a swap space which is provided for a host computer system, where the swap space includes a plurality of swap files with each individual swap file for swapping data only for a single corresponding virtual machine (VM). The per-VM swap space is used solely by the single, corresponding VM, such that only that particular VM's memory is allowed to be swapped out to the swap file. SUMMARY This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter. The invention is claimed in the independent claims. Preferred embodiments are specified in the dependent claims. In one general aspect, there is a method of managing a virtual memory using a first memory including a main memory space and a first swap pool and a second memory including a second swap pool, and the method includes: based on a quality of service (QoS) of tasks or on a system efficiency corresponding to execution of the tasks, adaptively adjusting a distribution state of the first memory or a size of the first swap pool; and based on the adaptively adjusted distribution state of the first memory or the adaptively adjusted size of the first swap pool, performing swap-out of a first page of the tasks from the main memory space to the first swap pool or the second swap pool or performing swap-in of a second page of the tasks from the first swap pool or the second swap pool to the main memory space. The performing of the swap-out of the first page or the swap-in of the second page includes: based on a characteristic of the first page, the first swap pool, or the second swap pool, selecting, from among the first swap pool and the second swap pool, a target swap pool of the first page for performing the swap-out of the first page; and performing the swap-out of the first page based on the selected target swap pool of the first page. The selecting of the target swap pool of the first page may include: based on the characteristic of the first page, the first swap pool, or the second swap pool, determining a first score of the first page; and selecting the target swap pool of the first page according to a result of comparing the first score of the first page to a first threshold value . The first swap pool may include a compressed swap pool wherein pages are compressed when written to the first swap pool and wherein pages are decompressed when read from the first swap pool. The performing of the swap-out of the first page or the swap-in of the second page may include: based on a characteristic of the second page, the first swap pool, or the second swap pool, determining a swap-in type of the second page, the swap-in type corresponding to whether to duplicatively store the second page in the main memory space and in a swap pool which can be either the first swap pool or the second swap pool; and performing the swap-in of the second page based on the determined swap-in type of the second page. The determining of the swap-in type of the second page may include: based on the characteristic of the second page, the first swap pool, or the second swap pool, determining a second score of the second page; and determining the swap-in type of the second page according to a result of comparing the second score of the second page to a second threshold value, and wherein the second score is proportional to hotness of the second page, a compression ratio of the second page, and an available space of the swap pool storing the second page, and wherein the second score is inversely proportional to performance of a swap pool storing the second page. The determining of the swap-in type of the second page may include