Page scheduling methods, systems, computer equipment, and storage media
By setting a hotness weight value for Linux memory pages and dynamically adjusting the LRU list, the problem of memory pages being squeezed into the inactive page list is avoided, thus improving memory access efficiency and business response speed.
Patent Information
- Application Number
- CN202310898809.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-21
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2043-07-21
AI Technical Summary
In the Linux kernel, a large number of business accesses in a short period of time lead to frequent swapping of memory pages, which reduces business performance. The existing LRU linked list strategy may push useful memory pages into the inactive page linked list, resulting in the risk of multiple accesses and reclamation.
By setting a hotness weight value for each memory page, the LRU list is dynamically adjusted according to the access frequency, avoiding the squeezing of memory pages that need to be accessed multiple times into the inactive page list, optimizing the LRU list update strategy, and keeping memory pages with high hotness weight values in the active page list.
It improves memory access efficiency, reduces the computational cost of memory swapping in and out, and enhances business response speed and performance.
Smart Images

Figure CN117076808B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of page scheduling technology, and in particular to a page scheduling method, system, computer device, and storage medium. Background Technology
[0002] With the rapid development of the internet industry and the significant increase in online business, enterprise users have increasingly higher demands for business performance and responsiveness. Therefore, continuously improving business response speed is a constant pursuit. Improving memory usage performance in servers presents numerous challenges. The purpose of the memory management system in the Linux kernel is to ensure that currently used memory pages are always kept in memory. However, sometimes a large number of short-term business accesses lead to memory reclamation, resulting in a large amount of memory swapping in and out, and a decline in business performance.
[0003] The Linux kernel maintains an LRU (Least Recently Used) list, which is essentially a series of linked lists. Pages in user space within physical memory are linked together by these lists. The kernel regularly checks the LRU lists, placing the most recently accessed page at the head of the LRU list. When more pages are needed, to move some pages from the disk or swap partition, pages at the tail of the LRU list are reclaimed first. The LRU implementation assumes that recently used pages are likely to be used again, while pages that haven't been used for some time are generally not worth retaining.
[0004] If an application loads many new memory pages into the active page list in a short period of time via a page fault, it may push some useful memory pages that are currently in use into the inactive page list. Although these newly added pages are only accessed once, the memory pages pushed into the inactive page list may need to be accessed multiple times, and these pages may be at risk of being reclaimed. This will cause memory to be swapped in and out, thus reducing business performance. Summary of the Invention
[0005] Based on this, a page scheduling method, system, computer device, and storage medium are provided, which can dynamically adjust and control the LRU list under the Linux system, and dynamically update it according to the actual memory page type and access frequency. This avoids memory pages that need to be accessed multiple times from being squeezed into the inactive page list or even reclaimed, and avoids performance loss due to memory swapping in and out, thereby improving business response speed.
[0006] On the one hand, a page scheduling method is provided, the method comprising:
[0007] Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list;
[0008] Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0009] The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list.
[0010] Based on the real-time popularity weight value of memory pages, the popularity weight value of memory pages in the current LRU list is modified, and the position of memory pages in the LRU list is adjusted.
[0011] In one embodiment, before the step of traversing the memory pages in the LRU linked list of the current system, setting each memory page to have a hotness weight value, and initializing the hotness weight values of the memory pages in the LRU linked list, the method further includes:
[0012] Configure the change in the heat weight value corresponding to the change in the position of the memory page in the active page list and the inactive page list;
[0013] Configure the initial heat weight value of newly loaded memory pages, and configure the newly loaded memory pages to be added to the list of inactive pages.
[0014] In one embodiment, the step of changing the heat weight value corresponding to the position change data of the configuration memory page in the active page list and the inactive page list includes:
[0015] Configure the memory page popularity weight value to increase by α. When a memory page is transferred from the inactive page list to the active page list, the popularity weight value of the memory page increases by α.
[0016] Configure a decrement β for the page popularity weight. When a page moves from the active page list to the inactive page list, the page popularity weight is reduced by β; where β < α.
[0017] In one embodiment, the steps of configuring the initial heat weight value of the newly loaded memory page and configuring the newly loaded memory page to be added to the inactive page list include:
[0018] Configure the initial heat weight of memory pages to γ. When a newly loaded memory page is added to the list of inactive pages, the heat weight of that memory page is initialized to γ; where γ < α.
[0019] In one embodiment, the step of initializing the hotness weight value of memory pages in the LRU list includes:
[0020] The hotness weight value of all memory pages in the LRU list is assigned to γ.
[0021] In one embodiment, the step of adjusting the position of the memory page in the LRU list includes:
[0022] In the linked list, memory pages are sorted in descending order based on their popularity weight value;
[0023] According to the limited number of memory pages in the active page list, memory pages that exceed the limited number at the end of the descending order in the active page list are obtained as memory pages to be pre-adjusted to the inactive page list, and then adjusted to the inactive page list.
[0024] According to the limited number of memory pages in the inactive page list, memory pages that exceed the limited number at the end of the descending order in the inactive page list are taken as memory pages to be pre-adjusted to be outside the inactive page list, and then adjusted to be outside the inactive page list.
[0025] In one embodiment, after the step of adjusting memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the method further includes:
[0026] The heat weight value of memory pages that have been moved outside the inactive page list will be reset to zero.
[0027] On the other hand, a page scheduling system is provided, the system comprising:
[0028] An initialization device is used to traverse the memory pages in the LRU linked list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU linked list.
[0029] The monitoring device is used to monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0030] The judgment device is used to judge the real-time heat weight value of each memory page based on the heat weight value change value corresponding to the position change data of the memory page in the active page list and the inactive page list.
[0031] An execution device is used to modify the hotness weight value of memory pages in the current LRU list based on the judgment result of the real-time hotness weight value of memory pages, and to adjust the position of memory pages in the LRU list.
[0032] In another aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0033] Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list;
[0034] Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0035] The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list.
[0036] Based on the real-time popularity weight value of memory pages, the popularity weight value of memory pages in the current LRU list is modified, and the position of memory pages in the LRU list is adjusted.
[0037] In another aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0038] Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list;
[0039] Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0040] The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list.
[0041] Based on the real-time popularity weight value of memory pages, the popularity weight value of memory pages in the current LRU list is modified, and the position of memory pages in the LRU list is adjusted.
[0042] The aforementioned page scheduling method, system, computer equipment, and storage medium assign a hotness weight value to each memory page. This hotness weight value reflects the access frequency of the memory page; the more times it is accessed, the higher the corresponding hotness weight value. Based on the size of the hotness weight value, it is possible to control whether the memory page is kept in the active page list or the inactive page list. Under the Linux system, the LRU list can be dynamically adjusted and controlled, and dynamically updated according to the actual memory page type and access frequency. This prevents memory pages that need to be accessed frequently from being pushed into the inactive page list or even reclaimed, thereby improving the business response speed. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is a diagram illustrating the application environment of a page scheduling method in one embodiment.
[0045] Figure 2 This is a flowchart illustrating a page scheduling method in one embodiment;
[0046] Figure 3 This is a flowchart illustrating the steps of traversing memory pages in the LRU list of the current system, setting a hotness weight value for each memory page, and initializing the hotness weight value of the memory pages in the LRU list in one embodiment.
[0047] Figure 4 This is a flowchart illustrating the steps for adjusting the position of a memory page in the LRU list in one embodiment.
[0048] Figure 5 For one embodiment, the corresponding Figure 1 The sequence diagram shown illustrates the application environment where the page scheduling system interacts with the LRU list.
[0049] Figure 6 This is a schematic diagram illustrating the update of memory page hotness weight values in an LRU linked list in one embodiment;
[0050] Figure 7 This is a structural block diagram of a page scheduling system in one embodiment;
[0051] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] As described in the background section, the virtual file system currently used in the Linux kernel allows businesses or programs to access a virtual address space that is much larger than the actual physical memory size. Therefore, the memory addresses accessed by applications are sometimes stored in the swap partition under the system. However, accessing the swap partition involves memory swapping in and out, so it is best to store the memory that a process is about to access in physical memory.
[0054] The Linux kernel maintains an LRU (Least Recently Used) list, which is essentially a linked list. Pages in user space within physical memory are linked together by this list. The kernel regularly checks the LRU list, placing the most recently accessed page at the head of the LRU list. When more pages are needed, to free up some pages from the disk or swap partition, the pages at the tail of the LRU list are reclaimed first. The LRU implementation assumes that recently used pages are likely to be used again, while pages that haven't been used for some time are generally not worth retaining.
[0055] The LRU list actually contains multiple linked lists, such as the active anonymous page list, the inactive anonymous page list, the active file page list, the inactive file page list, and the non-swapable page list. The active page list stores the most recently accessed memory pages. When a page at the end of the active page list needs to be removed, it is first moved to the inactive page list. At this point, user space cannot directly access these pages. If a process accesses a page already in the inactive page list, a soft page fault is triggered, and the kernel immediately moves the page back to the active page list, allowing user space to access it. If system memory is insufficient, pages will be reclaimed from the inactive page list or swapped to the swap partition.
[0056] If an application loads many new memory pages into the active page list in a short period of time via a page fault, it may push some useful memory pages that are currently in use into the inactive page list. Although these newly added pages are only accessed once, the memory pages pushed into the inactive page list may need to be accessed multiple times, and these pages may be at risk of being reclaimed. This will cause memory to be swapped in and out, thus reducing business performance.
[0057] As mentioned above, if these newly added pages are accessed only once, as the LRU list is continuously updated, these pages will be pushed into the inactive page list, and will also occupy the inactive memory pages that are actually needed for subsequent access.
[0058] To address the aforementioned issues, this invention creatively proposes a page scheduling method that dynamically adjusts and controls the LRU linked list iteration update strategy. The method updates dynamically based on the actual memory page type and access frequency, preventing memory pages requiring multiple accesses from being pushed into the inactive page list or even reclaimed; conversely, it prevents memory pages accessed only once from frequently entering the active page list, thus occupying space for other memory pages. Through these two optimizations, the LRU linked list update strategy is adjusted, avoiding performance losses from memory swapping in and out, thereby improving business response speed.
[0059] The page scheduling method provided in this application can be applied to, for example... Figure 1The page scheduling system shown interacts with an LRU linked list in an application environment. The page scheduling system includes an initialization device, a monitoring device, a judgment device, and an execution device. The initialization device primarily initializes and marks the memory page information in the current system's LRU linked list during the service startup phase, recording the current memory page's linked list position, access count, and whether it's the first access. The monitoring device is mainly responsible for monitoring the changes in the memory pages in the current LRU linked list. The judgment device is responsible for determining which linked list in the LRU linked list the current memory page should belong to based on the memory page information. The execution device is responsible for adding the memory page to the linked list where it should exist based on the judgment result.
[0060] In one embodiment, such as Figure 2 As shown, a page scheduling method is provided, which can be applied to... Figure 1 Taking the page scheduling system in [the context of the document] as an example, the following steps are included:
[0061] Step S1: Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight value of the memory pages in the LRU list;
[0062] Step S2: Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0063] Step S3: Determine the real-time heat weight value of each memory page based on the heat weight value change corresponding to the preset position change data of memory pages in the active page list and inactive page list.
[0064] Step S4: Based on the judgment result of the real-time hotness weight value of the memory page, modify the hotness weight value of the memory page in the current LRU list and adjust the position of the memory page in the LRU list.
[0065] This embodiment proposes an LRU linked list dynamic adjustment and update mechanism. The hotness weight value is updated according to the frequency of memory page access under the current Linux system. The hotness weight value is reset for memory pages that are reclaimed and then accessed again. Memory pages that are frequently swapped in and out can be kept in the LRU linked list based on the size of the hotness weight value. This avoids pushing memory pages that really need to be accessed multiple times into the inactive page linked list or even reclaiming them, thereby improving the access efficiency of hot memory pages.
[0066] like Figure 3 As shown, in this embodiment, before the step of traversing the memory pages in the LRU linked list of the current system, setting each memory page to have a hotness weight value, and initializing the hotness weight values of the memory pages in the LRU linked list, the following steps are also included:
[0067] Step S11: Configure the change value of the heat weight corresponding to the change data of the position of the memory page in the active page list and the inactive page list;
[0068] Step S12: Configure the initial heat weight value of the newly loaded memory page and configure the newly loaded memory page to be added to the inactive page list.
[0069] In this application, newly loaded memory pages are added to the inactive page list, and the strategy for entering the active page list is adjusted for memory pages accessed for the first time. This avoids the memory pages that need to be accessed multiple times in the active page list being squeezed out by a large number of page accesses in a short period of time, thus avoiding memory page swapping in and out.
[0070] In this embodiment, the step of configuring the change in the position of the memory page in the active page list and the inactive page list, corresponding to the change in the heat weight value, includes:
[0071] Configure the memory page popularity weight value to increase by α. When a memory page is transferred from the inactive page list to the active page list, the popularity weight value of the memory page increases by α.
[0072] Configure a decrement β for the page popularity weight. When a page moves from the active page list to the inactive page list, the page popularity weight is reduced by β; where β < α.
[0073] In this embodiment, the steps of configuring the initial heat weight value of the newly loaded memory page and configuring the newly loaded memory page to be added to the inactive page list include:
[0074] Configure the initial heat weight of memory pages to γ. When a newly loaded memory page is added to the list of inactive pages, the heat weight of that memory page is initialized to γ; where γ < α.
[0075] Assuming that the memory page accessed by the system at the current time is still highly likely to be accessed again in the next time period, and in order to avoid frequent switching between the active page list and the inactive page list for frequently accessed memory pages, α is usually greater than β; in addition, in order to avoid resource-intensive business requests for a large amount of memory in a short period of time crowding out the active page list and affecting the performance of the currently running business, the initial popularity weight of memory pages is configured to be γ. The weight value γ should not be too high, and is usually lower than α.
[0076] In this embodiment, α = 1.5, β = 0.5, and γ = 1 are preferred. The adjustment values α, β, and γ for the popularity weight can be adjusted according to actual needs. Generally, the α value represents the likelihood of a memory page moving to an active page; a higher α value indicates a greater likelihood that the currently accessed memory page will remain in the active page list. The β value represents the likelihood of a memory page moving to an inactive page; a higher β value indicates a desire for the popularity weight of the currently accessed memory page to decrease. Therefore, under normal circumstances, α is greater than β, and γ = α - β. Choosing γ = α - β ensures that the initial popularity weight of newly loaded memory pages is equal to the initial popularity weight of memory pages moved from the active page list to the inactive page list, maintaining data balance.
[0077] This embodiment dynamically updates the popularity weight value, allowing for customized configuration of the popularity weight value parameter based on business type and status. It adjusts the LRU list update strategy and optimizes the position of memory pages in the list, thereby improving memory access hit rate and preventing memory pages from being moved in and out of the list. For the overall business, this results in two benefits: firstly, reduced computational consumption and freed up resources; secondly, improved business access efficiency and performance.
[0078] In this embodiment, the step of initializing the hotness weight value of memory pages in the LRU list includes:
[0079] The hotness weight value of all memory pages in the LRU list is assigned to γ.
[0080] like Figure 4 As shown, in this embodiment, the step of adjusting the position of the memory page in the LRU list includes:
[0081] Step S41: Sort the memory pages in the linked list in descending order according to their popularity weight value;
[0082] Step S42: According to the limited number of memory pages in the active page list, obtain memory pages that exceed the limited number at the end of the descending order in the active page list as memory pages to be pre-adjusted to the inactive page list, and adjust them to the inactive page list.
[0083] Step S43: According to the limited number of memory pages in the inactive page list, obtain memory pages that exceed the limited number at the end of the descending order in the inactive page list as memory pages to be pre-adjusted to be outside the inactive page list, and adjust them to be outside the inactive page list.
[0084] Specifically, memory pages that were pre-adjusted to be outside the inactive page list are adjusted to be recycled memory pages or swapped to the swap partition.
[0085] In essence, the popularity weight value determines the order in which memory pages are sorted in descending order within the linked list. Therefore, the popularity weight value represents the relative importance of the sorting priority. The larger the popularity weight value, the longer the corresponding memory page remains in the linked list.
[0086] In this embodiment, after the step of adjusting the memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the method further includes:
[0087] Step S44: Clear the heat weight value of memory pages that have been adjusted to be outside the inactive page list to zero.
[0088] Among them, the popularity weight value of the reclaimed memory page is cleared to zero, so that the popularity weight value can be reset for memory pages that are accessed again after reclamation.
[0089] like Figure 5 , Figure 6 As shown, Figure 5 For the corresponding Figure 1 The sequence diagram shown illustrates the application environment where the page scheduling system interacts with the LRU list. Figure 6 This diagram illustrates the update of memory page hotness weight values in the LRU linked list.
[0090] Therefore, the basic principle of this embodiment is:
[0091] 1) The initialization device will traverse the memory pages in the LRU list under the current system and calculate the access frequency weight value of the memory page based on its location and the number of times it has been accessed.
[0092] 2) During business operations, memory access operations are constantly performed. Therefore, the memory pages in the LRU list will constantly change between the active page list and the inactive page list. The monitoring device can monitor the changes of memory pages in the list.
[0093] 3) The hotness weight value of memory pages is dynamically calculated and modified as they are continuously accessed or swapped out.
[0094] 4) If a memory page is transferred from the inactive page list to the active page list through a memory interrupt, the hotness weight value of that memory page is increased by α.
[0095] 5) If a memory page is moved from the active page list to the inactive page list, the page's heat weight is reduced by β.
[0096] 6) The hotness weight of a memory page is reset to zero when it is reclaimed from the inactive page list or moved to the swap partition.
[0097] 7) If a memory page is accessed for the first time, initialize the weight value to γ.
[0098] 8) When inserting a memory page into the LRU list for the first time, it is inserted at the head of the inactive page list. This ensures that when a resource-intensive task requests a large amount of memory at once, it will not crowd out the memory pages currently in use in the active page list, thus avoiding impacting the latency and performance of the current business.
[0099] 9) The judgment device determines the position of the memory page in the current LRU list based on the memory page hotness weight value and strategy.
[0100] 10) The position of a memory page in the LRU list depends on the page's hotness weight value.
[0101] 11) The execution unit is responsible for adjusting and configuring the position of memory pages in the LRU list based on the result of the judgment unit.
[0102] In the page scheduling method described above, each memory page is assigned a popularity weight value, which reflects the access frequency of the memory page. The more times it is accessed, the higher the popularity weight value. Based on the popularity weight value, the memory page can be controlled to remain in the active page list or the inactive page list. Under the Linux system, the LRU list can be dynamically adjusted and controlled, and updated dynamically according to the actual memory page type and access frequency. This prevents memory pages that need to be accessed multiple times from being pushed into the inactive page list or even reclaimed, thereby improving the business response speed.
[0103] It should be understood that although Figures 2-4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figures 2-4 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0104] In one embodiment, such as Figure 7 As shown, a page scheduling system 10 is provided, including: an initialization device 1, a monitoring device 2, a judgment device 3, and an execution device 4.
[0105] The initialization device 1 is used to traverse the memory pages in the LRU linked list under the current system, set each memory page to have a hotness weight value, and initialize the hotness weight value of the memory pages in the LRU linked list.
[0106] The monitoring device 2 is used to monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list.
[0107] The judgment device 3 is used to judge the real-time heat weight value of each memory page based on the heat weight value change value corresponding to the preset position change data of the memory page in the active page list and the inactive page list.
[0108] The execution device 4 is used to modify the memory page hotness weight value in the current LRU list based on the judgment result of the real-time hotness weight value of the memory page, and adjust the position of the memory page in the LRU list.
[0109] In this embodiment, before the step of traversing the memory pages in the LRU linked list of the current system, setting each memory page to have a hotness weight value, and initializing the hotness weight values of the memory pages in the LRU linked list, the method further includes:
[0110] Configure the change in the heat weight value corresponding to the change in the position of the memory page in the active page list and the inactive page list;
[0111] Configure the initial heat weight value of newly loaded memory pages, and configure the newly loaded memory pages to be added to the list of inactive pages.
[0112] In this embodiment, the step of configuring the change in the position of the memory page in the active page list and the inactive page list, corresponding to the change in the heat weight value, includes:
[0113] Configure the memory page popularity weight value to increase by α. When a memory page is transferred from the inactive page list to the active page list, the popularity weight value of the memory page increases by α.
[0114] Configure a decrement β for the page popularity weight. When a page moves from the active page list to the inactive page list, the page popularity weight is reduced by β; where β < α.
[0115] In this embodiment, the steps of configuring the initial heat weight value of the newly loaded memory page and configuring the newly loaded memory page to be added to the inactive page list include:
[0116] Configure the initial heat weight of memory pages to γ. When a newly loaded memory page is added to the list of inactive pages, the heat weight of that memory page is initialized to γ; where γ < α.
[0117] In this embodiment, the step of initializing the hotness weight value of memory pages in the LRU list includes:
[0118] The hotness weight value of all memory pages in the LRU list is assigned to γ.
[0119] In this embodiment, the step of adjusting the position of the memory page in the LRU list includes:
[0120] In the linked list, memory pages are sorted in descending order based on their popularity weight value;
[0121] According to the limited number of memory pages in the active page list, memory pages that exceed the limited number at the end of the descending order in the active page list are obtained as memory pages to be pre-adjusted to the inactive page list, and then adjusted to the inactive page list.
[0122] According to the limited number of memory pages in the inactive page list, memory pages that exceed the limited number at the end of the descending order in the inactive page list are taken as memory pages to be pre-adjusted to be outside the inactive page list, and then adjusted to be outside the inactive page list.
[0123] In this embodiment, after the step of adjusting the memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the method further includes:
[0124] The heat weight value of memory pages that have been moved outside the inactive page list will be reset to zero.
[0125] Combining the page scheduling method described above, the initialization device 1 refers to the device responsible for initializing the hotness weight value of memory pages in the LRU list under the current system after enabling current memory access optimization. The initial hotness weight value is assigned to 1 according to the position of the memory page.
[0126] Monitoring device 2 is responsible for monitoring changes in memory pages in the current LRU list, recording the transfer of memory pages from the active page list to the inactive page list, the transfer of inactive page lists to the active page list, and the entry of newly added memory pages into the LRU list, and feeding this information back to the judgment device.
[0127] The judgment device 3 is responsible for judging the popularity weight value of memory pages in the LRU list based on the information recorded by the monitoring device. Specifically, if a memory page is transferred from the inactive page list to the active page list, its popularity weight value increases by 1.5. If a memory page is transferred from the active page list to the inactive page list, its popularity weight value decreases by 0.5. If a memory page is newly loaded into the LRU list, its popularity weight value is initialized to 1.
[0128] The execution device 4 is responsible for modifying the hotness weight value of the memory pages in the current LRU list according to the result of the judgment device, sorting the memory pages in the list from high to low according to the hotness weight value, and inserting the adjusted memory pages into the corresponding positions in the LRU list.
[0129] This invention employs an LRU (Least Recently Used) linked list iterative update strategy for dynamic adjustment and control, introducing a memory page popularity weight value. This allows for appropriate adjustments without disrupting the current upstream and downstream relationships within the LRU linked list. The beneficial effects of this invention include: 1. By introducing a memory page popularity weight value, the popularity weight of a memory page is accurately identified based on its access status, measuring the likelihood of that memory page being accessed in the next access cycle; 2. The dynamically changing parameters α, β, and γ, adjusted by the popularity weight value, allow for customized optimization strategies and solutions in different business environments; 3. The LRU linked list is sorted according to the popularity weight value, ensuring that memory pages with higher current popularity weight values are still more likely to be accessed in the next access cycle. Based on these adjustments, the granularity of memory page swapping control is optimized, precisely controlling the current memory page's position in the LRU linked list to increase the success rate of direct memory page hits in the next access cycle, thereby improving access efficiency and business performance.
[0130] In the aforementioned page scheduling system, each memory page is assigned a popularity weight value, which reflects the access frequency of the memory page. The more times it is accessed, the higher the popularity weight value. Based on the popularity weight value, the system can control whether the memory page is kept in the active page list or the inactive page list. Under the Linux system, the LRU list can be dynamically adjusted and controlled, and updated dynamically according to the actual memory page type and access frequency. This prevents memory pages that need to be accessed frequently from being pushed into the inactive page list or even reclaimed, thereby improving the business response speed.
[0131] For specific limitations regarding the page scheduling system, please refer to the limitations on the page scheduling method above, which will not be repeated here. Each module in the aforementioned page scheduling system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0132] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores page scheduling data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a page scheduling method.
[0133] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0134] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0135] Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list;
[0136] Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0137] The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list.
[0138] Based on the real-time popularity weight value of memory pages, the popularity weight value of memory pages in the current LRU list is modified, and the position of memory pages in the LRU list is adjusted.
[0139] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0140] Before the step of traversing the memory pages in the LRU linked list of the current system, setting each memory page to have a hotness weight value, and initializing the hotness weight values of the memory pages in the LRU linked list, the following steps are also included:
[0141] Configure the change in the heat weight value corresponding to the change in the position of the memory page in the active page list and the inactive page list;
[0142] Configure the initial heat weight value of newly loaded memory pages, and configure the newly loaded memory pages to be added to the list of inactive pages.
[0143] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0144] The steps for determining the change in the heat weight value corresponding to the change in the position of the configured memory page in the active page list and the inactive page list include:
[0145] Configure the memory page popularity weight value to increase by α. When a memory page is transferred from the inactive page list to the active page list, the popularity weight value of the memory page increases by α.
[0146] Configure a decrement β for the page popularity weight. When a page moves from the active page list to the inactive page list, the page popularity weight is reduced by β; where β < α.
[0147] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0148] The steps of configuring the initial heat weight value of newly loaded memory pages and configuring the newly loaded memory pages to be added to the inactive page list include:
[0149] Configure the initial heat weight of memory pages to γ. When a newly loaded memory page is added to the list of inactive pages, the heat weight of that memory page is initialized to γ; where γ < α.
[0150] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0151] The step of initializing the hotness weight value of memory pages in the LRU list includes:
[0152] The hotness weight value of all memory pages in the LRU list is assigned to γ.
[0153] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0154] The step of adjusting the position of the memory page in the LRU list includes:
[0155] In the linked list, memory pages are sorted in descending order based on their popularity weight value;
[0156] According to the limited number of memory pages in the active page list, memory pages that exceed the limited number at the end of the descending order in the active page list are obtained as memory pages to be pre-adjusted to the inactive page list, and then adjusted to the inactive page list.
[0157] According to the limited number of memory pages in the inactive page list, memory pages that exceed the limited number at the end of the descending order in the inactive page list are taken as memory pages to be pre-adjusted to be outside the inactive page list, and then adjusted to be outside the inactive page list.
[0158] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0159] After the step of adjusting memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the following is also included:
[0160] The heat weight value of memory pages that have been moved outside the inactive page list will be reset to zero.
[0161] For specific limitations on the steps a processor takes when executing a computer program, please refer to the limitations on page scheduling methods mentioned above, which will not be repeated here.
[0162] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0163] Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list;
[0164] Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list;
[0165] The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list.
[0166] Based on the real-time popularity weight value of memory pages, the popularity weight value of memory pages in the current LRU list is modified, and the position of memory pages in the LRU list is adjusted.
[0167] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0168] Before the step of traversing the memory pages in the LRU linked list of the current system, setting each memory page to have a hotness weight value, and initializing the hotness weight values of the memory pages in the LRU linked list, the following steps are also included:
[0169] Configure the change in the heat weight value corresponding to the change in the position of the memory page in the active page list and the inactive page list;
[0170] Configure the initial heat weight value of newly loaded memory pages, and configure the newly loaded memory pages to be added to the list of inactive pages.
[0171] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0172] The steps for determining the change in the heat weight value corresponding to the change in the position of the configured memory page in the active page list and the inactive page list include:
[0173] Configure the memory page popularity weight value to increase by α. When a memory page is transferred from the inactive page list to the active page list, the popularity weight value of the memory page increases by α.
[0174] Configure a decrement β for the page popularity weight. When a page moves from the active page list to the inactive page list, the page popularity weight is reduced by β; where β < α.
[0175] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0176] The steps of configuring the initial heat weight value of newly loaded memory pages and configuring the newly loaded memory pages to be added to the inactive page list include:
[0177] Configure the initial heat weight of memory pages to γ. When a newly loaded memory page is added to the list of inactive pages, the heat weight of that memory page is initialized to γ; where γ < α.
[0178] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0179] The step of initializing the hotness weight value of memory pages in the LRU list includes:
[0180] The hotness weight value of all memory pages in the LRU list is assigned to γ.
[0181] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0182] The step of adjusting the position of the memory page in the LRU list includes:
[0183] In the linked list, memory pages are sorted in descending order based on their popularity weight value;
[0184] According to the limited number of memory pages in the active page list, memory pages that exceed the limited number at the end of the descending order in the active page list are obtained as memory pages to be pre-adjusted to the inactive page list, and then adjusted to the inactive page list.
[0185] According to the limited number of memory pages in the inactive page list, memory pages that exceed the limited number at the end of the descending order in the inactive page list are taken as memory pages to be pre-adjusted to be outside the inactive page list, and then adjusted to be outside the inactive page list.
[0186] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:
[0187] After the step of adjusting memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the following is also included:
[0188] The heat weight value of memory pages that have been moved outside the inactive page list will be reset to zero.
[0189] For specific limitations on the steps implemented when a computer program is executed by a processor, please refer to the limitations on page scheduling methods mentioned above, which will not be repeated here.
[0190] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0191] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0192] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A page scheduling method, characterized in that, include: Configure the change in the heat weight value corresponding to the change in the position of the memory page in the active page list and the inactive page list; Configure the initial heat weight value of newly loaded memory pages, and configure the newly loaded memory pages to be added to the list of inactive pages; Traverse the memory pages in the LRU list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU list; Monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list; The real-time heat weight value of each memory page is determined based on the change in heat weight value corresponding to the change in position of the memory page in the active page list and the inactive page list. Based on the judgment result of the real-time hotness weight value of the memory page, the hotness weight value of the memory page in the current LRU list is modified, and the position of the memory page in the LRU list is adjusted. The step of configuring the change in the position of the memory page in the active page list and the inactive page list, corresponding to the change in the popularity weight value, includes: increasing the popularity weight value of the memory page by α, when the memory page moves from the inactive page list to the active page list, the popularity weight value of the memory page increases by α; decreasing the popularity weight value of the memory page by β, when the memory page moves from the active page list to the inactive page list, the popularity weight value of the memory page decreases by β; where β < α; The steps of configuring the initial heat weight value of the newly loaded memory page and configuring the newly loaded memory page to be added to the inactive page list include: configuring the memory page to initialize the heat weight value as γ, and when the newly loaded memory page is added to the inactive page list, the heat weight value of the memory page is initialized to γ; where γ < α; The step of initializing the hotness weight value of memory pages in the LRU list includes: assigning the hotness weight value of all memory pages in the LRU list to γ.
2. The page scheduling method according to claim 1, characterized in that, The step of adjusting the position of the memory page in the LRU list includes: In the linked list, memory pages are sorted in descending order based on their popularity weight value; According to the limited number of memory pages in the active page list, memory pages that exceed the limited number at the end of the descending order in the active page list are obtained as memory pages to be pre-adjusted to the inactive page list, and then adjusted to the inactive page list. According to the limited number of memory pages in the inactive page list, memory pages that exceed the limited number at the end of the descending order in the inactive page list are taken as memory pages to be pre-adjusted to be outside the inactive page list, and then adjusted to be outside the inactive page list.
3. The page scheduling method according to claim 2, characterized in that, After the step of adjusting memory pages pre-adjusted to be outside the inactive page list to be outside the inactive page list, the following is also included: The heat weight value of memory pages that have been moved outside the inactive page list will be reset to zero.
4. A page scheduling system, characterized in that, The system for implementing the page scheduling method according to any one of claims 1 to 3, the system comprising: An initialization device is used to traverse the memory pages in the LRU linked list under the current system, set a hot weight value for each memory page, and initialize the hot weight values of the memory pages in the LRU linked list. The monitoring device is used to monitor the position change data of each memory page in the LRU list in the active page list and the inactive page list; The judgment device is used to judge the real-time heat weight value of each memory page based on the heat weight value change value corresponding to the position change data of the memory page in the active page list and the inactive page list. An execution device is used to modify the hotness weight value of memory pages in the current LRU list based on the judgment result of the real-time hotness weight value of memory pages, and to adjust the position of memory pages in the LRU list.
5. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
LRU flash memory cache management method based on dynamic page weight
CN109857680A
Page caching method based on B / S architecture, device, equipment and medium
CN111737616A