Hot and cold page statistics method and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA (CHINA) CO LTD
- Filing Date
- 2022-03-03
- Publication Date
- 2026-06-23
Smart Images

Figure CN114579404B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of computer technology, and in particular to a method for counting hot and cold pages. Background Technology
[0002] In cloud computing scenarios, identifying hot and cold pages in memory is crucial for improving memory resource utilization and reducing costs. Random access memory (RAM), also known as main memory, is an internal memory that directly exchanges data with the CPU. It can be read and written at any time and is very fast, typically serving as temporary data storage for the operating system or other running programs. Based on the working principle of its storage units, RAM is further divided into static random access memory (SRAM) and dynamic random access memory (DRAM). As data volumes continue to increase and memory-intensive applications become more prevalent, DRAM is gradually becoming insufficient to meet application demands. Emerging storage devices offer higher storage density, lower prices, and lower power consumption, but they suffer from higher latency and limited lifespan, and cannot directly replace DRAM. For example, non-volatile memory (NVM) is a type of memory that retains data even after power is lost. It is non-volatile, accessed byte-by-byte, has high storage density, low power consumption, and read / write performance close to DRAM, but its read / write speeds are asymmetrical, and its lifespan is limited. By combining this novel storage device with DRAM to form hybrid memory, the advantages of both can be effectively utilized. One approach is to integrate DRAM and NVM into a unified address space, where data resides either in DRAM or NVM. Because DRAM and NVM have different latency, storing more frequently accessed hot data in DRAM can significantly reduce the average memory access latency. As programs run, the hot data of an application is not static; the hotness or coldness of data can change at any time. Therefore, it is necessary to migrate data according to changes in hotness, ensuring that more frequently accessed data is always stored in DRAM. Accurately identifying hot and cold data is a crucial problem that needs to be solved. Summary of the Invention
[0003] In view of this, embodiments of this specification provide a method for counting hot and cold pages. One or more embodiments of this specification also relate to a device for counting hot and cold pages, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0004] According to a first aspect of the embodiments of this specification, a hot and cold page statistics method is provided, applied to a hot and cold page identification module of a memory controller, comprising:
[0005] In response to a memory access instruction sent by the processor, an access record for the initial memory page is generated according to the memory access instruction;
[0006] Update the access count of the initial memory page in the data list according to the access record;
[0007] Cold or hot memory pages are determined based on the number of accesses to the initial memory pages in the data list.
[0008] According to a second aspect of the embodiments of this specification, a hot and cold page counting device is provided, applied to a hot and cold page identification module of a memory controller, comprising:
[0009] The memory access record unit is configured to generate an access record for an initial memory page in response to a memory access instruction sent by the processor.
[0010] The popularity sorting unit is configured to update the access count of the initial memory page in the data list based on the access record;
[0011] The access control unit is configured to determine whether a memory page is cold or hot based on the number of accesses to the initial memory page in the data list.
[0012] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising:
[0013] Memory and processor;
[0014] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the above-described hot and cold page statistics method.
[0015] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions that, when executed by a processor, implement the steps of the above-described hot and cold page statistics method.
[0016] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described hot and cold page statistics method.
[0017] This specification provides a method and apparatus for hot and cold page statistics, applied to a hot and cold page identification module of a memory controller. The method includes: responding to a memory access instruction sent by the processor; generating an access record for an initial memory page based on the memory access instruction; updating the access count of the initial memory page in a data list based on the access record; and determining whether the memory page is a cold or hot memory page based on the access count of the initial memory page in the data list. By acquiring the memory access instruction sent by the processor, actual memory accesses can be detected, avoiding miscounting cached accesses as memory accesses. Furthermore, since each memory access can be statistically recorded through the access record, probabilistic errors during sampling and statistics are avoided, thereby improving the accuracy of hot and cold page identification. Attached Figure Description
[0018] Figure 1a This is a schematic diagram illustrating a scenario of a hot and cold page statistics method provided in one embodiment of this specification;
[0019] Figure 1b This is a schematic diagram of another scenario of a hot and cold page statistics method provided in one embodiment of this specification;
[0020] Figure 2 This is a flowchart illustrating a hot and cold page statistics method provided in one embodiment of this specification;
[0021] Figure 3 This is a flowchart illustrating the processing procedure of a hot and cold page statistics method provided in one embodiment of this specification;
[0022] Figure 4 This is a schematic diagram of the structure of a hot and cold page counting device provided in one embodiment of this specification;
[0023] Figure 5 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0024] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0025] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0026] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0027] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0028] Hot pages: When a business workload needs to access memory during runtime, the memory pages that are accessed frequently are called hot pages.
[0029] Cold pages: When a business workload needs to access memory during runtime, memory pages that are accessed less frequently are called cold pages.
[0030] Memory controller: A control module that receives requests from the CPU (Central Processing Unit) to access / read / write memory.
[0031] Processor: refers to the central processing unit (CPU), which is the core of a computer system for operation and control, and is the final execution unit for information processing and program execution.
[0032] Memory: One of the important components of a computer, also known as internal memory or main memory, it is used to temporarily store data processed by the CPU and data exchanged with external storage devices such as hard drives.
[0033] DRAM: Dynamic Random Access Memory (DRAM) is a type of semiconductor memory. Its main working principle is to use the amount of charge stored in a capacitor to represent whether a binary bit is 1 or 0.
[0034] NVM stands for Non-volatile memory. It features non-volatility, byte-by-byte access, high storage density, low power consumption, and read / write performance close to DRAM, but with asymmetrical read / write speeds and a limited lifespan.
[0035] A min-heap is a sorted complete binary tree in which the value of any non-terminal node is no greater than the values of its left and right children.
[0036] This specification provides a method for counting hot and cold pages, and also relates to a device for counting hot and cold pages, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0037] See Figure 1a , Figure 1a This is a schematic diagram illustrating a scenario of a hot and cold page statistics method provided in one embodiment of this specification. The application scenario may include a processor 110, a memory controller 120, and memory 130.
[0038] The processor 110 sends memory access information, and the memory controller 120 performs read and write operations on the memory 130 according to the memory access information sent by the processor 110. The memory controller 120 includes a hot / cold page identification module 121 and a memory access module 122. The memory access module 122 is used to read and write memory 130. The hot / cold page identification module 121 includes a memory access record unit 1211, a hotness sorting unit 1212, and an access control unit 1213. The memory access record unit 1211 is responsible for intercepting the memory access information sent by the processor 110 to the memory controller 120. The hotness sorting unit 1212 manages two min-heap structures (one for reading and one for writing), using the page number of memory 130 as the key and the access count as the value. Whenever a new access record is delivered, the access count is increased according to the key value, and the min-heap is updated at the same time. The access control unit 1213 is responsible for interacting with the software, providing an mmio interface, receiving configuration for the hot / cold page identification module 121, and returning the min-heap information of hot and cold pages.
[0039] When the processor 110 sends memory access information to the memory controller 120, the memory access record unit 1211 intercepts the memory access information sent by the processor 110 to the memory controller 120. The memory access information includes HPA (physical address), RW (read or write), and Size information. Based on the memory access information, an access record in the form of (memory page number, read or write) can be generated and sent to the hot ranking unit 1212. The hot ranking unit 1212 puts the record into the corresponding min-heap structure according to the read or write in (memory page number, read or write), and increases the access count of the corresponding memory page 130 according to the memory page number in the structure.
[0040] See Figure 1b , Figure 1b This is a schematic diagram illustrating another scenario of a hot and cold page statistics method provided in one embodiment of this specification. This application scenario may include an application program 140, a hot and cold page management kernel module 150, and a memory controller 120.
[0041] The hot and cold page management kernel module 150 includes a proc interface 151, an ioctl interface 152, an mmio interface 153, and reserved memory 154. The reserved memory 154 is a block of memory reserved for system startup as a storage area for memory access records. The mmio interface 153 is used to set parameters for the access control module or to read hot and cold page information. The proc interface 151 / ioctl interface 152 provides an interactive interface for users in the application 140. Users can set the granularity of hot and cold page identification and the address range through the application 140, and can also read hot and cold page information. The memory controller 120 includes a hot and cold page identification module 121 and a memory access module 122.
[0042] The hot and cold page identification module 121 in the memory controller 120 stores hot and cold page data records in the reserved memory 154. An application 140 retrieves hot and cold page information from the reserved memory 154 of the hot and cold page management kernel module 150 via the proc interface 151. The application 140 can also request configuration information from the hot and cold page identification module 121 via the proc interface 151. The hot and cold page identification module 121 then sends the configuration information to the hot and cold page management kernel module 150 via the mmio interface 153. If the application 140 modifies the configuration, it sends the new configuration information to the hot and cold page management kernel module 150, which then sends the new configuration information to the hot and cold page identification module 121 via the mmio interface 153 for application.
[0043] See Figure 2 , Figure 2A flowchart of a hot and cold page statistics method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0044] Step 202: In response to a memory access instruction sent by the processor, generate an access record for the initial memory page according to the memory access instruction.
[0045] The initial memory page can be a memory page in a memory device, for example, the initial memory page is 100 pages, and the granularity of each memory page is 2 megabytes (M); the access record can be understood as the record of the processor's requests for memory pages, for example, the record of the read request for the 20th memory page.
[0046] In practical applications, identifying hot and cold pages in cloud computing scenarios is crucial for improving memory resource utilization and reducing costs. By placing hot pages in DRAM and cold pages in NVM, memory usage costs can be effectively reduced. Therefore, accurately distinguishing between hot and cold pages is a key issue. A hot and cold page identification module can be set up in the memory controller. This module intercepts memory access information (memory access instructions) sent by the processor to the memory controller, processes the memory access information, and generates access records.
[0047] In summary, when the processor sends a memory access instruction to the memory controller, the instruction is parsed to obtain the physical address information, whether it's a read or write operation, and the size of the read or write operation. Based on the content of the memory access instruction, an access record for the initial memory page is generated. For example, if the physical address information in the memory access instruction is from address A1 to address B1, and it's a write operation on a memory page with a size of 5 megabytes (meaning 5 megabytes of data are written), an access record is generated based on the address range (A1 to B1), the write operation, and the 5 megabytes of data written.
[0048] The embodiments in this specification generate access records for memory pages based on memory access instructions sent by the processor, avoiding miscounting cache accesses as memory accesses and thus improving the accuracy of the statistics.
[0049] Specifically, the step of responding to a memory access instruction sent by the processor and generating an access record for an initial memory page according to the memory access instruction includes:
[0050] Get the memory access instructions sent by the processor;
[0051] Parse the memory access instructions to obtain memory page access information;
[0052] An access record for the initial memory page is generated based on the memory page access information.
[0053] In this context, obtaining the memory access instructions sent by the processor can be understood as intercepting the memory access instructions sent by the processor. For example, when the processor sends a memory access instruction to the memory controller, under normal circumstances, the memory access module in the memory controller will receive the memory access instruction sent by the processor and then modify the corresponding memory page according to the memory access instruction. However, in this embodiment of the specification, the memory access instructions sent by the processor to the memory controller are intercepted.
[0054] The memory page access information may include physical address information, information about read or write operations, and information about the size of the read or write operation. For example, in the above embodiment, the physical address information is from address A1 to address B1, and the size of the write operation to the memory page is 5 megabytes.
[0055] For example, when the processor sends a memory access instruction to the memory controller, the instruction can be intercepted, parsed, and the physical address information (addresses A1 to B1) can be obtained. The instruction is for a write operation to a memory page, and the size of the write operation is 5 megabytes. Based on the physical address information (addresses A1 to B1), the memory page write operation, and the size of the write operation (5 megabytes), it can be determined which memory page to write 5 megabytes of data to, and an access record for that memory page can be generated.
[0056] The embodiments in this specification generate access records for memory pages based on memory access instructions sent by the processor. Each memory access can be statistically recorded through the access records, which improves the accuracy of the statistics.
[0057] Further, the step of generating an access record for the initial memory page based on the memory page access information includes:
[0058] The initial memory page is determined based on the memory page address information and memory page size information in the memory page access information;
[0059] The read or write operation is determined based on the read / write information in the memory page access information;
[0060] Based on the read operation or the write operation, an access record for the initial memory page is generated, wherein the access record carries the identifier of the initial memory page.
[0061] The memory page address information can be the physical address information of the memory page, such as addresses A1 to B1 in the above embodiment; the memory page size information can be the size of the data written to the memory page, such as the size of the write operation in the above embodiment being 5 megabytes; the read / write information can be the information of writing or reading operations on the memory page; the identifier of the initial memory page can be a character, number, or other identifier, for example, when there are 100 initial memory pages, the identifier of the initial memory page can be 1 to 100.
[0062] Continuing with the previous example, there are 100 initial memory pages, each with a granularity of 2 megabytes. Correspondingly, the initial memory pages are identified as 1-100, and their physical address information is from A1 to B1. Write operations on memory pages are performed with a size of 5 megabytes. Based on the physical address information (A1 to B1) and the statement "5 megabytes of data written," memory pages 20, 21, and 22 are identified. According to the read / write information, "write operation on memory page," data is written to the memory page, so the generated access records are (20, write operation), (21, write operation), and (22, write operation).
[0063] In the embodiments of this specification, when identifying hot and cold pages, read and write information are taken into account. Corresponding access records are generated through read or write operations. Thus, cold or hot pages of read operations can be obtained as needed, and cold or hot pages of write operations can also be obtained as needed, thereby improving the usability of this solution.
[0064] Step 204: Update the access count of the initial memory page in the data list according to the access record.
[0065] The data list can be a list that includes the access counts of all memory pages. For example, the data list can include 100 data entries, each corresponding to one of the 100 memory pages. The access count can be understood as the number of times a memory page is read or written. For example, the 20th memory page is accessed 53 times.
[0066] In practical applications, the hot / cold page identification module also includes a popularity sorting unit, which updates the access count through access records and puts the access count of each memory page into a list. The list makes it easy to find the target data you want, which means you can quickly identify a cold page or a hot page.
[0067] For example, if there are 100 memory pages initially, and the access records include (20, write operation), (21, write operation), and (22, write operation), the access counts of the 20th, 21st, and 22nd memory pages in the data list can be updated based on (20, write operation), (21, write operation), and (22, write operation).
[0068] The embodiments in this specification improve the accuracy of memory page access counts by obtaining memory access instructions sent by the processor and determining the number of accesses based on the memory access instructions, thereby improving the accuracy of hot and cold page identification.
[0069] Specifically, updating the access count of the initial memory page in the access record data list includes:
[0070] The target data list is determined based on the read or write operations in the access record;
[0071] Update the access count of the initial memory page in the target data list according to the identifier of the initial memory page.
[0072] The target data list can be one of multiple data lists. For example, if read data lists and write data lists are created based on read and write operations on memory pages, the target data list can be any one of the read data lists and write data lists.
[0073] In practical applications, separate data lists can be created for read and write operations on memory pages to manage the access records of read and write operations respectively. The access records of read operations on memory pages are placed in the read operation data list, and the access records of write operations on memory pages are placed in the write operation data list.
[0074] Continuing with the previous example, the initial number of memory pages is 100. The access records include (20, write operation), (21, write operation), and (22, write operation). The target data list can be determined as the write operation data list. Based on the identifiers of the initial memory pages in (20, write operation), (21, write operation), and (22, write operation): 20, 21, and 22, the access counts of the 20th, 21st, and 22nd memory pages in the write operation data list can be updated. Specifically, the 20th memory page has been accessed 15 times, the 21st memory page has been accessed 28 times, and the 22nd memory page has been accessed 100 times. Therefore, the access counts of the 20th, 21st, and 22nd memory pages are incremented by 1. The updated results are: the 20th memory page has been accessed 16 times, the 21st memory page has been accessed 29 times, and the 22nd memory page has been accessed 101 times.
[0075] The embodiments in this specification separate the hot and cold pages for read operations from those for write operations in the memory controller for more precise statistics on memory access, thereby enabling targeted memory access optimization for different types of workloads.
[0076] When determining the target data list, it can be determined based on read and write operations on memory pages, as described in the following specific implementation method.
[0077] Further, determining the target data list based on the read operation or the write operation in the access record includes:
[0078] A list of read data is determined based on the read operations in the access record, and a list of write data is determined based on the write operations in the access record.
[0079] The read data list can store access records for reading operations on memory pages, and the write data list can store access records for writing operations on memory pages. For example, read data lists and write data lists can be created based on read and write operations on memory pages, respectively.
[0080] In practical applications, a minimum heap structure can be created for each type of memory page operation, based on read and write operations. This structure manages the access records for read and write operations respectively. The access records for read operations are placed in the read operation minimum heap structure, and the access records for write operations are placed in the write operation minimum heap structure.
[0081] In one feasible approach, with 100 initial memory pages and access records including (30, read operation), (31, read operation), and (32, read operation), the target data list can be determined as a read operation min-heap structure. Based on the identifiers of the initial memory pages in (30, read operation), (31, read operation), and (32, read operation): 30, 31, and 32, the access counts of the 30th, 31st, and 32nd memory pages in the read operation min-heap structure can be updated. The 30th memory page was accessed 15 times, the 31st memory page was accessed 28 times, and the 32nd memory page was accessed 100 times. Therefore, the access counts of the 30th, 31st, and 32nd memory pages are incremented by 1. The updated result is that the 30th memory page was accessed 16 times, the 31st memory page was accessed 29 times, and the 32nd memory page was accessed 101 times.
[0082] In another possible implementation, the initial memory pages are 100, and the access records include (20, write operation), (21, write operation), and (22, write operation). The target data list can be determined as a write-operation min-heap structure. Based on the identifiers of the initial memory pages in (20, write operation), (21, write operation), and (22, write operation): 20, 21, and 22, the access counts of the 20th, 21st, and 22nd memory pages in the write-operation min-heap structure can be updated. Specifically, the 20th memory page has been accessed 15 times, the 21st memory page 28 times, and the 22nd memory page 100 times. Therefore, the access counts of the 20th, 21st, and 22nd memory pages are incremented by 1, resulting in an updated access count of 16 times for the 20th memory page, 29 times for the 21st memory page, and 101 times for the 22nd memory page.
[0083] The embodiments in this specification implement accurate memory access frequency statistics through hardware, which can provide accurate hot and cold page information, facilitating other components to make correct paging decisions.
[0084] Furthermore, weights can be set for different memory pages so that some memory pages are accessed a different number of times even when they are accessed the same number of times. The specific implementation method is as follows.
[0085] The step of updating the access count of the initial memory page in the target data list according to the identifier of the initial memory page includes:
[0086] The access weight is determined based on the identifier of the initial memory page;
[0087] The number of accesses to the initial memory page is increased according to the access weight.
[0088] The access weight can be a weight that increases the number of accesses. For example, if the access weight of memory page A is 2, then if memory page A is accessed once, its access count will increase by 2.
[0089] In practical applications, some memory pages may need to be accessed faster than others, so they need to be kept in DRAM. However, these pages may not be accessed very often. In this case, an access weight can be set for the page, so that the number of accesses increases exponentially with the actual access volume.
[0090] For example, if the access records include (20, write operation), (21, write operation), and (22, write operation), the target data list can be determined to be a write-operation min-heap structure. Based on the initial memory page identifiers in (20, write operation), (21, write operation), and (22, write operation): 20, 21, 22, the access counts of the 20th, 21st, and 22nd memory pages in the data list can be updated. Specifically, the 20th memory page has 15 accesses with a weight of 2, the 21st memory page has 28 accesses with a weight of 1, and the 22nd memory page has 100 accesses with a weight of 1. Therefore, the access count of the 20th memory page is incremented by 2, and the access counts of the 21st and 22nd memory pages are incremented by 1. The updated result is that the 20th memory page has 17 accesses and the 21st memory page has 29 accesses.
[0091] The embodiments in this specification add access weights to memory pages, which can be precisely adjusted for a specific memory page, thus improving the universality of the solution.
[0092] Step 206: Determine whether a memory page is cold or hot based on the number of accesses to the initial memory page in the data list.
[0093] Here, cold memory pages or hot memory pages can be memory pages determined in the data list based on their location, or they can be memory pages determined in the data list based on the number of accesses. For example, if a cold memory page or a hot memory page is a memory page determined in the data list based on the number of accesses, and memory page A is accessed 20 times and memory page B is accessed 30 times, then memory page B is determined to be a hot page.
[0094] In practical applications, it is possible to determine which memory pages are hot pages and which are cold pages as needed. This can be done by setting a threshold or by determining the position of a page in a data list. This specification does not limit the scope of the embodiments.
[0095] One feasible approach to determine a cold or hot page based on its position in the data list is described below.
[0096] The step of determining a cold or hot memory page based on the access count of the initial memory page in the data list includes:
[0097] Sort all data in the data list according to the number of accesses to the initial memory page to obtain the updated data list;
[0098] The cold or hot memory page is determined based on the updated data list.
[0099] The updated data list can be understood as the list after being sorted according to the number of accesses. For example, the data list includes memory page A, memory page B, and memory page C. The order before sorting is memory page A, memory page B, and memory page C. After sorting the sorted list according to the number of accesses, the updated data list is obtained as memory page A, memory page C, and memory page B.
[0100] For example, the data list includes the first memory page being accessed 15 times, the second memory page being accessed 15 times, and the third memory page being accessed 17 times. After the first memory page is accessed, the second memory page is accessed 16 times. Based on the access count, all data in the data list is sorted in descending order. The updated data list is as follows: the third memory page, the first memory page, and the second memory page. If the first page in the list is determined to be the hot page, then the third memory page is also a hot page.
[0101] One feasible approach to determine cold or hot pages by setting a threshold is described below.
[0102] The step of determining cold or hot memory pages based on the updated data list includes:
[0103] The corresponding memory page identifier is determined based on the number of accesses and the preset threshold number in the updated data list;
[0104] The corresponding cold or hot memory page is determined based on the memory page identifier.
[0105] For example, the updated data list includes access records (20, write operation), (21, write operation), and (22, write operation). The 20th memory page is accessed 15 times, the 21st memory page is accessed 28 times, and the 22nd memory page is accessed 100 times. The preset threshold for access counts is 50 times. Therefore, the memory page identifier is determined to be 22. Based on the memory page identifier 22, the 22nd memory page can be identified as a hot page.
[0106] Furthermore, prior to responding to the memory access instruction sent by the processor, the method also includes:
[0107] The data modification instruction is received from the management module through a mapping interface, wherein the management module receives the data modification instruction from the terminal through a data interaction interface;
[0108] The initial memory page granularity, the address of the initial memory page, or a preset number of times threshold is modified according to the data modification instruction, wherein the spatial information of the initial memory page is determined based on the granularity of the initial memory page.
[0109] The mapping interface is used to set parameters or read memory page information, for example, it can be an mmio interface; the data interaction interface is used to receive or send data to the client, for example, a proc interface or an ioctl interface.
[0110] In practical applications, staff can set the granularity of memory pages, such as 4 kilobytes or 2 megabytes. They can also set the mapping between the virtual address and the physical address of the memory page. In addition, they can set a preset threshold number of times to determine which memory pages are hot pages or cold pages.
[0111] Furthermore, after determining whether a memory page is cold or hot based on the number of accesses to the data list, the method further includes:
[0112] The data acquisition instruction is received from the management module through a mapping interface, wherein the management module receives the data acquisition instruction from the terminal through a data interaction interface;
[0113] The target data is returned to the management module according to the data acquisition instruction and the data list, wherein the management module sends the target data to the terminal through the data interaction interface.
[0114] In practical applications, staff can request data from a data list, for example, to view all data in the data list, or to extract information about cold and hot pages.
[0115] It should be noted that the mapping interface in the embodiments of this specification may also include a data clearing function. For example, receiving a data clearing instruction can clear the data in the data list and then re-count the number of memory accesses. In this way, cold pages or hot pages within a certain period of time can be counted.
[0116] This specification provides a method for identifying hot and cold pages. The method includes: responding to a memory access instruction sent by a processor; generating an access record for an initial memory page based on the memory access instruction; updating the access count of the initial memory page in a data list based on the access record; and determining whether the memory page is a cold or hot memory page based on the access count of the initial memory page in the data list. By obtaining the memory access instruction sent by the processor, actual memory accesses can be detected, avoiding miscounting cached accesses as memory accesses. Furthermore, since each memory access can be recorded in the access record, probabilistic errors during sampling and statistics are avoided, thereby improving the accuracy of hot and cold page identification.
[0117] See Figure 3 , Figure 3 The present specification illustrates a process flowchart of a hot and cold page statistics method according to an embodiment of this specification, which specifically includes the following steps.
[0118] Step 302: The memory controller receives the memory access instruction sent by the processor.
[0119] In this context, obtaining the memory access instructions sent by the processor can be understood as intercepting the memory access instructions sent by the processor. For example, when the processor sends a memory access instruction to the memory controller, under normal circumstances, the memory access module in the memory controller will receive the memory access instruction sent by the processor and then modify the corresponding memory page according to the memory access instruction. However, in this embodiment of the specification, the memory access instructions sent by the processor to the memory controller are intercepted.
[0120] For example, intercepting a memory access instruction when the processor sends it to the memory controller.
[0121] Step 304: The memory controller parses memory access instructions to obtain memory page access information.
[0122] The memory page access information may include physical address information, information about read or write operations, and information about the size of the read or write operation. For example, in the above embodiment, the physical address information is from address A1 to address B1, and the size of the write operation to the memory page is 5 megabytes.
[0123] For example, parsing memory access instructions yields physical address information from address A1 to address B1, and the write operation to a memory page has a size of 5 megabytes.
[0124] Step 306: The memory controller determines the initial memory page based on the memory page address information and memory page size information in the memory page access information.
[0125] The memory page address information can be the physical address information of the memory page, such as address A1 to address B1 in the above embodiment; the memory page size information can be the size of the data written to the memory page, such as the size of the write operation in the above embodiment being 5 megabytes.
[0126] For example, based on physical address information A1 to B1, a write operation to a memory page, and a write operation size of 5 megabytes, it can be determined which memory page to write 5 megabytes of data to, thus generating an access record for that memory page. Initially, there are 100 memory pages, each with a granularity of 2 megabytes. Correspondingly, the initial memory pages are identified as 1-100, with physical address information A1 to B1, and a write operation size of 5 megabytes. Based on the "physical address information A1 to B1" and "writing 5 megabytes of data," the 20th, 21st, and 22nd memory pages are determined.
[0127] Step 308: The memory controller determines whether to perform a read or write operation based on the read / write information in the memory page access information.
[0128] The read / write information can be information about writing to or reading from memory pages.
[0129] Using the previous example, based on the read / write information: "write operation to memory page", it is determined that data is being written to a memory page.
[0130] Step 310: The memory controller generates an access record for the initial memory page based on the read or write operation, wherein the access record carries the identifier of the initial memory page.
[0131] The identifier of the initial memory page can be a character, a number, or other identifier. For example, if there are 100 initial memory pages, the identifier of the initial memory page can be from 1 to 100.
[0132] Using the previous example, based on the read / write information "write operation to memory page", it is determined that data is written to the memory page, so the generated access records are (20, write operation), (21, write operation) and (22, write operation).
[0133] Step 312: The memory controller determines the target data list based on the read or write operations in the access record.
[0134] The target data list can be one of multiple data lists. For example, if read data lists and write data lists are created based on read and write operations on memory pages, the target data list can be any one of the read data lists and write data lists.
[0135] For example, if the initial memory pages are 100 and the access records include (20, write operation), (21, write operation) and (22, write operation), the target data list can be determined to be a minimum heap structure for write operations.
[0136] Step 314: The memory controller updates the access count of the initial memory page in the target data list based on the identifier of the initial memory page.
[0137] In practical applications, a minimum heap structure can be created for each type of memory page operation, based on read and write operations. This structure manages the access records for read and write operations respectively. The access records for read operations are placed in the read operation minimum heap structure, and the access records for write operations are placed in the write operation minimum heap structure.
[0138] For example, based on the initial memory page identifiers 20, 21, and 22 in (20, write operation), we can update the access counts of the 20th, 21st, and 22nd memory pages in the min-heap structure of write operations. The 20th memory page has been accessed 15 times, the 21st memory page 28 times, and the 22nd memory page 100 times. Increasing the access counts of these three memory pages by 1 results in an updated count of 16 for the 20th memory page, 29 for the 21st, and 101 for the 22nd.
[0139] Step 316: Sort all data in the data list according to the access count of the initial memory page to obtain the updated data list.
[0140] The updated data list can be understood as the list after being sorted according to the number of accesses. For example, the data list includes memory page A, memory page B, and memory page C. The order before sorting is memory page A, memory page B, and memory page C. After sorting the sorted list according to the number of accesses, the updated data list is obtained as memory page A, memory page C, and memory page B.
[0141] Using the previous example, the updated data list shows that the 20th memory page was accessed 16 times, the 21st memory page was accessed 29 times, and the 22nd memory page was accessed 101 times. Sort all data in the data list in descending order based on the access count, and the updated data list will then contain: the 22nd memory page, the 21st memory page, and the 20th memory page.
[0142] Step 318: Determine whether a memory page is cold or hot based on the updated data list.
[0143] For example, the updated data list includes access records (20, write operation), (21, write operation), and (22, write operation). The 20th memory page is accessed 16 times, the 21st memory page is accessed 29 times, and the 22nd memory page is accessed 101 times. The preset threshold for access counts is 50 times. Therefore, the memory page identifier is determined to be 22. Based on the memory page identifier 22, the 22nd memory page can be identified as a hot page.
[0144] The embodiments in this specification can detect real memory access by acquiring memory access instructions sent by the processor, avoiding miscounting cache access as memory access. Furthermore, since each memory access can be statistically recorded through access records, probabilistic errors that may occur during sampling and statistics are avoided, thereby improving the accuracy of hot and cold page identification.
[0145] Corresponding to the above method embodiments, this specification also provides embodiments of a hot and cold slate counting device. Figure 4 A schematic diagram of a hot and cold slate counting device according to one embodiment of this specification is shown. Figure 4 As shown, the device includes:
[0146] The memory access record unit 402 is configured to generate an access record for an initial memory page in response to a memory access instruction sent by the processor.
[0147] The popularity sorting unit 404 is configured to update the access count of the initial memory page in the data list according to the access record;
[0148] Access control unit 406 is configured to determine whether a memory page is cold or hot based on the number of accesses to the initial memory page in the data list.
[0149] Optionally, the memory access record unit 402 is also configured as follows:
[0150] Get the memory access instructions sent by the processor;
[0151] Parse the memory access instructions to obtain memory page access information;
[0152] An access record for the initial memory page is generated based on the memory page access information.
[0153] Optionally, the memory access record unit 402 is also configured as follows:
[0154] The initial memory page is determined based on the memory page address information and memory page size information in the memory page access information;
[0155] The read or write operation is determined based on the read / write information in the memory page access information;
[0156] Based on the read operation or the write operation, an access record for the initial memory page is generated, wherein the access record carries the identifier of the initial memory page.
[0157] Optionally, the popularity ranking unit 404 is also configured as follows:
[0158] The target data list is determined based on the read or write operations in the access record;
[0159] Update the access count of the initial memory page in the target data list according to the identifier of the initial memory page.
[0160] Optionally, the popularity ranking unit 404 is also configured as follows:
[0161] A list of read data is determined based on the read operations in the access record, and a list of write data is determined based on the write operations in the access record.
[0162] Optionally, the popularity ranking unit 404 is also configured as follows:
[0163] The access weight is determined based on the identifier of the initial memory page;
[0164] The number of accesses to the initial memory page is increased according to the access weight.
[0165] Optionally, the popularity ranking unit 404 is also configured as follows:
[0166] Sort all data in the data list according to the number of accesses to the initial memory page to obtain the updated data list;
[0167] The cold or hot memory page is determined based on the updated data list.
[0168] Optionally, the access control unit 406 is also configured to:
[0169] The corresponding memory page identifier is determined based on the number of accesses and the preset threshold number in the updated data list;
[0170] The corresponding cold or hot memory page is determined based on the memory page identifier.
[0171] Optionally, the hot and cold page statistics device also includes an interactive module, configured to:
[0172] The data modification instruction is received from the management module through a mapping interface, wherein the management module receives the data modification instruction from the terminal through a data interaction interface;
[0173] The initial memory page granularity, the address of the initial memory page, or a preset number of times threshold is modified according to the data modification instruction, wherein the spatial information of the initial memory page is determined based on the granularity of the initial memory page.
[0174] Optionally, the interaction module is also configured as follows:
[0175] The data acquisition instruction is received from the management module through a mapping interface, wherein the management module receives the data acquisition instruction from the terminal through a data interaction interface;
[0176] The target data is returned to the management module according to the data acquisition instruction and the data list, wherein the management module sends the target data to the terminal through the data interaction interface.
[0177] This specification provides a hot / cold page statistics device. The device responds to a memory access instruction sent by a processor, generates an access record for an initial memory page based on the instruction, updates the access count of the initial memory page in a data list based on the access record, and determines whether the memory page is hot or cold based on the access count. By acquiring the memory access instruction sent by the processor, genuine memory accesses can be detected, avoiding miscounting cached accesses as memory accesses. Furthermore, since each memory access can be statistically recorded, probabilistic errors during sampling and statistics are avoided, thereby improving the accuracy of hot / cold page identification.
[0178] The above is a schematic scheme of a hot and cold page counting device according to this embodiment. It should be noted that the technical solution of this hot and cold page counting device and the technical solution of the hot and cold page counting method described above belong to the same concept. For details not described in detail in the technical solution of the hot and cold page counting device, please refer to the description of the technical solution of the hot and cold page counting method described above.
[0179] Figure 5 A structural block diagram of a computing device 500 according to one embodiment of this specification is shown. The components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and a database 550 is used to store data.
[0180] The computing device 500 also includes an access device 540, which enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0181] In one embodiment of this specification, the above-described components of the computing device 500 and Figure 5 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 5 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0182] The computing device 500 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 500 can also be a mobile or stationary server.
[0183] The processor 520 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the database processing method described above.
[0184] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the hot and cold page statistics method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the hot and cold page statistics method described above.
[0185] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described hot and cold page statistics method.
[0186] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the hot and cold page statistics method described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the hot and cold page statistics method described above.
[0187] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described hot and cold page statistics method.
[0188] The above is an illustrative example of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solution of the aforementioned hot and cold page statistics method. Details not described in detail in the computer program's technical solution can be found in the description of the technical solution of the aforementioned hot and cold page statistics method.
[0189] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0190] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0191] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0192] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0193] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A method for counting hot and cold pages, applied to a hot and cold page identification module of a memory controller, the method comprising: In response to a memory access instruction sent by the processor, an access record for the initial memory page is generated according to the memory access instruction; The access weight is determined based on the identifier of the initial memory page, and the access count of the initial memory page in the data list is updated based on the access weight; The data list is a minimum heap structure built based on read and write operations on memory pages; the access weight is the weight that increases the number of accesses. Sort all data in the data list according to the number of accesses to the initial memory page in the data list to obtain the updated data list; Based on the number of accesses in the updated data list and the preset access threshold, cold memory pages or hot memory pages are determined.
2. The method according to claim 1, wherein generating an access record for an initial memory page in response to a memory access instruction sent by the processor comprises: Get the memory access instructions sent by the processor; Parse the memory access instructions to obtain memory page access information; An access record for the initial memory page is generated based on the memory page access information.
3. The method according to claim 2, wherein generating an access record for the initial memory page based on the memory page access information comprises: The initial memory page is determined based on the memory page address information and memory page size information in the memory page access information; The read or write operation is determined based on the read / write information in the memory page access information; Based on the read operation or the write operation, an access record for the initial memory page is generated, wherein the access record carries the identifier of the initial memory page.
4. The method according to claim 3, wherein updating the access count of the initial memory page in the access record data list includes: The target data list is determined based on the read or write operations in the access record; Update the access count of the initial memory page in the target data list according to the identifier of the initial memory page.
5. The method according to claim 4, wherein determining the target data list based on the read operation or the write operation in the access record includes: A list of read data is determined based on the read operations in the access record, and a list of write data is determined based on the write operations in the access record.
6. The method according to claim 4, wherein updating the access count of the initial memory page in the target data list according to the identifier of the initial memory page includes: The access weight is determined based on the identifier of the initial memory page; The number of accesses to the initial memory page is increased according to the access weight.
7. The method according to claim 1, wherein determining a cold memory page or a hot memory page based on the access count of the initial memory page in the data list comprises: Sort all data in the data list according to the number of accesses to the initial memory page to obtain the updated data list; The cold or hot memory page is determined based on the updated data list.
8. The method according to claim 7, wherein determining a cold memory page or a hot memory page based on the updated data list comprises: The corresponding memory page identifier is determined based on the number of accesses and the preset threshold number in the updated data list; The corresponding cold or hot memory page is determined based on the memory page identifier.
9. The method of claim 1, further comprising, before responding to a memory access instruction sent by the processor: The data modification instruction is received from the management module through a mapping interface, wherein the management module receives the data modification instruction from the terminal through a data interaction interface; The initial memory page granularity, the address of the initial memory page, or a preset number of times threshold is modified according to the data modification instruction, wherein the spatial information of the initial memory page is determined based on the granularity of the initial memory page.
10. The method according to claim 1, further comprising, after determining the cold memory page or hot memory page based on the access count of the data list: The data acquisition instruction is received from the management module through a mapping interface, wherein the management module receives the data acquisition instruction from the terminal through a data interaction interface; The target data is returned to the management module according to the data acquisition instruction and the data list, wherein the management module sends the target data to the terminal through the data interaction interface.
11. A hot and cold page counting device, applied to a hot and cold page identification module of a memory controller, the device comprising: The memory access record unit is configured to generate an access record for an initial memory page in response to a memory access instruction sent by the processor. The popularity ranking unit is configured to determine the access weight based on the identifier of the initial memory page, and update the access count of the initial memory page in the data list according to the access weight; The data list is a minimum heap structure built based on read and write operations on memory pages; the access weight is the weight that increases the number of accesses. Sort all data in the data list according to the number of accesses to the initial memory page in the data list to obtain the updated data list; The access control unit is configured to determine whether a memory page is cold or hot based on the number of accesses in the updated data list and a preset threshold number of accesses.
12. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the hot and cold page statistics method according to any one of claims 1 to 10.
13. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the hot and cold page statistics steps of any one of claims 1 to 10.