WO2022057749A1 - Method and apparatus for handling missing memory page abnomality, and device and storage medium - Google Patents

Method and apparatus for handling missing memory page abnomality, and device and storage medium Download PDF

Info

Publication number
WO2022057749A1
WO2022057749A1 PCT/CN2021/117898 CN2021117898W WO2022057749A1 WO 2022057749 A1 WO2022057749 A1 WO 2022057749A1 CN 2021117898 W CN2021117898 W CN 2021117898W WO 2022057749 A1 WO2022057749 A1 WO 2022057749A1
Authority
WO
WIPO (PCT)
Prior art keywords
information
memory
prefetch
page
page fault
Prior art date
Application number
PCT/CN2021/117898
Other languages
French (fr)
Chinese (zh)
Inventor
王义彬
王龙
杨栋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022057749A1 publication Critical patent/WO2022057749A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/073Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a memory management context, e.g. virtual memory or cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems

Definitions

  • the embodiments of the present application relate to the field of computer technologies, and in particular, to a method, apparatus, device, and storage medium for processing a memory page fault exception.
  • the memory includes multiple consecutive memory pages.
  • the processor needs to access memory data, if the memory data is not in the memory pages included in the memory, a page fault exception will occur.
  • a disk includes a SWAP partition, and the SWAP partition is used to store data on memory pages that are rarely accessed by a processor, that is, data on cold pages.
  • the processor reads the corresponding data from the SWAP partition, and loads the read data into the corresponding memory page in the memory.
  • the processor starts from the memory page where the currently accessed memory data is located, and pre-reads multiple consecutive memories from the SWAP partition The data on the page is loaded into the corresponding memory page for subsequent continuous access.
  • the data on multiple consecutive memory pages are blindly pre-read into the memory.
  • the pre-read data includes a lot of data that is not really to be accessed. In this way, the memory resources will be tight, and the page fault exception will be triggered again in the future, which increases the memory access delay.
  • Embodiments of the present application provide a method, apparatus, device, and storage medium for processing abnormal page faults in memory, which can effectively reduce the number of abnormal page faults, reduce memory access latency, and reduce consumption of memory resources.
  • the technical solution is as follows:
  • a method for processing a page fault exception in memory includes:
  • the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind.
  • Prefetching data from multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
  • the memory data to be read by the computer device is not in the memory pages included in the memory, a page fault exception occurs, and when a page fault exception occurs, the information of the memory page where the page fault exception occurs this time is determined, That is, the information of the target memory page is determined, and the first information is obtained.
  • the information of the memory page is any information that can identify the memory page, such as the address of the memory page, the number of the memory page, etc., and the information of the memory page is used as the memory in the embodiment of the present application
  • the address of the page is taken as an example to introduce.
  • the computer device converts the virtual address of the memory data to be read this time into the address of the target memory page to obtain the first address.
  • the first address is the start address of the target memory page.
  • the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access.
  • the computer device predicts a plurality of prefetch information corresponding to the first information according to the historical memory access information, including: according to the correlation between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information. relationship, and obtain multiple pieces of prefetch information corresponding to the first information.
  • the historical access memory information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned.
  • the computer device obtains a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information, including: performing the processing on the first information.
  • a hash operation is performed to obtain a first sequence number; according to the first sequence number and the first information, a plurality of corresponding prefetch information is searched from the historical access memory information.
  • the page fault address is the memory page address that triggers the page fault exception stored in the historical access memory information
  • the historical access memory information can store multiple
  • Each serial number and corresponding records can be stored in the record corresponding to each serial number, and a plurality of prefetch addresses can be stored in the record corresponding to each page fault address.
  • a row number threshold (ROW) is configured in the computer device, and the row number threshold is used to indicate the maximum value of the hash result of the memory page information, that is, to limit the maximum value of the sequence number.
  • the historical access memory information may store a plurality of corresponding prefetch information from the first information.
  • the prefetch information it is also possible that multiple pieces of prefetch information corresponding to the first information are not stored.
  • the computer device searches for a plurality of corresponding prefetch information from the historical access memory information, including: searching for the record where the first serial number and the first information are located from the historical access memory information; If the first sequence number and the record where the first information is located are found in the memory information, the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
  • the computer device searches for a plurality of corresponding prefetch information from the record where the first sequence number and the first information are located, including: searching for the corresponding multiple prefetch information from the record where the first sequence number and the first information are located according to the prefetch depth. prefetch information. That is, after the computer device searches for the corresponding prefetch information from the record in which the first sequence number and the first information are located, the computer device uses a plurality of prefetch information whose total number does not exceed the prefetch depth in the record as the found plurality of prefetch information. get information.
  • a prefetch depth (prefetch depth, PD) is also configured in the computer device, and the prefetch depth is used to indicate the maximum number of multiple prefetch information acquired each time.
  • the computer device after the computer device searches for the first serial number and the record where the first information is located from the historical access memory information, it further includes: if the first serial number and the record where the first information is located are not found from the historical access memory information record, the historical access memory information is updated according to the first sequence number and the first information.
  • the computer device updates the historical access memory information according to the first serial number and the first information, including: when the historical access memory information does not store the first serial number and the first information, creating the first serial number and the first information in the historical access memory information.
  • the record of the serial number and the first information is to update the historical access memory information; in the case where the historical access memory information is stored with the first serial number, but the first information is not stored, the first information is stored in the record of the first serial number, to Update historical access memory information.
  • the computer equipment stores the first information in the record of the first serial number, including: if the number of page fault information stored in the record of the first serial number does not reach the first quantity threshold, then store in the record of the first serial number.
  • the first information if the number of page-missing information stored in the record of the first sequence number reaches the first quantity threshold, then delete the page-missing information with the earliest storage time and the corresponding prefetch information in the record of the first sequence number.
  • the first information is stored in the record.
  • the computer device is further configured with a first quantity threshold (ASSOC), and the first quantity threshold is used to indicate the maximum quantity of page fault information that can be stored in a record of the same serial number.
  • ASSOC first quantity threshold
  • the computer device deletes the earliest stored page fault in the record of the first serial number information and the corresponding prefetch information, and store the first information in the records corresponding to the first sequence, that is, eliminate the old information, and update the latest information in the historical access memory information.
  • the above-mentioned method of storing the first information in the record of the first serial number can be understood as a least recently used (LRU) method, in which the earliest stored page fault information is eliminated.
  • LRU least recently used
  • the historical access memory information can also be updated according to the page fault queue.
  • the method further includes: updating the historical access memory information according to the page fault queue, and the page fault queue is used to store the occurrences in chronological order. Information about memory pages with page fault exceptions. It should be noted that a page-missing queue (miss queue, MQ) is also stored in the computer device.
  • the computer device updates historical access memory information according to the page fault queue, including: storing the first information in the page fault queue; acquiring the memory in the page fault queue that is located before the first information and whose quantity does not exceed a second quantity threshold.
  • Page information obtain one or more second information; store the first information as prefetch information corresponding to each of the one or more second information in the historical access memory information.
  • the computer device is also configured with a page fault queue length (MQ length, MQ_L), and the page fault queue length is used to indicate the maximum amount of memory page information that can be stored in the page fault queue, so as to ensure that Data timeliness of memory page information.
  • MQ length MQ_L
  • the page fault queue length is used to indicate the maximum amount of memory page information that can be stored in the page fault queue, so as to ensure that Data timeliness of memory page information.
  • the computer device stores the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information, including: according to the first information and the one or more second information.
  • the positional relationship of each second information in the page fault queue in the second information, and the association relationship between the first information and each second information is stored in the historical memory access information.
  • each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each relevant group corresponds to a relevant level, and each relevant group is used to store prefetch information; the computer device is in the missing page according to the first information and each second information in the one or more second information.
  • the positional relationship in the queue storing the association relationship between the first information and each second information in the historical memory access information, including: selecting one second information from the one or more second information, for the selected second information
  • the information performs the following operations until the following operations are performed on each of the one or more second information: determine the first information according to the position of the first information and the selected second information in the page fault queue
  • the reference level is obtained with the correlation level of the selected second information; the first information is stored in the first information position of the target correlation group, and the target correlation group is that the correlation level corresponding to the selected second information is the reference level related groups.
  • the prefetch information (that is, the memory page information is stored) may already be stored in the first information position of the target related group, Then, the computer device needs to first move and/or delete the prefetched information stored in the relevant group included in the corresponding second information, and then store the first information in the first information position of the target relevant group.
  • the computer device is further configured with a third quantity threshold (SUCC), where the third quantity threshold is used to indicate the maximum quantity of prefetch information that can be stored in each relevant group.
  • the number of the one or more information locations is a third number threshold, and the one or more relevant groups are sequentially arranged in the order of the relevant level; the computer device stores the first information in the first information location of the target relevant group, including :
  • the computer device stores the first information in the first information position of the target related group
  • the computer device moves each memory page information stored in the target related group backward by one After the information location, the first information is stored in the first information location;
  • the computer device deletes the last memory page information in the target related group , after moving the remaining memory page information by one information position, the first information is stored in the first information position;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the computer device moves the target related group and each memory page information before the first free information position in the related group after the target related group by one information position, and then the first information is stored at the first information location;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group There is no free information location in the subsequent related group, then the computer device deletes the last memory page information in the last related group corresponding to the selected second information, and deletes the target related group and the related group located after the target related group. After the rest of the information of the memory pages are moved back by one information position, the first information is stored in the first information position.
  • the computer equipment stores the first information in the first information position of the target related group in a sequential backward manner.
  • MRU method to insert the first information into the target related group corresponding to each second information.
  • the computer equipment obtains prefetch information from the stored historical memory access information and updates the historical memory access information after each page fault exception occurs.
  • a prefetching algorithm is used to predict the prefetching information, that is, the computer equipment is configured with a prefetching algorithm, the computer equipment continuously updates the historical memory access information by running the prefetching algorithm, and records the historical memory access rules through the historical access memory information.
  • the computer device may store the historical access memory information in any manner of storing data, for example, storing the historical access memory information in a table form.
  • the historical access memory information in tabular form may be referred to as a multi-level correlation table (MLCT).
  • MLCT multi-level correlation table
  • a plurality of prefetch information corresponding to the memory page of the current page fault exception is obtained, and historical memory access information (such as a multi-level correlation table) is updated. Since the historical memory access information is gradually established according to the sequence relationship between the memory pages of the page fault exception occurred in the historical memory access, the multiple prefetch information obtained from the historical memory access information is very likely to be the first time in the historical access.
  • the memory page information corresponding to the memory data that needs to be accessed continuously that is, the data corresponding to the multiple prefetch messages read by this solution is very likely to be the memory to be accessed by the processor next.
  • data, that is, this solution pre-reads memory data more accurately, which can avoid serious waste of memory resources, and can reduce the probability of page fault exceptions again, that is, improve the prefetch hit rate and effectively reduce the memory access delay. .
  • non-sequential memory access mode includes strided mode and mixed mode.
  • This solution Learning the rules of historical memory access through the above method establishes historical access memory information, such as MLCT, instead of blindly prefetching data corresponding to consecutive memory page addresses into memory. All have good results.
  • the computer device reads the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory, including: reading from the specified storage space according to the plurality of prefetch information. Fetch the corresponding data to the corresponding memory page in the memory.
  • the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
  • a designated storage space is set in the computer device for storing the data of the cold page, that is, storing the data not stored in the memory page of the memory.
  • the read and write speed of XL-FLASH device is faster than that of SWAP partition of disk, and its price is lower than that of memory stick (such as dynamic random access memory (DRAM)), and its capacity is large, which can provide several times more than memory.
  • the accessible memory space includes DRAM and XL-FLASH devices, that is, by adding XL-FLASH devices, the accessible memory space is increased several times, that is, visible to users The fetch space has increased a lot.
  • remote storage for example, a storage device such as a disk and XL-FLASH included in a remote computer device, if the device wants to access the storage space of the remote storage, it can be accessed through the network, such as through high-speed Internet access remote storage.
  • the method further includes: determining the cold page in the memory according to the access time and the access quantity of the memory page in the memory in the first time period; and moving the data on the cold page from the memory to the designated storage space. That is, in addition to prefetching memory data from the specified storage space through the above method, the processor can also combine the method of scanning and eliminating cold pages in the memory to move the data on the cold pages in the memory to the specified storage space, That is, cold pages in memory are eliminated. In this way, more memory space can be freed up for storing hot memory data, thereby improving memory resource utilization.
  • the method further includes: receiving a prefetch algorithm performance query instruction; displaying prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate; wherein the prefetch accuracy rate is determined by the total prefetch rate.
  • the number and the number of prefetch hits are determined.
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses. The total number of prefetches refers to the total number of all prefetch information acquired in the second time period.
  • the number of prefetch hits refers to The total number of accessed memory pages in the memory pages corresponding to all the prefetch information acquired in the second time period, and the total number of accesses refers to the total number of all memory pages accessed in the second time period.
  • the prefetch accuracy rate can represent the accuracy of the prefetch algorithm to a certain extent
  • the prefetch coverage rate can represent the effectiveness of the prefetch algorithm for applications running on the device to a certain extent.
  • the computer device further includes: receiving a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the prefetch algorithm performance information; and according to the prefetch parameter adjustment instruction, update the history.
  • Access memory information can be understood as being based on a prefetching algorithm, and the user can configure the prefetching parameters included in the prefetching algorithm, such as the row number threshold, the first number threshold, the second number threshold, the third threshold. The number threshold, prefetch depth, page fault queue length, etc., the user can also adjust the prefetch parameters configured in the computer device.
  • MLCT historical access memory information
  • the larger the corresponding multi-level correlation table after the user adjusts the prefetch parameters the more historical memory access information the multi-level correlation table can record. The performance of the algorithm is better.
  • a device for processing a memory page fault exception in a second aspect, is provided, and the device for processing a memory page fault exception has the function of implementing the behavior of the method for processing the memory page fault exception in the first aspect.
  • the apparatus for processing a memory page fault exception includes one or more modules, and the one or more modules are used to implement the processing method for a memory page fault exception provided in the first aspect.
  • a device for processing a memory page fault exception includes:
  • the first determining module is used to determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time;
  • a prediction module configured to predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to characterize the law of historical memory access;
  • the reading module is used for reading the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
  • the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access;
  • the prediction module includes:
  • an obtaining unit configured to obtain a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information;
  • the historical memory access information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned;
  • the acquisition unit includes:
  • a hash subunit configured to perform a hash operation on the first information to obtain the first serial number
  • the search subunit is configured to search for a plurality of corresponding pieces of prefetch information from the historical memory access information according to the first sequence number and the first information.
  • lookup subunits are specifically used to:
  • the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
  • lookup subunits are specifically used to:
  • the corresponding pieces of prefetch information are searched from the first sequence number and the record where the first information is located.
  • the device also includes:
  • the first update module is used to update the historical memory access information according to the first sequence number and the first information if multiple prefetch information corresponding to the first information is not obtained, and the first sequence number is to hash the first information obtained by operation.
  • the first update module includes:
  • the first update unit is used to create the record where the first sequence number and the first information are located in the historical memory access information, to update the historical memory access information;
  • the second updating unit is configured to store the first information in the record of the first serial number to update the historical memory access information when the first serial number is stored in the historical memory access information but the first information is not stored.
  • the second update unit includes:
  • the first storage subunit is used to store the first information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number does not reach the first quantity threshold;
  • the second storage subunit is used to delete the page fault information with the earliest storage time and the corresponding prefetch information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, The first information is stored in the record of the first serial number.
  • the device also includes:
  • the second update module is used to update historical memory access information according to the page fault queue, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
  • the second update module includes:
  • a first storage unit for storing the first information in the page fault queue
  • an acquisition unit configured to acquire the memory page information that is located before the first information and whose quantity does not exceed the second quantity threshold in the page fault queue, and obtains one or more second information
  • the second storage unit is configured to store the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information.
  • the second storage unit includes:
  • the third storage subunit is configured to store the first information and each second information in the historical memory access information according to the positional relationship between the first information and each second information in the one or more second information in the page fault queue The relationship between the two information.
  • each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each related group corresponds to a related level, and each related group is used to store prefetch information;
  • the third storage subunit is specifically used for:
  • the positions of the first information and the selected second information in the page fault queue determine the correlation level of the first information and the selected second information, and obtain the reference level
  • the first information is stored in the first information position of the target correlation group, and the target correlation group is a correlation group whose correlation level corresponding to the selected second information is a reference level.
  • the number of the one or more information locations is a third number threshold, and the one or more related groups are arranged in order of related levels;
  • the third storage subunit is specifically used for:
  • the target related group is the last related group corresponding to the selected second information
  • the last memory page information in the target related group is deleted, and the After the remaining memory page information is moved back by one information position, the first information is stored in the first information position;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the target related group and each memory page information before the first free information position in the related group after the target related group are moved back by one information position, and the first Information is stored in the first information location;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is no free information location in the subsequent related groups, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related group located after the target related group are deleted. After the rest of the memory page information is moved back by one information position, the first information is stored in the first information position.
  • the reading module includes:
  • the reading unit is configured to read the corresponding data from the specified storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
  • the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
  • the device also includes:
  • the second determining module is configured to determine the cold page in the memory according to the access time and the access quantity of the memory page in the memory in the first time period;
  • the move module is used to move data on cold pages from memory to the specified storage space.
  • the device also includes:
  • a first receiving module configured to receive a prefetch algorithm performance query instruction
  • the display module is used to display the performance information of the prefetching algorithm, and the performance information of the prefetching algorithm includes the prefetching accuracy rate and the prefetching coverage rate;
  • the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses
  • the total number of prefetches refers to all the prefetch information obtained in the second time period.
  • the total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period
  • the total number of accesses refers to all the memory accessed in the second time period.
  • the total number of pages is determined by the total number of prefetches and the number of prefetch hits
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses
  • the total number of prefetches refers to all the prefetch information obtained in the second time period.
  • the total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all
  • the device also includes:
  • a second receiving module configured to receive a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the performance information of the prefetch algorithm
  • the third update module is used to adjust the instruction according to the prefetch parameter and update the historical memory access information.
  • a computer device in a third aspect, includes a processor and a memory, the memory is used for storing a program for executing the method for processing a memory page fault exception provided in the first aspect, and a memory for implementing The data involved in the method for processing a memory page fault exception provided by the first aspect.
  • the processor is configured to execute programs stored in the memory.
  • the operating means of the storage device may further include a communication bus for establishing a connection between the processor and the memory.
  • a computer-readable storage medium where instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium runs on a computer, the computer executes the processing of the memory page fault exception described in the first aspect. method.
  • a computer program product containing instructions which, when running on a computer, enables the computer to execute the method for processing a memory page fault exception described in the first aspect.
  • the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind.
  • Prefetching data of multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
  • FIG. 1 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • FIG. 2 is a flowchart of a method for processing a memory page fault exception provided by an embodiment of the present application
  • FIG. 3 is a schematic diagram of a page fault queue provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of obtaining a prefetch address from a stored multi-level correlation table according to an embodiment of the present application
  • FIG. 5 is a flowchart of another method for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a multi-level correlation table provided by an embodiment of the present application.
  • FIG. 7 is a flowchart of another method for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a method for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of another method for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of an apparatus for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 12 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application.
  • the network architecture and service scenarios described in the embodiments of the present application are for the purpose of illustrating the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application.
  • the evolution of the architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
  • FIG. 1 is a schematic structural diagram of a computer device according to an embodiment of the present application.
  • the computer device includes one or more processors 101 , a communication bus 102 , memory 103 , and one or more communication interfaces 104 .
  • the processor 101 is a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or one or more integrated circuits for implementing the solution of the present application, for example, an application-specific integrated circuit ( application-specific integrated circuit, ASIC), programmable logic device (programmable logic device, PLD) or a combination thereof.
  • the above-mentioned PLD is a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL) or any of them. combination.
  • the processor 101 has the function of implementing the method for processing a memory page fault exception provided by the embodiment of the present application.
  • FIGS. 2 to 9 For the specific implementation method, refer to the detailed introduction in the embodiments in FIGS. 2 to 9 .
  • the communication bus 102 is used to transfer information between the aforementioned components.
  • the communication bus 102 is divided into an address bus, a data bus, a control bus, and the like.
  • address bus a data bus
  • control bus a control bus
  • only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
  • the memory 103 is a read-only memory (read-only memory, ROM), a random access memory (random access memory, RAM), an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM) , optical disc (including compact disc read-only memory, CD-ROM, compact disc, laser disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or can be used for portable or any other medium that stores desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory 103 exists independently and is connected to the processor 101 through the communication bus 102, or the memory 103 is integrated with the processor 101.
  • the memory 103 includes a memory and a designated storage space, such as the storage space of an XL-FLASH device.
  • the Communication interface 104 uses any transceiver-like device for communicating with other devices or a communication network.
  • the communication interface 104 includes a wired communication interface, and optionally, a wireless communication interface.
  • the wired communication interface is, for example, an Ethernet interface.
  • the Ethernet interface is an optical interface, an electrical interface or a combination thereof.
  • the wireless communication interface is a wireless local area network (wireless local area network, WLAN) interface, a cellular network communication interface, or a combination thereof.
  • the computer device includes multiple processors, such as processor 101 and processor 105 as shown in FIG. 1 .
  • processors are a single-core processor, or a multi-core processor.
  • a processor herein refers to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the computer device further includes an output device 106 and an input device 107 .
  • the output device 106 communicates with the processor 101 and can display information in a variety of ways.
  • the output device 106 is a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, a projector, or the like.
  • the input device 107 communicates with the processor 101 and can receive user input in a variety of ways.
  • the input device 107 is a mouse, a keyboard, a touch screen device, a sensor device, or the like.
  • the memory 103 is further configured to store program codes 110 for executing the solutions of the present application, and the processor 101 can execute the program codes 110 stored in the memory 103 .
  • the program code 110 includes one or more software modules, and the computer device can use the processor 101 and the program code 110 in the memory 103 to implement the processing method for the memory page fault exception provided in the embodiment of FIG. 2 below.
  • the program code 110 includes the first determination module, the prediction module and the reading module shown in the embodiment of FIG. 10 , and the processor 101 uses the first determination module, the prediction module and the reading module to cause a page fault exception in the memory.
  • the page fault is predicted, the information of the memory page for page fault prediction is determined, the prefetch information is predicted, and the memory data is pre-read to the memory page.
  • FIG. 2 is a flowchart of a method for processing a memory page fault exception provided by an embodiment of the present application, and the method is applied to a computer device. Please refer to FIG. 2 , the method includes the following steps.
  • Step 201 Determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time.
  • the information of the memory page where the page fault exception occurs this time is determined, that is, the information of the target memory page is determined, and the first information is obtained.
  • the information of the memory page may be any kind of information that can identify the memory page, such as the address of the memory page, the number of the memory page, etc.
  • the information of the memory page is The address of the memory page is introduced as an example. That is, when a page fault exception occurs, the address of the memory page where the page fault exception occurs this time is determined, that is, the address of the target memory page is determined, and the first address is obtained.
  • the computer device converts the virtual address of the memory data to be read this time into the address of the target memory page to obtain the first address, and the first information is the first address.
  • the first address is the starting address of the target memory page, and the starting address is a virtual address.
  • the computer device divides the memory into 25 consecutive memory pages according to each consecutive 4k, each memory page corresponds to a memory page address, and each memory page address is the address of the corresponding memory page.
  • the starting address for example, the address of the first memory page is 0000, the address of the second memory page is 0004, the virtual address of the memory data of this page fault exception is 0011, then the quotient obtained by dividing 0011 by 4 is multiplied by 4 , that is, the starting address of the memory page where this page fault exception is obtained is 0008, that is, the first address is 0008.
  • Step 202 Predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to represent the regularity of the historical memory access.
  • the computer device predicts a plurality of prefetch information corresponding to the first information according to the historical memory access information .
  • the historical memory access information is used to represent the law of historical memory access.
  • the first information is a first address
  • the prefetch information is a prefetch address
  • the computer device predicts a plurality of prefetch addresses corresponding to the first address according to historical memory access information.
  • the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access.
  • the computer device acquires a plurality of prefetch information corresponding to the first information from the stored historical memory access information.
  • the historical memory access information may be referred to as page fault associated information.
  • the computer device acquires a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information. That is, the association relationship is stored in the computer device in the embodiment of the present application, and the computer device can predict the prefetch information according to the association relationship.
  • the historical memory access information includes the sequence number, the corresponding relationship between page fault information and prefetch information. obtained by the hash operation.
  • the implementation process for the computer device to obtain a plurality of prefetch information corresponding to the first information from the stored historical memory access information is as follows: the computer device performs a hash operation on the first information to obtain a first serial number, and according to the first serial number and the first information, and look up the corresponding pieces of prefetch information from the historical memory access information.
  • the computer device performs a hash operation on the first address to obtain a first serial number, and according to the first serial number and the first address, from the historical Find the corresponding multiple prefetch addresses in the memory access information.
  • the page fault address is the address of the memory page that triggers the page fault exception stored in the historical memory access information.
  • the historical memory access information can store multiple serial numbers and corresponding records, and the records corresponding to each serial number can store multiple page faults. address. Multiple prefetch addresses can be stored in the record corresponding to each page fault address.
  • the memory includes 100 memory pages, that is, there are 100 memory page addresses, and assuming that the parameter of the hash operation is 10, then after hashing the memory page addresses, at most 10 serial numbers can be obtained, each A maximum of 10 memory page addresses are stored in the record corresponding to the serial number, so that the historical memory access information can store 10 records corresponding to the serial number, and the record corresponding to each serial number can store a maximum of 10 page fault addresses.
  • the first address is 0024
  • the computer device after the computer device performs a hash operation on the first address, the first sequence number is 4, then the computer device searches the stored historical memory access information for the corresponding address according to the first sequence number 4 and the first address 0024. multiple prefetch addresses.
  • a row number threshold is configured in the computer device, and the row number threshold is used to indicate the maximum value of the hash result of memory page information (such as addresses), that is, to limit the maximum value of the sequence number. For example Typically, if the threshold of the number of rows is 10, then the sequence number can be 0-9 (or 1-10, etc.), that is, the maximum value of the sequence number is 9 (or 10, etc.).
  • the historical memory access information may store a plurality of corresponding prefetch information in the historical memory access information.
  • the prefetch information it is also possible that multiple pieces of prefetch information corresponding to the first information are not stored.
  • the computer device searches the historical memory access information for the record where the first serial number and the first information are located. If the record where the first serial number and the first information are located is found from the historical memory access information, Find the corresponding multiple prefetch information in the records of .
  • the computer equipment searches for the record where the first sequence number and the first address are located from the historical memory access information, and if the record where the first sequence number and the first address are located is found from the historical memory access information, then the first sequence number and the record where the first address is located are searched from the historical memory access information. The corresponding multiple prefetch addresses are searched in the record where the first address is located.
  • the computer device uses all the prefetch information in the record as the acquired multiple prefetch information.
  • the prefetch information is a prefetch address, and the computer device uses all the prefetch addresses found as multiple acquired prefetch addresses.
  • the computer device searches for a plurality of corresponding pieces of prefetch information from the record where the first sequence number and the first information are located according to the prefetch depth. That is, after the computer device searches for the corresponding prefetch information from the record in which the first sequence number and the first information are located, multiple prefetch information whose total number does not exceed the prefetch depth in the record are used as the obtained multiple prefetch information. get information. For example, the computer device takes multiple prefetch addresses whose total number does not exceed the prefetch depth in the found records as the obtained multiple prefetch addresses.
  • a prefetch depth is also configured in the computer device, and the prefetch depth is used to indicate the maximum number of multiple pieces of prefetch information (eg, addresses) acquired each time. If the total quantity of the prefetch information in the record where the first sequence number and the first information are located does not exceed the PD, the computer device regards all the prefetch information in the record as the acquired multiple prefetch information. If the number of prefetch information in the record where the first sequence number and the first information are located exceeds the prefetch depth, the computer device uses PD pieces of prefetch information in the record as the found multiple prefetch information. PD pieces of prefetch information are randomly selected from the record, or the computer device selects PD pieces of prefetch information according to the storage time sequence or location sequence of the prefetch information.
  • PD prefetch depth
  • the computer device updates the historical memory access information according to the first sequence number and the first information, where the first sequence number is a
  • the information is obtained by hash operation.
  • the computer equipment searches for the record where the first sequence number and the first address are located from the historical memory access information, and if the record where the first sequence number and the first address are located is not found from the historical memory access information, then the computer equipment A serial number and a first address to update historical memory access information.
  • the computer device when the historical memory access information does not store the first serial number and the first information, the computer device creates a record where the first serial number and the first information are located in the historical memory access information to update the historical memory access information. In the case where the historical memory access information is stored with the first serial number but does not store the first information, the computer device stores the first information in the record of the first serial number to update the historical memory access information.
  • the computer device searches for the prefetch address according to the address of a memory page that triggers a page fault exception for the first time, no information is stored in the historical memory access information.
  • the computer device stores the first address of the current page fault exception and the first serial number obtained by hashing the first address in the historical memory access information, so as to update the historical memory access information.
  • new serial numbers and corresponding page fault addresses are continuously added to the historical memory access information.
  • an implementation manner for the computer device to store the first information in the record of the first sequence number is: if the number of page fault information stored in the record of the first sequence number does not reach the first quantity threshold, the computer device stores the first sequence number in the first sequence number. Store the first information in the record of the first serial number; if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, then the computer equipment deletes the page fault information with the earliest storage time and the corresponding prefetching in the record of the first serial number information, the first information is stored in the record of the first serial number.
  • the computer device is also configured with a first quantity threshold (ASSOC), and the first quantity threshold is used to indicate the page fault information (such as an address) that can be stored in the records of the same serial number. greatest amount.
  • ASSOC first quantity threshold
  • the computer device deletes the earliest stored page fault information and the corresponding prefetch information in the record of the first serial number, and stores the first information in the first serial number.
  • the old information is eliminated, and the latest information is updated in the historical memory access information.
  • the memory includes 100 memory pages, that is, there are 100 memory page addresses, and assuming that the row number threshold ROW is 10, after hashing the memory page addresses, at most 10 serial numbers can be obtained, each serial number.
  • a maximum of 10 memory page addresses can be stored in the records of , so that the historical memory access information can store 10 serial numbers and corresponding records, and a maximum of 10 page fault addresses can be stored in the records of each serial number.
  • the first number threshold is 4, that is, each serial number stores at most 4 page fault addresses, and the record of the first serial number has already stored 4 page fault addresses, then the computer device stores the earliest of these 4 page fault addresses. The page fault address and the corresponding prefetch address are deleted, and then the first address is stored in the record corresponding to the first serial number.
  • the value of the first number threshold ASSOC may be smaller than the number of memory page addresses that each sequence number stores at most.
  • each sequence number corresponds to storing 10 memory page addresses at most, but the first number The threshold is set to 4, which is less than 10.
  • the computer device can reduce the amount of stored data by hashing the memory page addresses and setting the first number threshold smaller, and only store relatively new data in historical memory access information. information, while ensuring the accuracy of prefetching, and speeding up the rate of obtaining prefetching information from historical memory access information.
  • the above-mentioned method of storing the first information in the record of the first serial number can be understood as a LRU method, in which the earliest stored page fault information is eliminated.
  • the historical memory access information can also be updated according to the page fault queue.
  • a page fault queue is also stored in the computer device, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order, that is, to store the historical access memory in chronological order. Information about the memory page that triggers the page fault exception.
  • the implementation manner of the computer device updating historical memory access information according to the page fault queue MQ includes the following steps:
  • the computer device stores the first information (eg, address) at the end of the page fault queue.
  • the computer device deletes the expired data in the page fault queue every time period, for example, deletes the memory page information whose storage time exceeds the time threshold from the current time, or keeps the page fault queue in the The specified amount of memory page information with a relatively recent storage time is deleted, and other memory page information with an earlier storage time in the page fault queue is deleted, so as to save storage space and ensure the data aging of the memory page information stored in the page fault queue. sex.
  • the newly stored first information (eg, address) is always located at the end of the page fault queue.
  • the computer device is further configured with a page fault queue length MQ_L, and the page fault queue length is used to indicate the maximum number of memory page information (eg addresses) that can be stored in the page fault queue.
  • the computer device starts counting from the first time the memory page information is recorded in the MQ, and the value obtained after each count is used as the total number of page faults, that is, the computer device accumulates the number of page faults, and obtains the total number of page faults. quantity.
  • the computer device calculates the total number of page faults divided by the length of the page fault queue to obtain a remainder, and determines the storage location of the first information in the page fault queue according to the remainder. , and store the first information in the storage location.
  • the length of the page fault queue is 128, that is, the page fault queue stores information on at most 128 memory pages where page fault exceptions occur, and the storage locations of the page fault queue include 0-127 (or 1-128).
  • the computer device divides 36 by 128 to obtain a remainder of 36, then the computer device according to the remainder It is determined that the storage location of the first information is 35 (or 36), and the first information is stored in the storage location in the page fault queue.
  • the computer device divides 139 by 128 to obtain a remainder of 11, then the computer device determines according to the remainder.
  • the storage location of the first information is 10 (or 11), and the first information is stored in the storage location in the page fault queue, that is, the memory page information previously stored in the storage location is overwritten.
  • the first information (eg, address) is stored in the page fault queue in a circular storage manner, and the newly stored first information is not necessarily located at the end of the page fault queue.
  • a second quantity threshold (LEVEL) is further configured in the computer device, and the second quantity threshold is used to indicate the maximum quantity of the second information obtained from the page fault queue.
  • the computer device stores the first information in the page fault queue according to the above method 1, that is, always stores the first information at the end of the page fault queue, then the computer device directly obtains the first information in the page fault queue.
  • the memory page information of the second quantity threshold is obtained, that is, the one or more pieces of second information are obtained.
  • the memory page addresses currently stored in the page fault queue include m1, m2, m3, m4, and m5, the first address is m5, and the second quantity threshold is 3, then the computer equipment Acquire m2, m3, and m4 as the acquired 3 second addresses.
  • the computer device stores the first information in the page fault queue according to the above method 2, that is, the first information is not necessarily stored at the end of the page fault queue.
  • the memory before the first information in the page fault queue is The quantity of page information is not less than the second quantity threshold, and the computer device directly obtains the memory page information whose quantity does not exceed the second quantity threshold before the first information in the page fault queue, that is, obtains the one or more second information.
  • the computer device obtains the memory page information before the first information in the page fault queue, and obtains Part of the memory page information from the end of the queue forward, obtains one or more second information whose quantity is the second quantity threshold. That is, when the computer device stores the first information in the page fault queue by means of circular storage, the computer device also acquires the second information by means of forward circular storage.
  • the memory page addresses currently stored in the page fault queue include m1, m2, m3, m4, m5, m6, m7, m8, the first address is m2, and the second quantity threshold is 3, then the computer device acquires m1, m8 and m7 as the acquired 3 second addresses, so that when the page fault queue stores memory page addresses that are not less than the second number threshold in addition to the first address, One or more second addresses are guaranteed to be acquired in a quantity equal to the second quantity threshold.
  • the first information is stored in the historical memory access information as the prefetch information corresponding to each of the one or more second information.
  • the computer device stores the first information and each second information in the historical memory access information according to the positional relationship between the first information and the one or more second information in the page fault queue. The relationship of the second information.
  • each of the one or more second information corresponds to one or more related groups, and the number of the one or more related groups is a second number threshold,
  • Each correlation group corresponds to one or more information locations, each correlation group corresponds to a correlation level, and each correlation group is used to store prefetch information.
  • the computer device selects one second information from the one or more second information, and performs the following operations on the selected second information until each of the one or more second information is Perform the following operations until: according to the positions of the first information and the selected second information in the page fault queue, determine the correlation level of the first information and the selected second information, obtain a reference level, and store the first information in the target at the first information position of the related group, wherein the target related group is a related group whose related level corresponding to the selected second information is a reference level.
  • the computer device determines the correlation level of the first information and the corresponding second information according to the position of the first information and each second information in the page fault queue, obtains the reference level, and stores the first information in the historical memory access information at the first information position in the target related group corresponding to the corresponding second information in .
  • the page fault queue includes m1, m2, m3, m4, m5, m6, m7, and m8, the first address is m4, and the second The number threshold is 3, m1, m2, and m3 are the three acquired second addresses, and each second address corresponds to three related groups. Then the computer device determines the relationship between m4 and m1 according to the positions of m1 and m4 in the page fault queue.
  • the correlation level is 3, and m4 is stored at the first address position in the third correlation group corresponding to m1; according to the positions of m2 and m4 in the page fault queue, the correlation level between m4 and m2 is determined to be 2, and m4 It is stored in the first address position in the second correlation group corresponding to m2; according to the positions of m3 and m4 in the page fault queue, determine that the correlation level between m4 and m3 is 1, and store m4 in the first address corresponding to m1. at the first address position in the associated group.
  • the computer device performs a hash operation on each second information, obtains the sequence number corresponding to the corresponding second information, and accesses the information from the historical memory.
  • the corresponding serial number is searched in the information, and the corresponding second information is searched from the page fault information stored in the record of the corresponding serial number.
  • the prefetch information (that is, the memory page information is stored) may already be stored in the first information position of the target related group, Then, the computer device needs to first move and/or delete the prefetched information stored in the relevant group included in the corresponding second information, and then store the first information in the first information position of the target relevant group.
  • the number of one or more information locations corresponding to each related group is a third number threshold, and the one or more related groups are arranged in order of related levels. That is, in this embodiment of the present application, the computer device is further configured with a third quantity threshold (SUCC), and the third quantity threshold is used to indicate the maximum quantity of prefetch information (such as addresses) that can be stored in each relevant group. . Based on this, the computer device stores the first information in the first information location of the target related group, including various situations:
  • SUCC third quantity threshold
  • the computer device stores the first information in the first information position of the target related group.
  • Case 3 if the number of memory page information stored in the target related group reaches the third quantity threshold, and the target related group is the last related group corresponding to the selected second information, then the last memory page information in the target related group is stored. Deleting, after moving the remaining memory page information in the target related group by one information position, the first information is stored in the first information position of the target related group.
  • Case 4 if the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the selected second information corresponds to the related group in the relevant group. If there is an idle information position in the related group after the target related group, move the target related group and each memory page information before the first free information position in the related group after the target related group by one information position. The first information is stored at the first information location of the target related group.
  • Case 5 if the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the selected second information corresponds to the related group in the relevant group. If there is no free information location in the related group after the target related group, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related information located after the target related group are deleted. After the rest of the memory page information in the group is moved back by one information position, the first information is stored in the first information position of the target related group.
  • the computer equipment stores the first information in the first information position of the target related group in a sequential backward manner.
  • This implementation can be understood as inserting the first information into the MRU method. in a target related group corresponding to each second information.
  • a third quantity threshold is configured in the computer device, or a plurality of third quantity thresholds are configured, and each relevant group corresponds to a third quantity threshold.
  • the quantity of prefetch information for example, the third quantity threshold corresponding to the related group with a high degree of configuration correlation (for example, the correlation level is level 1) is larger, and the related group with a low level of configuration correlation (for example, the correlation level is level 3) corresponds to The threshold of the third quantity is smaller, which can improve the prefetching accuracy to a certain extent.
  • the computer device obtains prefetch information from the stored historical memory access information and updates the historical memory access information after each page fault exception occurs.
  • a prefetch algorithm to predict prefetch information such as addresses
  • the computer device is configured with a prefetch algorithm
  • the computer device continuously updates the historical memory access information by running the prefetch algorithm, and records the historical memory access information through the historical memory access information. law.
  • a prefetch algorithm (which can be understood as a software module) is configured in the computer device, and the configured prefetch algorithm includes a prefetch parameter, and the prefetch parameter includes the row number threshold (ROW) and the first number threshold (ASSOC) introduced above. ), the second quantity threshold (LEVEL), the third quantity threshold (SUCC), the prefetch depth (PD) and the page fault queue length (MQ_L), wherein the first quantity threshold, the prefetch depth and the page fault queue length can be selected Configure or not configure.
  • each sequence number can store the most page fault information (such as addresses), and in the case where the prefetch depth is not configured, the first sequence number and all prefetched information in the record of the first information are stored.
  • the information is taken as the acquired prefetch information, and the computer device stores the first information at the end of the page fault queue without configuring the length of the page fault queue.
  • the computer device can store the historical memory access information in any way of storing data, such as storing the historical memory access information in a table form.
  • Memory access information storing data
  • the historical memory access information in tabular form can be called a multi-level correlation table.
  • MLCT the following is an example of MLCT
  • the information of the memory page is the address of the memory page.
  • the prefetch algorithm includes a prefetch parameter
  • the prefetch parameter includes a row number threshold, a first number threshold, a second number threshold, a third number threshold, a prefetch depth, and a page fault queue length
  • the computer device updates the stored MLCT according to the page fault queue.
  • a user may configure a prefetch algorithm through a computer device, including configuring a prefetch parameter, wherein:
  • ROW R, the maximum value of the hash result of the memory page address, that is, the maximum value used to limit the serial number;
  • ASSOC In the tags (T) corresponding to the same hash result, the maximum number of memory page addresses that can be recorded, that is, the maximum number of memory page addresses stored in the record of the same serial number;
  • LEVEL LEV, the number of related groups corresponding to the memory page address corresponding to each tag
  • SUCC the maximum number of memory page addresses that can be stored in each relevant group
  • PD the maximum number of multiple prefetch addresses acquired each time
  • MQ_L The page fault queue length.
  • MQ stores the addresses of the memory pages of each page fault exception in chronological order, including A, B, C, D, E, F, G, H, and I. Assume that the page fault occurs on the first page. One address is E, and the third quantity threshold is 3, then obtain B, C and D in MQ to get 3 second addresses, where the correlation level between E and B is 3, the correlation level between E and C is 2, and the correlation level between E and C is 2.
  • the correlation level with D is 1, which can be understood as E is the third-level successor of B (level 3 successor, L3 SUCCE), E is the second-level successor of C (level 2 successor, L2 SUCCE), E is the first-level successor of D (level 1 successor, L1 SUCCE), then store the first address E in the third-level correlation group of B, store E in the second-level correlation group of C, and store E in the first-level correlation group of D, obtaining A multi-level correlation table storing B, C, and D and the corresponding prefetch addresses.
  • the multi-level correlation table shown in Figure 4 stores the first address E and the corresponding prefetch address, and the level 1 group corresponding to E (level 1 group, L1G). ), A and C are stored in ), B and D are stored in the level 2 group (L2G), and H is stored in the third-level correlation group. Assuming that the prefetch depth is 3, then the computer device obtains A, C and B as the prefetch address.
  • the computer device handles the page fault exception according to the following steps.
  • the virtual address va of the missing memory data is determined, and according to the virtual address va, the starting address of the memory page of the current page fault exception is determined, and the first address va p is obtained.
  • each memory page corresponds to a memory page address
  • each memory page address is the start of the corresponding memory page. For example, if the address of the first memory page is 0000, the address of the second memory page is 0004, and the virtual address of the memory data of this page fault exception is 0011, then the quotient obtained by dividing 0011 by 4 is multiplied by 4, that is, The starting address of the memory page where this page fault exception is obtained is 0008, that is, the first address is 0008.
  • the sequence number starts from 0, the maximum value of the sequence number that can be obtained by the hash operation is 9, and the first address is 0008. According to the hash operation, divide 0008 by 10 to obtain The quotient is 0, and 0 is used as the first sequence number.
  • the computer device obtains a plurality of corresponding prefetch addresses according to the prefetch depth PD.
  • the column corresponding to tags is used to store the page fault address.
  • the computer device adds the first sequence number rp in the MLCT , and adds the first address va p to a tag corresponding to the first sequence number rp ;
  • the computer device stores the first address va p in a tag corresponding to the first serial number rp in an LRU manner.
  • the LRU method is used to store the first address va p in the first sequence number as follows: if the number of memory page addresses recorded in the tags corresponding to the first sequence number r p reaches the first number threshold (ASSOC), then the computer equipment After deleting the memory page address with the earliest storage time in the tags, the first address va p is added to the tags; if the number of memory page addresses recorded in the tags corresponding to the first serial number r p does not reach the first number threshold, Then the computer device directly adds the first address va p to tags.
  • ASSOC first number threshold
  • storing the first address va page in the relevant group in an MRU manner may be understood as a manner of moving backward in sequence, and the specific implementation method refers to the foregoing embodiments, which will not be repeated here.
  • FIG. 6 is an exemplary MLCT shown in an embodiment of the present application.
  • the column where ROW(R) is located is used to store the serial number
  • the column where ASSOC is located is used to store the serial number of each TAG(T).
  • the column is optional, the column where TAG is located stores the page fault address corresponding to each serial number, the column where L1 is located is used to store the prefetch address of the first-level successor corresponding to the page fault address (VA), and the column where L2 is located is used to store The prefetch address (PVA) of the secondary successor corresponding to the page fault address.
  • VA page fault address
  • multiple prefetch addresses corresponding to the memory page of the current page fault exception are obtained, and the multi-level correlation table is updated. Since the multi-level correlation table is gradually established according to the sequence relationship between the memory pages with page fault exceptions that occur during historical access to memory, the multiple prefetch addresses obtained from the multi-level correlation table are highly likely to be the first in historical access. After the memory data corresponding to an address, the memory page address corresponding to the memory data that needs to be accessed continuously, that is, the data corresponding to the multiple prefetch addresses read by this solution is very likely to be the memory to be accessed by the processor next. data, that is, this solution pre-reads memory data more accurately, which can avoid serious waste of memory resources, and can reduce the probability of page fault exceptions again, that is, improve the prefetch hit rate and effectively reduce the memory access delay. .
  • the non-sequential memory access mode includes strided mode and mixed mode.
  • the MLCT is established by learning the rules of historical memory access through the prefetch algorithm, instead of blindly prefetching the data corresponding to the consecutive memory page addresses into the memory. This scheme has good effects on sequential memory access mode, skip read mode and mixed mode. .
  • the computer device predicts the prefetch information corresponding to the first information based on a Markov model.
  • a computer device constructs a Markov model based on historical memory access information, which includes historically accessed memory page information (such as addresses) arranged in chronological order, or memory page information of abnormal page faults arranged in chronological order, The computer device calculates the measurement probability of the memory page information and the transition probability between the memory page information according to the Markov model, and then calculates the probability that the first information is transferred to other memory page information according to the measurement probability and the transition probability, and calculates the maximum probability obtained by the calculation.
  • the corresponding memory page information is used as a prefetch information.
  • the computer device continues to use the prefetch information as the first information, and continues to predict the next most probable prefetch information by using the Markov model, to obtain the second prefetch information, And so on, until a plurality of prefetch information with the number of the prefetch depth is obtained.
  • the computer device predicts the prefetch information corresponding to the first information by using a deep learning model, such as predicting the prefetch information by using an artificial intelligence (artificial intelligence, AI) model.
  • a deep learning model such as predicting the prefetch information by using an artificial intelligence (artificial intelligence, AI) model.
  • AI artificial intelligence
  • the historical memory access information includes historically accessed memory page information (such as addresses) arranged in chronological order, and the deep learning model is trained according to the historical memory access information.
  • Each training sample includes a sample input and a The sample expected output, the computer equipment inputs the training sample into the initial model, and the deep learning model is obtained by training.
  • the computer device After obtaining the memory page information of the page fault exception this time, that is, after obtaining the first information, the computer device inputs the first information into the deep learning model, and outputs a plurality of prefetch information.
  • the computer device obtains training samples online, and gradually trains and updates the deep learning model by means of online training, or after the computer device obtains a certain amount of training samples, the deep learning model is obtained by training by means of offline training.
  • Step 203 Read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
  • the computer device after predicting and obtaining multiple pieces of prefetch information (eg, addresses), the computer device reads data corresponding to the multiple pieces of prefetch information to a corresponding memory page in the memory.
  • prefetch information eg, addresses
  • the prefetch address is a virtual address
  • some of the data corresponding to the multiple prefetch addresses may already be on the corresponding memory page in the memory.
  • the mapping relationship between the virtual address and the physical address of the memory is used to determine whether the data corresponding to the multiple prefetch addresses are already on the corresponding memory page, and the data not on the memory page is read to the corresponding memory page.
  • the computer device reads the corresponding data from the designated storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
  • the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
  • a designated storage space is set in the computer device for storing the data of the cold page, that is, storing the data not stored in the memory page of the memory.
  • the read and write speed of XL-FLASH devices is faster than that of SWAP partitions of disks, and the price is lower than that of memory sticks (such as DRAM), and the capacity is large, which can provide several times more capacity than memory.
  • the memory space includes DRAM and XL-FLASH devices, that is, by adding XL-FLASH devices, the accessible memory space is increased several times, that is, the access memory space visible to the user is increased a lot.
  • remote storage for example, a storage device such as a disk and XL-FLASH included in a remote computer device, if the device wants to access the storage space of the remote storage, it can be accessed through the network, such as through high-speed Internet access remote storage.
  • the designated memory space includes the storage space of one or more of the SWAP partition, the XL-FLASH device and the remote storage.
  • the computer device determines the cold pages in the memory according to the access time and the number of accesses of the memory pages in the memory in the first time period, and moves the data on the cold pages from the memory to the designated storage space. That is, in addition to prefetching memory data from the specified storage space through the prefetch algorithm, the processor can also combine the method of scanning and eliminating cold pages in the memory to move the data on the cold pages in the memory to the specified storage space. , that is, eliminating cold pages in memory. In this way, more memory space can be freed up for storing hot memory data, thereby improving memory resource utilization.
  • the computer device obtains the access time and the access quantity of the memory pages in the memory in the first time period, and determines the cold page in the memory according to the access time and the access quantity of the memory pages in the memory during the period of time .
  • the number of accesses of each memory page in the memory corresponds to the weight w1
  • the average of the durations between the respective access times of each memory page in the memory and the current time during this period is the first duration
  • the first duration corresponds to the weight w2.
  • the processor calculates the product of the number of accesses of each memory page in the memory and the weight w1 plus the product of the first duration and the weight w2 to obtain the memory access statistics value corresponding to the corresponding memory page, and the processor calculates the corresponding memory access statistics in the memory
  • a memory page whose value is less than the statistical threshold is determined as a cold page, or the processor sorts the access statistics corresponding to each memory page in the memory from small to large, and determines the memory page corresponding to the specified proportion of access statistics at the lower end of the sorting as a cold page .
  • the computer device periodically scans and eliminates cold pages, the first period of time is a period of time before the current scan, and the duration of the first period of time may be greater than, equal to or less than the scan period.
  • the computer device when the computer device eliminates cold pages, it compresses the data on the cold pages in the memory and stores it in the specified storage space. When pre-reading the memory data, it decompresses the prefetched memory data from the specified storage space and reads the in memory. In this way, through data compression, the amount of data storage in the specified storage space can be saved, and more cold pages can be eliminated from the memory to the specified storage space. In this way, more hot memory data can be stored in the memory, further improving the Resource utilization of memory.
  • the computer device combines the prefetch algorithm and the memory page scan to prefetch the memory data and eliminate the memory data, wherein the computer device scans the cold pages in the memory through the page scan module, and compresses the data of the cold pages and stores them in the memory.
  • the computer equipment prefetches the memory data from the designated storage space through the prefetching algorithm, in which the corresponding data is decompressed from the designated storage space through the kernel compression module and then read into the memory (such as DRAM), which is equivalent to reading heat. page data.
  • the computer device can also receive a prefetch algorithm performance query instruction, and display prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate.
  • the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses
  • the total number of prefetches refers to all the prefetch information obtained in the second time period.
  • the total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period, and the total number of accesses refers to all the memory accessed in the second time period.
  • the total number of pages refers to the total number of pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period, and the total number of accesses refers to all the memory accessed in the second time period. The total number of pages.
  • the second time period refers to a period of time from when the computer device runs the prefetch algorithm to when it receives the prefetch algorithm performance query instruction, or the second time period is before the moment when the prefetch algorithm performance information query is received.
  • a period of time of the specified duration refers to a period of time from when the computer device runs the prefetch algorithm to when it receives the prefetch algorithm performance query instruction, or the second time period is before the moment when the prefetch algorithm performance information query is received.
  • the prefetch accuracy rate can represent the accuracy of the prefetch algorithm to a certain extent
  • the prefetch coverage rate can represent the effectiveness of the prefetch algorithm for applications running on the device to a certain extent.
  • the user obtains the performance information of the prefetch algorithm, including the prefetch accuracy, Prefetch coverage, total number of prefetches, number of prefetch hits, etc. If the prefetching accuracy rate is low, the user can adjust the prefetching parameters by entering a command line in the computer device, such as increasing LEVEL, increasing ASSOC or increasing SUCC, etc.
  • the computer device updates the historical memory according to the adjusted prefetching parameters Access information (such as MLCT) to record the association relationship of more historically accessed memory page information in the historical memory access information.
  • Access information such as MLCT
  • the computer device receives the prefetch parameter adjustment instruction, the prefetch parameter adjustment instruction is determined by user feedback on the prefetch algorithm performance information, the computer device adjusts the instruction according to the prefetch parameter, and updates the history. Memory access information.
  • a user can query prefetch algorithm performance information through a computer device, and the computer device displays the prefetch algorithm performance information after receiving the prefetch algorithm performance query instruction, such as the prefetch accuracy rate and the prefetch coverage rate, Optionally, the total number of prefetches, the number of prefetch hits, etc. can also be displayed, and the user can choose to adjust the prefetch parameters through the computer device according to the prefetch accuracy rate and the prefetch coverage rate.
  • the historical memory access information as MLCT as an example, under normal circumstances, the larger the corresponding multi-level correlation table after the user adjusts the prefetch parameters, the more the correlation relationship of the historically accessed memory page information that the multi-level correlation table can record. To a certain extent, the performance of the prefetching algorithm is better.
  • the computer equipment includes a processor (CPU), a memory and a designated storage space (taking XL-FLASH as an example), and this method is understood to be realized through an abstract three-layer model of SMAP, which includes a perception layer, a decision layer and a physical layer.
  • SMAP can be understood to include functions corresponding to all the methods provided in the embodiments of the present application.
  • the computer device counts the hot and cold pages in the memory (main memory) through the processor and, for example, through the application (application, APP), the operating system (operaing system, OS) or the virtual machine (such as Hyper-v) statistics of memory cold and hot pages Pages, that is, memory hot and cold through the perception layer at the software level.
  • a computer device prefetches or eliminates memory pages by running a prefetching algorithm and a memory elimination algorithm, etc. on the processor, that is, prefetching or eliminating memory pages through a decision layer at the software and hardware levels.
  • the computer device performs media compression and decompression through the memory hardware module, that is, the media compression at the physical layer improves the access rate and saves storage space.
  • the processing method for the memory page fault exception provided by the embodiment of the present application is exemplarily described.
  • the user configures the prefetch algorithm and other related algorithms (such as the memory elimination algorithm for scanning cold pages) through the command line and other forms.
  • the algorithm is run to realize the data prefetch of the memory page. And the elimination of cold pages in memory.
  • the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory It is not blindly prefetching the data of multiple consecutive memory page addresses into the memory, that is, the prefetching hit rate of this scheme is higher, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce the memory access delay, and this
  • the data prefetched by the scheme is more effective, the consumption of memory resources is lower, and the memory resources are not very tight.
  • FIG. 10 is a schematic structural diagram of an apparatus 1000 for processing a memory page fault exception provided by an embodiment of the present application.
  • the apparatus 1000 for processing a memory page fault exception may be implemented as part or all of a computer device by software, hardware, or a combination of the two.
  • the computer device may be the computer device shown in FIG. 1 .
  • the apparatus 1000 includes: a first determination module 1001 , a prediction module 1002 and a reading module 1003 .
  • the first determination module 1001 is used to determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time; for the specific implementation method, refer to the detailed introduction of step 201 in the foregoing embodiment of FIG. 2 , I won't go into details here.
  • the prediction module 1002 is used to predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to represent the law of historical memory access; for the specific implementation method, refer to step 202 in the aforementioned embodiment of FIG. 2 The detailed introduction will not be repeated here.
  • the reading module 1003 is configured to read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
  • the reading module 1003 is configured to read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
  • the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access;
  • Prediction module 1002 includes:
  • an obtaining unit configured to obtain a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information;
  • the historical memory access information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned;
  • the acquisition unit includes:
  • a hash subunit configured to perform a hash operation on the first information to obtain the first serial number
  • the search subunit is configured to search for a plurality of corresponding pieces of prefetch information from the historical memory access information according to the first sequence number and the first information.
  • lookup subunits are specifically used to:
  • the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
  • lookup subunits are specifically used to:
  • the corresponding pieces of prefetch information are searched from the first sequence number and the record where the first information is located.
  • the device also includes:
  • the first update module is used to update the historical memory access information according to the first sequence number and the first information if multiple prefetch information corresponding to the first information is not obtained, and the first sequence number is to hash the first information obtained by operation.
  • the first update module includes:
  • the first update unit is used to create a record where the first serial number and the first information are located in the historical memory access information in the case that the historical memory access information does not store the first serial number and the first information, to update the historical memory access information;
  • the second updating unit is configured to store the first information in the record of the first serial number to update the historical memory access information when the first serial number is stored in the historical memory access information but the first information is not stored.
  • the second update unit includes:
  • the first storage subunit is used to store the first information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number does not reach the first quantity threshold;
  • the second storage subunit is used to delete the page fault information with the earliest storage time and the corresponding prefetch information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, The first information is stored in the record of the first serial number.
  • the device also includes:
  • the second update module is used to update historical memory access information according to the page fault queue, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
  • the second update module includes:
  • a first storage unit for storing the first information in the page fault queue
  • an acquisition unit configured to acquire the memory page information that is located before the first information and whose quantity does not exceed the second quantity threshold in the page fault queue, and obtains one or more second information
  • the second storage unit is configured to store the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information.
  • the second storage unit includes:
  • the third storage subunit is configured to store the first information and each second information in the historical memory access information according to the positional relationship between the first information and each second information in the one or more second information in the page fault queue The relationship between the two information.
  • each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each related group corresponds to a related level, and each related group is used to store prefetch information;
  • the third storage subunit is specifically used for:
  • the positions of the first information and the selected second information in the page fault queue determine the correlation level of the first information and the selected second information, and obtain the reference level
  • the first information is stored in the first information position of the target related group, and the target related group is a related group whose correlation level corresponding to the selected second information is a reference level.
  • the number of the one or more information locations is a third number threshold, and the one or more related groups are arranged in order of related levels;
  • the third storage subunit is specifically used for:
  • the target related group is the last related group corresponding to the selected second information
  • the last memory page information in the target related group is deleted, and the After the remaining memory page information is moved back by one information position, the first information is stored in the first information position;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the target related group and each memory page information before the first free information position in the related group after the target related group are moved back by one information position, and the first Information is stored in the first information location;
  • the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is no free information location in the subsequent related groups, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related group located after the target related group are deleted. After the rest of the memory page information is moved back by one information position, the first information is stored in the first information position.
  • the reading module 1003 includes:
  • the reading unit is configured to read the corresponding data from the specified storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
  • the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
  • the apparatus 1000 further includes:
  • the second determination module 1004 is configured to determine the cold page in the memory according to the access time and the number of accesses of the memory pages in the memory in the first time period; for the specific implementation method, refer to the detailed introduction of step 203 in the foregoing embodiment of FIG. 2 , here No longer.
  • the moving module 1005 is configured to move the data on the cold page from the memory to the designated storage space.
  • the apparatus 1000 further includes:
  • a first receiving module 1006, configured to receive a prefetch algorithm performance query instruction
  • a display module 1007 configured to display prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate;
  • the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses
  • the total number of prefetches refers to all the prefetch information obtained in the second time period.
  • the total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period
  • the total number of accesses refers to all the memory accessed in the second time period.
  • the total number of pages is determined by the total number of prefetches and the number of prefetch hits
  • the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses
  • the total number of prefetches refers to all the prefetch information obtained in the second time period.
  • the total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all
  • the apparatus 1000 further includes:
  • the second receiving module 1008 is configured to receive a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the performance information of the prefetch algorithm;
  • the third update module 1009 is configured to adjust the instruction according to the prefetch parameter and update the historical memory access information.
  • the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind.
  • Prefetching data from multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
  • the device for processing a memory page fault exception when processing the memory page fault abnormality, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions may be allocated as required. It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above.
  • the apparatus for processing a memory page fault exception provided by the above embodiment and the embodiment of the processing method for a memory page fault exception belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general purpose computer, special purpose computer, computer network or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server, a data center, etc. that includes one or more available media integrated.
  • the available media may be magnetic media (eg: floppy disk, hard disk, magnetic tape), optical media (eg: digital versatile disc (DVD)) or semiconductor media (eg: solid state disk (SSD)) Wait.
  • the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, may be a non-transitory storage medium.
  • references herein to "at least one” refers to one or more, and “plurality” refers to two or more.
  • “/” means or means, for example, A/B can mean A or B;
  • "and/or” in this document is only an association that describes an associated object Relation, it means that there can be three kinds of relations, for example, A and/or B can mean that A exists alone, A and B exist at the same time, and B exists alone.
  • words such as “first” and “second” are used to distinguish the same or similar items with basically the same function and effect. Those skilled in the art can understand that the words “first”, “second” and the like do not limit the quantity and execution order, and the words “first”, “second” and the like are not necessarily different.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

A method and apparatus for handling a missing memory page abnormality, and a device and a storage medium, relating to the technical field of computers. By means of the method and apparatus, the device and the storage medium, pre-fetch information is predicted according to historical memory access information, and data corresponding to the pre-fetch information is read into a memory, instead of blindly pre-fetching consecutive data of a plurality of memory page addresses into the memory. As such, the pre-fetch hit rate is higher, the number of subsequent missing page abnormalities can be effectively reduced, a memory access delay can be effectively reduced, pre-fetched data is more effective, and the loss of memory resources is lower, such that there is less strain on memory resources.

Description

内存缺页异常的处理方法、装置、设备及存储介质Method, device, device and storage medium for processing memory page fault exception 技术领域technical field
本申请实施例涉及计算机技术领域,特别涉及一种内存缺页异常的处理方法、装置、设备及存储介质。The embodiments of the present application relate to the field of computer technologies, and in particular, to a method, apparatus, device, and storage medium for processing a memory page fault exception.
背景技术Background technique
内存包括多个连续的内存页,当处理器需要访问内存数据时,如果该内存数据不在内存包括的内存页中,则会发生缺页异常。The memory includes multiple consecutive memory pages. When the processor needs to access memory data, if the memory data is not in the memory pages included in the memory, a page fault exception will occur.
在相关技术中,磁盘包括SWAP分区,SWAP分区用于存储处理器不常访问的内存页上的数据,也即冷页面上的数据。当发生缺页异常时,处理器从SWAP分区读取对应的数据,并将读取的数据加载到内存中相应的内存页上。其中,为了加快缺页异常的处理效率,降低访存时延,在发生缺页异常时,处理器从当前访问的内存数据所在的内存页开始,从SWAP分区中预先读取连续的多个内存页上的数据,并加载到对应的内存页上,以备后续有连续的访问。In the related art, a disk includes a SWAP partition, and the SWAP partition is used to store data on memory pages that are rarely accessed by a processor, that is, data on cold pages. When a page fault exception occurs, the processor reads the corresponding data from the SWAP partition, and loads the read data into the corresponding memory page in the memory. Among them, in order to speed up the processing efficiency of page fault exception and reduce the memory access delay, when a page fault exception occurs, the processor starts from the memory page where the currently accessed memory data is located, and pre-reads multiple consecutive memories from the SWAP partition The data on the page is loaded into the corresponding memory page for subsequent continuous access.
然而,在发生缺页异常时,盲目地将连续的多个内存页上的数据预先读取到内存中,在非顺序访问内存页的情况下,预先读取的数据中包括很多并非真正要访问的内存数据,这样会造成内存资源紧张,后续还会再次触发缺页异常,加大了访存时延。However, when a page fault exception occurs, the data on multiple consecutive memory pages are blindly pre-read into the memory. In the case of non-sequential memory page access, the pre-read data includes a lot of data that is not really to be accessed. In this way, the memory resources will be tight, and the page fault exception will be triggered again in the future, which increases the memory access delay.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了一种内存缺页异常的处理方法、装置、设备及存储介质,能够有效减少缺页异常的次数,降低访存时延,减少对内存资源的损耗。所述技术方案如下:Embodiments of the present application provide a method, apparatus, device, and storage medium for processing abnormal page faults in memory, which can effectively reduce the number of abnormal page faults, reduce memory access latency, and reduce consumption of memory resources. The technical solution is as follows:
第一方面,提供了一种内存缺页异常的处理方法,该方法包括:In a first aspect, a method for processing a page fault exception in memory is provided, and the method includes:
确定目标内存页的信息,得到第一信息,目标内存页为本次发生缺页异常的内存页;根据历史内存访问信息,预测与第一信息对应的多个预取信息,历史内存访问信息用于表征历史访问内存的规律;将多个预取信息对应的数据读取到内存中相应的内存页上。Determine the information of the target memory page, obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time; It is used to characterize the law of historical access to memory; the data corresponding to multiple prefetch information is read into the corresponding memory page in the memory.
在本申请实施例中,由于历史内存访问信息能够表征历史访问内存的规律,因此,根据历史内存访问信息来预测预取信息,从而将预取信息对应的数据读取到内存中,并非盲目的预取连续的多个内存页地址的数据到内存中,也即本方案预取命中率更高,能够有效减少后续缺页异常的次数,有效降低访存时延,且本方案预取的数据更加有效,对内存资源的损耗较低,内存资源不会很紧张。In the embodiment of the present application, since the historical memory access information can represent the law of historical memory access, the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind. Prefetching data from multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
在本申请实施例中,如果计算机设备需要读取的内存数据不在内存包括的内存页中,则发生缺页异常,当发生缺页异常时,确定本次发生缺页异常的内存页的信息,也即确定目标内存页的信息,得到第一信息。In the embodiment of the present application, if the memory data to be read by the computer device is not in the memory pages included in the memory, a page fault exception occurs, and when a page fault exception occurs, the information of the memory page where the page fault exception occurs this time is determined, That is, the information of the target memory page is determined, and the first information is obtained.
需要说明的是,在本申请实施例中,内存页的信息为能够标识内存页的任意一种信息, 例如内存页的地址,内存页的编号等,本申请实施例以内存页的信息为内存页的地址为例,进行介绍。It should be noted that, in the embodiment of the present application, the information of the memory page is any information that can identify the memory page, such as the address of the memory page, the number of the memory page, etc., and the information of the memory page is used as the memory in the embodiment of the present application The address of the page is taken as an example to introduce.
示例性地,当发生缺页异常时,计算机设备将本次需要读取的内存数据的虚拟地址,转换为目标内存页的地址,得到第一地址。需要说明的是,第一地址为目标内存页的起始地址。Exemplarily, when a page fault exception occurs, the computer device converts the virtual address of the memory data to be read this time into the address of the target memory page to obtain the first address. It should be noted that the first address is the start address of the target memory page.
可选地,历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的。Optionally, the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access.
可选地,计算机设备根据历史内存访问信息,预测与第一信息对应的多个预取信息,包括:根据历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与第一信息对应的多个预取信息。Optionally, the computer device predicts a plurality of prefetch information corresponding to the first information according to the historical memory access information, including: according to the correlation between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information. relationship, and obtain multiple pieces of prefetch information corresponding to the first information.
可选地,历史访问内存信息包括序号、缺页信息与预取信息之间的对应关系,缺页信息是指发生缺页异常的内存页的信息,序号是通过对缺页信息进行哈希运算得到的。Optionally, the historical access memory information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned.
基于此,计算机设备根据历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与第一信息对应的多个预取信息,包括:对第一信息进行哈希运算,得到第一序号;根据第一序号和第一信息,从历史访问内存信息中查找对应的多个预取信息。Based on this, the computer device obtains a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information, including: performing the processing on the first information. A hash operation is performed to obtain a first sequence number; according to the first sequence number and the first information, a plurality of corresponding prefetch information is searched from the historical access memory information.
示例性地,以第一信息为第一地址、预取信息为预取地址为例,缺页地址是历史访问内存信息中存储的触发缺页异常的内存页地址,历史访问内存信息能够存储多个序号以及对应的记录,每个序号对应的记录中能够存储多个缺页地址,每个缺页地址对应的记录中能够存储多个预取地址。Exemplarily, taking the first information as the first address and the prefetch information as the prefetch address as an example, the page fault address is the memory page address that triggers the page fault exception stored in the historical access memory information, and the historical access memory information can store multiple Each serial number and corresponding records can be stored in the record corresponding to each serial number, and a plurality of prefetch addresses can be stored in the record corresponding to each page fault address.
需要说明的是,计算机设备中配置有行数阈值(ROW),行数阈值用于指示关于内存页信息的哈希结果的最大值,也即用于限制序号的最大值It should be noted that a row number threshold (ROW) is configured in the computer device, and the row number threshold is used to indicate the maximum value of the hash result of the memory page information, that is, to limit the maximum value of the sequence number.
在本申请实施例中,计算机设备根据第一序号和第一信息,从历史访问内存信息中获取对应的多个预取信息时,历史访问内存信息中有可能会存储第一信息对应的多个预取信息,也有可能没有存储第一信息对应的多个预取信息。接下来对这两种情况分别进行说明。In the embodiment of the present application, when the computer device acquires a plurality of corresponding prefetch information from the historical access memory information according to the first serial number and the first information, the historical access memory information may store a plurality of corresponding prefetch information from the first information. For the prefetch information, it is also possible that multiple pieces of prefetch information corresponding to the first information are not stored. Next, these two cases will be described separately.
历史访问内存信息中存储有第一信息对应的多个预取信息的情况:The case where multiple prefetch information corresponding to the first information is stored in the historical access memory information:
计算机设备根据第一序号和第一信息,从历史访问内存信息中查找对应的多个预取信息,包括:从历史访问内存信息中查找第一序号和第一信息所在的记录;如果从历史访问内存信息中查找到第一序号和第一信息所在的记录,则从第一序号和第一信息所在的记录中查找对应的多个预取信息。According to the first serial number and the first information, the computer device searches for a plurality of corresponding prefetch information from the historical access memory information, including: searching for the record where the first serial number and the first information are located from the historical access memory information; If the first sequence number and the record where the first information is located are found in the memory information, the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
可选地,计算机设备从第一序号和第一信息所在的记录中查找对应的多个预取信息,包括:按照预取深度,从第一序号和第一信息所在的记录中查找对应的多个预取信息。也即是,计算机设备从第一序号和第一信息所在的记录中查找对应的预取信息后,将该记录中总数量不超过预取深度的多个预取信息作为查找到的多个预取信息。Optionally, the computer device searches for a plurality of corresponding prefetch information from the record where the first sequence number and the first information are located, including: searching for the corresponding multiple prefetch information from the record where the first sequence number and the first information are located according to the prefetch depth. prefetch information. That is, after the computer device searches for the corresponding prefetch information from the record in which the first sequence number and the first information are located, the computer device uses a plurality of prefetch information whose total number does not exceed the prefetch depth in the record as the found plurality of prefetch information. get information.
需要说明的是,计算机设备中还配置有预取深度(prefetch deep,PD),预取深度用于指示每次获取的多个预取信息的最大数量。It should be noted that, a prefetch depth (prefetch depth, PD) is also configured in the computer device, and the prefetch depth is used to indicate the maximum number of multiple prefetch information acquired each time.
历史访问内存信息中没有存储第一信息对应的多个预取信息的情况:The case where multiple prefetch information corresponding to the first information is not stored in the historical access memory information:
在本申请实施例中,计算机设备从历史访问内存信息中查找第一序号和第一信息所在的记录之后,还包括:如果从历史访问内存信息中未查找到第一序号和第一信息所在的记录,则根据第一序号和第一信息,更新历史访问内存信息。In the embodiment of the present application, after the computer device searches for the first serial number and the record where the first information is located from the historical access memory information, it further includes: if the first serial number and the record where the first information is located are not found from the historical access memory information record, the historical access memory information is updated according to the first sequence number and the first information.
可选地,计算机设备根据第一序号和第一信息,更新历史访问内存信息,包括:在历史 访问内存信息未存储第一序号和第一信息的情况下,在历史访问内存信息中创建第一序号和第一信息所在的记录,以更新历史访问内存信息;在历史访问内存信息存储有第一序号,但未存储第一信息的情况下,在第一序号的记录中存储第一信息,以更新历史访问内存信息。Optionally, the computer device updates the historical access memory information according to the first serial number and the first information, including: when the historical access memory information does not store the first serial number and the first information, creating the first serial number and the first information in the historical access memory information. The record of the serial number and the first information is to update the historical access memory information; in the case where the historical access memory information is stored with the first serial number, but the first information is not stored, the first information is stored in the record of the first serial number, to Update historical access memory information.
可选地,计算机设备在第一序号的记录中存储第一信息,包括:如果第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则在第一序号的记录中存储第一信息;如果第一序号的记录中存储的缺页信息的数量达到第一数量阈值,则删除第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在第一序号的记录中存储第一信息。Optionally, the computer equipment stores the first information in the record of the first serial number, including: if the number of page fault information stored in the record of the first serial number does not reach the first quantity threshold, then store in the record of the first serial number. The first information; if the number of page-missing information stored in the record of the first sequence number reaches the first quantity threshold, then delete the page-missing information with the earliest storage time and the corresponding prefetch information in the record of the first sequence number. The first information is stored in the record.
需要说明的是,在本申请实施例中,计算机设备中还配置有第一数量阈值(ASSOC),第一数量阈值用于指示同一个序号的记录中能够存储的缺页信息的最大数量。这样,如果第一序号的记录中存储的缺页信息的数量达到ASSOC,也即是第一序号对应的多个信息位置已存满,则计算机设备删除第一序号的记录中最早存储的缺页信息以及对应的预取信息,并将第一信息存储在第一序列对应的记录中,也即淘汰旧信息,将最新信息更新在历史访问内存信息中。It should be noted that, in this embodiment of the present application, the computer device is further configured with a first quantity threshold (ASSOC), and the first quantity threshold is used to indicate the maximum quantity of page fault information that can be stored in a record of the same serial number. In this way, if the number of page fault information stored in the record of the first serial number reaches ASSOC, that is, the multiple information positions corresponding to the first serial number are full, the computer device deletes the earliest stored page fault in the record of the first serial number information and the corresponding prefetch information, and store the first information in the records corresponding to the first sequence, that is, eliminate the old information, and update the latest information in the historical access memory information.
上述将第一信息存储在第一序号的记录中的方式可以理解为一种最近最少使用(least recently used,LRU)的方式,通过这种方式淘汰最早存储的缺页信息。The above-mentioned method of storing the first information in the record of the first serial number can be understood as a least recently used (LRU) method, in which the earliest stored page fault information is eliminated.
不管历史访问内存信息中是否存储有第一信息对应的多个预取信息,在计算机设备确定第一信息之后,还能够根据缺页队列,更新历史访问内存信息。Regardless of whether multiple prefetch information corresponding to the first information is stored in the historical access memory information, after the computer device determines the first information, the historical access memory information can also be updated according to the page fault queue.
也即是,计算机设备从历史访问内存信息中查找与第一信息对应的多个预取信息之后,还包括:根据缺页队列,更新历史访问内存信息,缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息。需要说明的是,计算机设备中还存储有缺页队列(miss queue,MQ)。That is, after the computer device searches for a plurality of prefetch information corresponding to the first information from the historical access memory information, the method further includes: updating the historical access memory information according to the page fault queue, and the page fault queue is used to store the occurrences in chronological order. Information about memory pages with page fault exceptions. It should be noted that a page-missing queue (miss queue, MQ) is also stored in the computer device.
可选地,计算机设备根据缺页队列,更新历史访问内存信息,包括:将第一信息存储在缺页队列中;获取缺页队列中位于第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息;将第一信息作为该一个或多个第二信息中每个第二信息对应的预取信息,存储至历史访问内存信息中。Optionally, the computer device updates historical access memory information according to the page fault queue, including: storing the first information in the page fault queue; acquiring the memory in the page fault queue that is located before the first information and whose quantity does not exceed a second quantity threshold. Page information, obtain one or more second information; store the first information as prefetch information corresponding to each of the one or more second information in the historical access memory information.
可选地,计算机设备中还配置有缺页队列长度(MQ length,MQ_L),缺页队列长度用于指示缺页队列中能够存储的内存页信息的最大数量,以保证缺页队列中存储的内存页信息的数据时效性。Optionally, the computer device is also configured with a page fault queue length (MQ length, MQ_L), and the page fault queue length is used to indicate the maximum amount of memory page information that can be stored in the page fault queue, so as to ensure that Data timeliness of memory page information.
可选地,计算机设备将第一信息作为该一个或多个第二信息中每个第二信息对应的预取信息,存储至历史内存访问信息中,包括:根据第一信息与该一个或多个第二信息中每个第二信息在缺页队列中的位置关系,在历史内存访问信息中存储第一信息与每个第二信息的关联关系。Optionally, the computer device stores the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information, including: according to the first information and the one or more second information. The positional relationship of each second information in the page fault queue in the second information, and the association relationship between the first information and each second information is stored in the historical memory access information.
可选地,该一个或多个第二信息中的每个第二信息对应有一个或多个相关组,该一个或多个相关组的数量为第二数量阈值,每个相关组对应有一个或多个信息位置,每个相关组对应一个相关级别,每个相关组用于存储预取信息;计算机设备根据第一信息与该一个或多个第二信息中每个第二信息在缺页队列中的位置关系,在历史内存访问信息中存储第一信息与每个第二信息的关联关系,包括:从该一个或多个第二信息中选择一个第二信息,对于选择出的第二信息执行如下操作,直至对一个或多个第二信息中的每个第二信息均执行如下操作为止:根据第一信息与选择出的第二信息在缺页队列中的位置,确定第一信息与选择出的第二信息的相关级别,得到参考级别;将第一信息存储在目标相关组的第一个信息位置上,目 标相关组为选择出的第二信息对应的相关级别为参考级别的相关组。Optionally, each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each relevant group corresponds to a relevant level, and each relevant group is used to store prefetch information; the computer device is in the missing page according to the first information and each second information in the one or more second information. The positional relationship in the queue, storing the association relationship between the first information and each second information in the historical memory access information, including: selecting one second information from the one or more second information, for the selected second information The information performs the following operations until the following operations are performed on each of the one or more second information: determine the first information according to the position of the first information and the selected second information in the page fault queue The reference level is obtained with the correlation level of the selected second information; the first information is stored in the first information position of the target correlation group, and the target correlation group is that the correlation level corresponding to the selected second information is the reference level related groups.
需要说明的是,缺页队列中存储的两个内存页信息的位置越近,在一定程度上表示这两个内存页信息的关联程度(相关程度)越高。It should be noted that the closer the positions of the two memory page information stored in the page fault queue are, the higher the correlation degree (correlation degree) of the two memory page information to a certain extent.
由于在将第一信息作为预取信息存储在历史访问内存信息中的目标相关组之前,目标相关组的第一个信息位置上可能已经存储有预取信息(也即存储有内存页信息),那么计算机设备需要先移动和/或删除相应第二信息包括的相关组中存储的预取信息后,将第一信息存储在目标相关组的第一个信息位置上。Because before storing the first information as the prefetch information in the target related group in the historical access memory information, the prefetch information (that is, the memory page information is stored) may already be stored in the first information position of the target related group, Then, the computer device needs to first move and/or delete the prefetched information stored in the relevant group included in the corresponding second information, and then store the first information in the first information position of the target relevant group.
可选地,在本申请实施例中,计算机设备中还配置有第三数量阈值(SUCC),第三数量阈值用于指示每个相关组中能够存储的预取信息的最大数量。该一个或多个信息位置的数量为第三数量阈值,该一个或多个相关组按照相关级别的顺序依次排列;计算机设备将第一信息存储在目标相关组的第一个信息位置上,包括:Optionally, in this embodiment of the present application, the computer device is further configured with a third quantity threshold (SUCC), where the third quantity threshold is used to indicate the maximum quantity of prefetch information that can be stored in each relevant group. The number of the one or more information locations is a third number threshold, and the one or more relevant groups are sequentially arranged in the order of the relevant level; the computer device stores the first information in the first information location of the target relevant group, including :
如果目标相关组的第一个信息位置上未存储内存页信息,则计算机设备将第一信息存储在目标相关组的第一个信息位置上;If the memory page information is not stored in the first information position of the target related group, the computer device stores the first information in the first information position of the target related group;
如果第一个信息位置上存储有内存页信息,且目标相关组存储的内存页信息的数量未达到第三数量阈值,则计算机设备将目标相关组中存储的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If memory page information is stored in the first information location, and the number of memory page information stored in the target related group does not reach the third quantity threshold, the computer device moves each memory page information stored in the target related group backward by one After the information location, the first information is stored in the first information location;
如果目标相关组存储的内存页信息的数量达到第三数量阈值,且目标相关组为选择出的第二信息对应的最后一个相关组,则计算机设备将目标相关组中的最后一个内存页信息删除,将其余内存页信息后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, and the target related group is the last related group corresponding to the selected second information, the computer device deletes the last memory page information in the target related group , after moving the remaining memory page information by one information position, the first information is stored in the first information position;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中存在空闲的信息位置,则计算机设备将目标相关组以及位于目标相关组之后的相关组中首个空闲的信息位置之前的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the computer device moves the target related group and each memory page information before the first free information position in the related group after the target related group by one information position, and then the first information is stored at the first information location;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中不存在空闲的信息位置,则计算机设备将选择出的第二信息对应的最后一个相关组中的最后一个内存页信息删除,将目标相关组以及位于目标相关组之后的相关组中的其余内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上。If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group There is no free information location in the subsequent related group, then the computer device deletes the last memory page information in the last related group corresponding to the selected second information, and deletes the target related group and the related group located after the target related group. After the rest of the information of the memory pages are moved back by one information position, the first information is stored in the first information position.
由上述可知,计算机设备通过一种顺次后移的方式,将第一信息存储在目标相关组的第一个信息位置上,可以将这种实现方式理解为通过最近最常使用(most recently used,MRU)的方式将第一信息插入每个第二信息对应的目标相关组中。It can be seen from the above that the computer equipment stores the first information in the first information position of the target related group in a sequential backward manner. , MRU) method to insert the first information into the target related group corresponding to each second information.
通过以上方式,计算机设备在每次发生缺页异常后,从存储的历史内存访问信息中获取预取信息,以及对历史访问内存信息进行更新,上述介绍的实现方式可以理解为,计算机设备通过一种预取算法来预测预取信息,也即计算机设备中配置有预取算法,计算机设备通过运行预取算法不断地更新历史访问内存信息,通过历史访问内存信息记录历史访问内存的规律。In the above manner, the computer equipment obtains prefetch information from the stored historical memory access information and updates the historical memory access information after each page fault exception occurs. A prefetching algorithm is used to predict the prefetching information, that is, the computer equipment is configured with a prefetching algorithm, the computer equipment continuously updates the historical memory access information by running the prefetching algorithm, and records the historical memory access rules through the historical access memory information.
可选地,计算机设备可以以任一种存储数据的方式来存储历史访问内存信息,例如以表格形式存储历史访问内存信息。可选地,表格形式的历史访问内存信息可以称为多级相关表 (multi-level correlation table,MLCT)。Optionally, the computer device may store the historical access memory information in any manner of storing data, for example, storing the historical access memory information in a table form. Alternatively, the historical access memory information in tabular form may be referred to as a multi-level correlation table (MLCT).
通过以上过程,获取本次缺页异常的内存页对应的多个预取信息,并更新历史内存访问信息(如多级相关表)。由于历史内存访问信息是根据历史访问内存时发生的缺页异常的内存页之间的先后关系逐渐建立起来的,从历史内存访问信息中获取的多个预取信息,很大概率也是历史访问第一信息对应的内存数据之后,需要继续访问的内存数据对应的内存页信息,也即是,本方案读取的多个预取信息对应的数据,很大概率就是处理器接下来要访问的内存数据,也即本方案更加精准地预读内存数据,能够避免造成严重的内存资源浪费,且能够降低再次发生缺页异常的概率,也即提高了预取命中率,有效降低了访存时延。Through the above process, a plurality of prefetch information corresponding to the memory page of the current page fault exception is obtained, and historical memory access information (such as a multi-level correlation table) is updated. Since the historical memory access information is gradually established according to the sequence relationship between the memory pages of the page fault exception occurred in the historical memory access, the multiple prefetch information obtained from the historical memory access information is very likely to be the first time in the historical access. After the memory data corresponding to a message, the memory page information corresponding to the memory data that needs to be accessed continuously, that is, the data corresponding to the multiple prefetch messages read by this solution is very likely to be the memory to be accessed by the processor next. data, that is, this solution pre-reads memory data more accurately, which can avoid serious waste of memory resources, and can reduce the probability of page fault exceptions again, that is, improve the prefetch hit rate and effectively reduce the memory access delay. .
需要说明的是,计算机设备中应用的访存模式有多种,例如顺序访存模式、非顺序访存模式,非顺序访存模式包括跳读(strided)模式和混合(mixed)模式,本方案通过上述方法学习历史访问内存的规律建立历史访问内存信息,如MLCT,而非盲目的预取连续的内存页地址对应的数据到内存中,本方案对于顺序访存模式、跳读模式和混合模式均有良好的效果。It should be noted that there are many memory access modes applied in computer equipment, such as sequential memory access mode and non-sequential memory access mode. The non-sequential memory access mode includes strided mode and mixed mode. This solution Learning the rules of historical memory access through the above method establishes historical access memory information, such as MLCT, instead of blindly prefetching data corresponding to consecutive memory page addresses into memory. All have good results.
可选地,在本申请实施例中,计算机设备将该多个预取信息对应的数据读取到内存中相应的内存页上,包括:根据该多个预取信息,从指定存储空间中读取对应的数据到内存中相应的内存页上。Optionally, in this embodiment of the present application, the computer device reads the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory, including: reading from the specified storage space according to the plurality of prefetch information. Fetch the corresponding data to the corresponding memory page in the memory.
可选地,指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。Optionally, the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
需要说明的是,在计算机设备中设置指定存储空间,用于存储冷页面的数据,也即是存储未在内存的内存页上存储的数据。其中,XL-FLASH设备的读写速度快于磁盘的SWAP分区,且价格比内存条(如动态随机存取存储器(dynamic random access memory,DRAM))低,容量大,能够提供比内存多几倍的容量,对于计算机设备来说,可供访问的内存空间包括DRAM和XL-FLASH设备,也即通过增加XL-FLASH设备将可供访问的内存空间增加了几倍,也即是对用户可见的访存空间增加了很多。It should be noted that a designated storage space is set in the computer device for storing the data of the cold page, that is, storing the data not stored in the memory page of the memory. Among them, the read and write speed of XL-FLASH device is faster than that of SWAP partition of disk, and its price is lower than that of memory stick (such as dynamic random access memory (DRAM)), and its capacity is large, which can provide several times more than memory. For computer equipment, the accessible memory space includes DRAM and XL-FLASH devices, that is, by adding XL-FLASH devices, the accessible memory space is increased several times, that is, visible to users The fetch space has increased a lot.
另外,需要说明的是,关于远端存储器,例如远端的一个计算机设备包括的磁盘、XL-FLASH等存储设备,本设备如果要访问远端存储器的存储空间,可以通过网络访问,如通过高速的互联网访问远端存储器。In addition, it should be noted that with regard to the remote storage, for example, a storage device such as a disk and XL-FLASH included in a remote computer device, if the device wants to access the storage space of the remote storage, it can be accessed through the network, such as through high-speed Internet access remote storage.
可选地,该方法还包括:根据第一时间段内内存中的内存页的访问时间和访问数量,确定内存中的冷页面;将冷页面上的数据从内存移动到指定存储空间中。也即是,除通过上述方法从指定存储空间中预取内存数据之外,处理器还能够结合扫描并淘汰内存中冷页面的方法,将内存中冷页面上的数据移动到指定存储空间中,也即淘汰内存中的冷页面。这样,能够将内存腾出更多的空间用于存放热度高的内存数据,提高内存的资源利用率。Optionally, the method further includes: determining the cold page in the memory according to the access time and the access quantity of the memory page in the memory in the first time period; and moving the data on the cold page from the memory to the designated storage space. That is, in addition to prefetching memory data from the specified storage space through the above method, the processor can also combine the method of scanning and eliminating cold pages in the memory to move the data on the cold pages in the memory to the specified storage space, That is, cold pages in memory are eliminated. In this way, more memory space can be freed up for storing hot memory data, thereby improving memory resource utilization.
可选地,该方法还包括:接收预取算法性能查询指令;显示预取算法性能信息,预取算法性能信息包括预取准确率和预取覆盖率;其中,预取准确率由预取总数量和预取命中数量确定,预取覆盖率由预取总数量和访问总数量确定,预取总数量是指第二时间段内获取的所有预取信息的总数量,预取命中数量是指第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,访问总数量是指第二时间段内被访问的所有内存页的总数量。Optionally, the method further includes: receiving a prefetch algorithm performance query instruction; displaying prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate; wherein the prefetch accuracy rate is determined by the total prefetch rate. The number and the number of prefetch hits are determined. The prefetch coverage rate is determined by the total number of prefetches and the total number of accesses. The total number of prefetches refers to the total number of all prefetch information acquired in the second time period. The number of prefetch hits refers to The total number of accessed memory pages in the memory pages corresponding to all the prefetch information acquired in the second time period, and the total number of accesses refers to the total number of all memory pages accessed in the second time period.
需要说明的是,预取准确率在一定程度上能够表征预取算法的准确度,预取覆盖率在一定程度上能够表征预取算法对于本设备运行的应用的有效程度。It should be noted that the prefetch accuracy rate can represent the accuracy of the prefetch algorithm to a certain extent, and the prefetch coverage rate can represent the effectiveness of the prefetch algorithm for applications running on the device to a certain extent.
可选地,计算机设备显示预取算法性能信息之后,还包括:接收预取参数调整指令,预 取参数调整指令由关于预取算法性能信息的用户反馈确定;根据预取参数调整指令,更新历史访问内存信息。也即是,上述预取内存数据的方法可以理解为基于一种预取算法,用户可以配置预取算法包括的预取参数,如行数阈值、第一数量阈值、第二数量阈值、第三数量阈值、预取深度、缺页队列长度等,用户还能够调整计算机设备中配置的预取参数。以历史访问内存信息为MLCT为例,通常情况下,用户调整预取参数后对应的多级相关表越大,多级相关表能够记录的历史访存信息也就越多,在一定程度上预取算法的性能也就越好。Optionally, after displaying the prefetch algorithm performance information, the computer device further includes: receiving a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the prefetch algorithm performance information; and according to the prefetch parameter adjustment instruction, update the history. Access memory information. That is to say, the above method of prefetching memory data can be understood as being based on a prefetching algorithm, and the user can configure the prefetching parameters included in the prefetching algorithm, such as the row number threshold, the first number threshold, the second number threshold, the third threshold. The number threshold, prefetch depth, page fault queue length, etc., the user can also adjust the prefetch parameters configured in the computer device. Taking historical access memory information as MLCT as an example, in general, the larger the corresponding multi-level correlation table after the user adjusts the prefetch parameters, the more historical memory access information the multi-level correlation table can record. The performance of the algorithm is better.
第二方面,提供了一种内存缺页异常的处理装置,所述内存缺页异常的处理装置具有实现上述第一方面中内存缺页异常的处理方法行为的功能。所述内存缺页异常的处理装置包括一个或多个模块,该一个或多个模块用于实现上述第一方面所提供的内存缺页异常的处理方法。In a second aspect, a device for processing a memory page fault exception is provided, and the device for processing a memory page fault exception has the function of implementing the behavior of the method for processing the memory page fault exception in the first aspect. The apparatus for processing a memory page fault exception includes one or more modules, and the one or more modules are used to implement the processing method for a memory page fault exception provided in the first aspect.
也即是,提供了一种内存缺页异常的处理装置,该装置包括:That is, a device for processing a memory page fault exception is provided, and the device includes:
第一确定模块,用于确定目标内存页的信息,得到第一信息,目标内存页为本次发生缺页异常的内存页;The first determining module is used to determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time;
预测模块,用于根据历史内存访问信息,预测与第一信息对应的多个预取信息,历史内存访问信息用于表征历史访问内存的规律;a prediction module, configured to predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to characterize the law of historical memory access;
读取模块,用于将该多个预取信息对应的数据读取到内存中相应的内存页上。The reading module is used for reading the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
可选地,历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的;Optionally, the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access;
预测模块包括:The prediction module includes:
获取单元,用于根据历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与第一信息对应的多个预取信息;an obtaining unit, configured to obtain a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information;
可选地,历史内存访问信息包括序号、缺页信息与预取信息之间的对应关系,缺页信息是指发生缺页异常的内存页的信息,序号是通过对缺页信息进行哈希运算得到的;Optionally, the historical memory access information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned;
获取单元包括:The acquisition unit includes:
哈希子单元,用于对第一信息进行哈希运算,得到第一序号;a hash subunit, configured to perform a hash operation on the first information to obtain the first serial number;
查找子单元,用于根据第一序号和第一信息,从历史内存访问信息中查找对应的多个预取信息。The search subunit is configured to search for a plurality of corresponding pieces of prefetch information from the historical memory access information according to the first sequence number and the first information.
可选地,查找子单元具体用于:Optionally, lookup subunits are specifically used to:
从历史内存访问信息中查找第一序号和第一信息所在的记录;Find the first serial number and the record where the first information is located from the historical memory access information;
如果从历史内存访问信息中查找到第一序号和第一信息所在的记录,则从第一序号和第一信息所在的记录中查找对应的多个预取信息。If the first sequence number and the record where the first information is located are found from the historical memory access information, the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
可选地,查找子单元具体用于:Optionally, lookup subunits are specifically used to:
按照预取深度,从第一序号和第一信息所在的记录中查找对应的多个预取信息。According to the prefetch depth, the corresponding pieces of prefetch information are searched from the first sequence number and the record where the first information is located.
可选地,该装置还包括:Optionally, the device also includes:
第一更新模块,用于如果未获取到与第一信息对应的多个预取信息,则根据第一序号和第一信息,更新历史内存访问信息,第一序号是对第一信息进行哈希运算得到的。The first update module is used to update the historical memory access information according to the first sequence number and the first information if multiple prefetch information corresponding to the first information is not obtained, and the first sequence number is to hash the first information obtained by operation.
可选地,第一更新模块包括:Optionally, the first update module includes:
第一更新单元,用于在历史内存访问信息未存储第一序号和第一信息的情况下,在历史 内存访问信息中创建第一序号和第一信息所在的记录,以更新历史内存访问信息;The first update unit is used to create the record where the first sequence number and the first information are located in the historical memory access information, to update the historical memory access information;
第二更新单元,用于在历史内存访问信息存储有第一序号,但未存储第一信息的情况下,在第一序号的记录中存储第一信息,以更新历史内存访问信息。The second updating unit is configured to store the first information in the record of the first serial number to update the historical memory access information when the first serial number is stored in the historical memory access information but the first information is not stored.
可选地,第二更新单元包括:Optionally, the second update unit includes:
第一存储子单元,用于如果第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则在第一序号的记录中存储第一信息;The first storage subunit is used to store the first information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number does not reach the first quantity threshold;
第二存储子单元,用于如果第一序号的记录中存储的缺页信息的数量达到第一数量阈值,则删除第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在第一序号的记录中存储第一信息。The second storage subunit is used to delete the page fault information with the earliest storage time and the corresponding prefetch information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, The first information is stored in the record of the first serial number.
可选地,该装置还包括:Optionally, the device also includes:
第二更新模块,用于根据缺页队列,更新历史内存访问信息,缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息。The second update module is used to update historical memory access information according to the page fault queue, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
可选地,第二更新模块包括:Optionally, the second update module includes:
第一存储单元,用于将第一信息存储在缺页队列中;a first storage unit for storing the first information in the page fault queue;
获取单元,用于获取缺页队列中位于第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息;an acquisition unit, configured to acquire the memory page information that is located before the first information and whose quantity does not exceed the second quantity threshold in the page fault queue, and obtains one or more second information;
第二存储单元,用于将第一信息作为该一个或多个第二信息中每个第二信息对应的预取信息,存储至历史内存访问信息中。The second storage unit is configured to store the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information.
可选地,第二存储单元包括:Optionally, the second storage unit includes:
第三存储子单元,用于根据第一信息与该一个或多个第二信息中每个第二信息在缺页队列中的位置关系,在历史内存访问信息中存储第一信息与每个第二信息的关联关系。The third storage subunit is configured to store the first information and each second information in the historical memory access information according to the positional relationship between the first information and each second information in the one or more second information in the page fault queue The relationship between the two information.
可选地,该一个或多个第二信息中的每个第二信息对应有一个或多个相关组,该一个或多个相关组的数量为第二数量阈值,每个相关组对应有一个或多个信息位置,每个相关组对应一个相关级别,每个相关组用于存储预取信息;Optionally, each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each related group corresponds to a related level, and each related group is used to store prefetch information;
第三存储子单元具体用于:The third storage subunit is specifically used for:
从该一个或多个第二信息中选择一个第二信息,对于选择出的第二信息执行如下操作,直至对该一个或多个第二信息中的每个第二信息均执行如下操作为止:Select one second information from the one or more second information, and perform the following operations on the selected second information until the following operations are performed on each of the one or more second information:
根据第一信息与选择出的第二信息在缺页队列中的位置,确定第一信息与选择出的第二信息的相关级别,得到参考级别;According to the positions of the first information and the selected second information in the page fault queue, determine the correlation level of the first information and the selected second information, and obtain the reference level;
将第一信息存储在目标相关组的第一个信息位置上,目标相关组为选择出的第二信息对应的相关级别为参考级别的相关组。The first information is stored in the first information position of the target correlation group, and the target correlation group is a correlation group whose correlation level corresponding to the selected second information is a reference level.
可选地,该一个或多个信息位置的数量为第三数量阈值,该一个或多个相关组按照相关级别的顺序依次排列;Optionally, the number of the one or more information locations is a third number threshold, and the one or more related groups are arranged in order of related levels;
第三存储子单元具体用于:The third storage subunit is specifically used for:
如果第一个信息位置上存储有内存页信息,且目标相关组存储的内存页信息的数量未达到第三数量阈值,则将目标相关组中存储的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If memory page information is stored in the first information location, and the number of memory page information stored in the target related group does not reach the third quantity threshold, move each memory page information stored in the target related group by one information location. After that, store the first information in the first information position;
如果目标相关组存储的内存页信息的数量达到第三数量阈值,且目标相关组为选择出的第二信息对应的最后一个相关组,则将目标相关组中的最后一个内存页信息删除,将其余内 存页信息后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, and the target related group is the last related group corresponding to the selected second information, the last memory page information in the target related group is deleted, and the After the remaining memory page information is moved back by one information position, the first information is stored in the first information position;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中存在空闲的信息位置,则将目标相关组以及位于目标相关组之后的相关组中首个空闲的信息位置之前的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the target related group and each memory page information before the first free information position in the related group after the target related group are moved back by one information position, and the first Information is stored in the first information location;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中不存在空闲的信息位置,则将选择出的第二信息对应的最后一个相关组中的最后一个内存页信息删除,将目标相关组以及位于目标相关组之后的相关组中的其余内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上。If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is no free information location in the subsequent related groups, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related group located after the target related group are deleted. After the rest of the memory page information is moved back by one information position, the first information is stored in the first information position.
可选地,读取模块包括:Optionally, the reading module includes:
读取单元,用于根据该多个预取信息,从指定存储空间中读取对应的数据到内存中相应的内存页上。The reading unit is configured to read the corresponding data from the specified storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
可选地,该指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。Optionally, the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
可选地,该装置还包括:Optionally, the device also includes:
第二确定模块,用于根据第一时间段内内存中的内存页的访问时间和访问数量,确定内存中的冷页面;The second determining module is configured to determine the cold page in the memory according to the access time and the access quantity of the memory page in the memory in the first time period;
移动模块,用于将冷页面上的数据从内存移动到指定存储空间中。The move module is used to move data on cold pages from memory to the specified storage space.
可选地,该装置还包括:Optionally, the device also includes:
第一接收模块,用于接收预取算法性能查询指令;a first receiving module, configured to receive a prefetch algorithm performance query instruction;
显示模块,用于显示预取算法性能信息,预取算法性能信息包括预取准确率和预取覆盖率;The display module is used to display the performance information of the prefetching algorithm, and the performance information of the prefetching algorithm includes the prefetching accuracy rate and the prefetching coverage rate;
其中,预取准确率由预取总数量和预取命中数量确定,预取覆盖率由预取总数量和访问总数量确定,预取总数量是指第二时间段内获取的所有预取信息的总数量,预取命中数量是指第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,访问总数量是指第二时间段内被访问的所有内存页的总数量。Among them, the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits, the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses, and the total number of prefetches refers to all the prefetch information obtained in the second time period. The total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period, and the total number of accesses refers to all the memory accessed in the second time period. The total number of pages.
可选地,该装置还包括:Optionally, the device also includes:
第二接收模块,用于接收预取参数调整指令,预取参数调整指令由关于预取算法性能信息的用户反馈确定;a second receiving module, configured to receive a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the performance information of the prefetch algorithm;
第三更新模块,用于根据预取参数调整指令,更新历史内存访问信息。The third update module is used to adjust the instruction according to the prefetch parameter and update the historical memory access information.
第三方面,提供了一种计算机设备,所述计算机设备包括处理器和存储器,所述存储器用于存储执行上述第一方面所提供的内存缺页异常的处理方法的程序,以及存储用于实现上述第一方面所提供的内存缺页异常的处理方法所涉及的数据。所述处理器被配置为用于执行所述存储器中存储的程序。所述存储设备的操作装置还可以包括通信总线,该通信总线用于该处理器与存储器之间建立连接。In a third aspect, a computer device is provided, the computer device includes a processor and a memory, the memory is used for storing a program for executing the method for processing a memory page fault exception provided in the first aspect, and a memory for implementing The data involved in the method for processing a memory page fault exception provided by the first aspect. The processor is configured to execute programs stored in the memory. The operating means of the storage device may further include a communication bus for establishing a connection between the processor and the memory.
第四方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面所述的内存缺页异常的处理方法。In a fourth aspect, a computer-readable storage medium is provided, where instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium runs on a computer, the computer executes the processing of the memory page fault exception described in the first aspect. method.
第五方面,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面所述的内存缺页异常的处理方法。In a fifth aspect, a computer program product containing instructions is provided, which, when running on a computer, enables the computer to execute the method for processing a memory page fault exception described in the first aspect.
上述第二方面、第三方面、第四方面和第五方面所获得的技术效果与第一方面中对应的技术手段获得的技术效果近似,在这里不再赘述。The technical effects obtained by the second aspect, the third aspect, the fourth aspect and the fifth aspect are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here.
本申请实施例提供的技术方案至少能够带来以下有益效果:The technical solutions provided in the embodiments of the present application can at least bring the following beneficial effects:
在本申请实施例中,由于历史内存访问信息能够表征历史访问内存的规律,因此,根据历史内存访问信息来预测预取信息,从而将预取信息对应的数据读取到内存中,并非盲目的预取连续的多个内存页地址的数据到内存中,也即本方案预取命中率更高,能够有效减少后续缺页异常的次数,有效降低访存时延,且本方案预取的数据更加有效,对内存资源的损耗较低,内存资源不会很紧张。In the embodiment of the present application, since the historical memory access information can represent the regularity of the historical memory access, the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind. Prefetching data of multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
附图说明Description of drawings
图1是本申请实施例提供的一种计算机设备的结构示意图;1 is a schematic structural diagram of a computer device provided by an embodiment of the present application;
图2是本申请实施例提供的一种内存缺页异常的处理方法的流程图;FIG. 2 is a flowchart of a method for processing a memory page fault exception provided by an embodiment of the present application;
图3是本申请实施例提供的一种缺页队列的示意图;3 is a schematic diagram of a page fault queue provided by an embodiment of the present application;
图4是本申请实施例提供的一种从存储的多级相关表中获取预取地址的示意图;4 is a schematic diagram of obtaining a prefetch address from a stored multi-level correlation table according to an embodiment of the present application;
图5是本申请实施例提供的另一种内存缺页异常的处理方法的流程图;5 is a flowchart of another method for processing a memory page fault exception provided by an embodiment of the present application;
图6是本申请实施例提供的一种多级相关表的示意图;6 is a schematic diagram of a multi-level correlation table provided by an embodiment of the present application;
图7是本申请实施例提供的又一种内存缺页异常的处理方法的流程图;7 is a flowchart of another method for processing a memory page fault exception provided by an embodiment of the present application;
图8是本申请实施例提供的一种内存缺页异常的处理方法的示意图;8 is a schematic diagram of a method for processing a memory page fault exception provided by an embodiment of the present application;
图9是本申请实施例提供的另一种内存缺页异常的处理方法的示意图;FIG. 9 is a schematic diagram of another method for processing a memory page fault exception provided by an embodiment of the present application;
图10是本申请实施例提供的一种内存缺页异常的处理装置的结构示意图;FIG. 10 is a schematic structural diagram of an apparatus for processing a memory page fault exception provided by an embodiment of the present application;
图11是本申请实施例提供的另一种内存缺页异常的处理装置的结构示意图;FIG. 11 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application;
图12是本申请实施例提供的又一种内存缺页异常的处理装置的结构示意图;FIG. 12 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application;
图13是本申请实施例提供的又一种内存缺页异常的处理装置的结构示意图。FIG. 13 is a schematic structural diagram of another apparatus for processing a memory page fault exception provided by an embodiment of the present application.
具体实施方式detailed description
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
本申请实施例描述的网络架构以及业务场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着网络架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The network architecture and service scenarios described in the embodiments of the present application are for the purpose of illustrating the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. The evolution of the architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
请参考图1,图1是根据本申请实施例示出的一种计算机设备的结构示意图。该计算机设备包括一个或多个处理器101、通信总线102、存储器103以及一个或多个通信接口104。Please refer to FIG. 1 , which is a schematic structural diagram of a computer device according to an embodiment of the present application. The computer device includes one or more processors 101 , a communication bus 102 , memory 103 , and one or more communication interfaces 104 .
处理器101为一个通用中央处理器(central processing unit,CPU)、网络处理器(NP)、微处理器、或者为一个或多个用于实现本申请方案的集成电路,例如,专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。可选地,上述PLD为复杂可编程逻辑器件(complex programmable logic device,CPLD),现场可编程逻辑门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。在本申请实施例中,处理器101具有实现本申请实施例提供的内存缺页异常的处理方法的功能,具体实现方式参照图2至图9实施例中的详细介绍。The processor 101 is a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or one or more integrated circuits for implementing the solution of the present application, for example, an application-specific integrated circuit ( application-specific integrated circuit, ASIC), programmable logic device (programmable logic device, PLD) or a combination thereof. Optionally, the above-mentioned PLD is a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL) or any of them. combination. In the embodiment of the present application, the processor 101 has the function of implementing the method for processing a memory page fault exception provided by the embodiment of the present application. For the specific implementation method, refer to the detailed introduction in the embodiments in FIGS. 2 to 9 .
通信总线102用于在上述组件之间传送信息。可选地,通信总线102分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus 102 is used to transfer information between the aforementioned components. Optionally, the communication bus 102 is divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
可选地,存储器103为只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、光盘(包括只读光盘(compact disc read-only memory,CD-ROM)、压缩光盘、激光盘、数字通用光盘、蓝光光盘等)、磁盘存储介质或者其它磁存储设备,或者是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其它介质,但不限于此。存储器103独立存在,并通过通信总线102与处理器101相连接,或者,存储器103与处理器101集成在一起。在本申请实施例中,存储器103包括内存和指定存储空间,指定存储空间如XL-FLASH设备的存储空间。Optionally, the memory 103 is a read-only memory (read-only memory, ROM), a random access memory (random access memory, RAM), an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM) , optical disc (including compact disc read-only memory, CD-ROM, compact disc, laser disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or can be used for portable or any other medium that stores desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. The memory 103 exists independently and is connected to the processor 101 through the communication bus 102, or the memory 103 is integrated with the processor 101. In this embodiment of the present application, the memory 103 includes a memory and a designated storage space, such as the storage space of an XL-FLASH device.
通信接口104使用任何收发器一类的装置,用于与其它设备或通信网络通信。通信接口104包括有线通信接口,可选地,还包括无线通信接口。其中,有线通信接口例如以太网接口等。可选地,以太网接口为光接口、电接口或其组合。无线通信接口为无线局域网(wireless local area networks,WLAN)接口、蜂窝网络通信接口或其组合等。 Communication interface 104 uses any transceiver-like device for communicating with other devices or a communication network. The communication interface 104 includes a wired communication interface, and optionally, a wireless communication interface. The wired communication interface is, for example, an Ethernet interface. Optionally, the Ethernet interface is an optical interface, an electrical interface or a combination thereof. The wireless communication interface is a wireless local area network (wireless local area network, WLAN) interface, a cellular network communication interface, or a combination thereof.
可选地,在一些实施例中,计算机设备包括多个处理器,如图1中所示的处理器101和处理器105。这些处理器中的每一个为一个单核处理器,或者一个多核处理器。可选地,这里的处理器指一个或多个设备、电路、和/或用于处理数据(如计算机程序指令)的处理核。Optionally, in some embodiments, the computer device includes multiple processors, such as processor 101 and processor 105 as shown in FIG. 1 . Each of these processors is a single-core processor, or a multi-core processor. Alternatively, a processor herein refers to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
在具体实现中,作为一种实施例,计算机设备还包括输出设备106和输入设备107。输出设备106和处理器101通信,能够以多种方式来显示信息。例如,输出设备106为液晶显示器(liquid crystal display,LCD)、发光二级管(light emitting diode,LED)显示设备、阴极射线管(cathode ray tube,CRT)显示设备或投影仪(projector)等。输入设备107和处理器101通信,能够以多种方式接收用户的输入。例如,输入设备107是鼠标、键盘、触摸屏设备或传感设备等。In a specific implementation, as an embodiment, the computer device further includes an output device 106 and an input device 107 . The output device 106 communicates with the processor 101 and can display information in a variety of ways. For example, the output device 106 is a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, a projector, or the like. The input device 107 communicates with the processor 101 and can receive user input in a variety of ways. For example, the input device 107 is a mouse, a keyboard, a touch screen device, a sensor device, or the like.
在一些实施例中,存储器103还用于存储执行本申请方案的程序代码110,处理器101能够执行存储器103中存储的程序代码110。该程序代码110中包括一个或多个软件模块,该计算机设备能够通过处理器101以及存储器103中的程序代码110,来实现下文图2实施例提供的内存缺页异常的处理方法。示例性地,该程序代码110包括图10实施例所示的第一确定模块、预测模块和读取模块,处理器101通过第一确定模块、预测模块和读取模块,在 内存发生缺页异常时,确定缺页预测的内存页的信息,预测预取信息,并预读内存数据到内存页上。In some embodiments, the memory 103 is further configured to store program codes 110 for executing the solutions of the present application, and the processor 101 can execute the program codes 110 stored in the memory 103 . The program code 110 includes one or more software modules, and the computer device can use the processor 101 and the program code 110 in the memory 103 to implement the processing method for the memory page fault exception provided in the embodiment of FIG. 2 below. Exemplarily, the program code 110 includes the first determination module, the prediction module and the reading module shown in the embodiment of FIG. 10 , and the processor 101 uses the first determination module, the prediction module and the reading module to cause a page fault exception in the memory. When the page fault is predicted, the information of the memory page for page fault prediction is determined, the prefetch information is predicted, and the memory data is pre-read to the memory page.
图2是本申请实施例提供的一种内存缺页异常的处理方法的流程图,该方法应用于计算机设备。请参考图2,该方法包括如下步骤。FIG. 2 is a flowchart of a method for processing a memory page fault exception provided by an embodiment of the present application, and the method is applied to a computer device. Please refer to FIG. 2 , the method includes the following steps.
步骤201:确定目标内存页的信息,得到第一信息,目标内存页为本次发生缺页异常的内存页。Step 201: Determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time.
在本申请实施例中,当计算机设备包括的处理器需要访问内存数据时,如果该内存数据不在内存包括的内存页中,则会发生缺页异常。In this embodiment of the present application, when the processor included in the computer device needs to access memory data, if the memory data is not in the memory page included in the memory, a page fault exception will occur.
示例性地,当计算机设备的操作系统中运行的一个进程需要读取内存数据时,根据需要读取的内存数据的虚拟地址,从存储的内存的虚拟地址与物理地址的映射关系中,查找对应的物理地址,如果该映射关系中不存在对应的虚拟地址和物理地址,则表示需要读取的内存数据不在内存包括的内存页中,则操作系统会触发缺页异常。Exemplarily, when a process running in the operating system of the computer device needs to read the memory data, according to the virtual address of the memory data to be read, from the mapping relationship between the virtual address and the physical address of the stored memory, find the corresponding If there is no corresponding virtual address and physical address in the mapping relationship, it means that the memory data to be read is not in the memory pages included in the memory, and the operating system will trigger a page fault exception.
当发生缺页异常时,确定本次发生缺页异常的内存页的信息,也即确定目标内存页的信息,得到第一信息。When a page fault exception occurs, the information of the memory page where the page fault exception occurs this time is determined, that is, the information of the target memory page is determined, and the first information is obtained.
需要说明的是,在本申请实施例中,内存页的信息可以为能够标识内存页的任意一种信息,例如内存页的地址,内存页的编号等,本申请实施例以内存页的信息为内存页的地址为例进行介绍。也即是,当发生缺页异常时,确定本次发生缺页异常的内存页的地址,也即确定目标内存页的地址,得到第一地址。It should be noted that, in the embodiment of the present application, the information of the memory page may be any kind of information that can identify the memory page, such as the address of the memory page, the number of the memory page, etc. In the embodiment of the present application, the information of the memory page is The address of the memory page is introduced as an example. That is, when a page fault exception occurs, the address of the memory page where the page fault exception occurs this time is determined, that is, the address of the target memory page is determined, and the first address is obtained.
在本申请实施例中,计算机设备将本次需要读取的内存数据的虚拟地址,转换为目标内存页的地址,得到第一地址,第一信息即为第一地址。需要说明的是,第一地址为目标内存页的起始地址,起始地址为一个虚拟地址。In the embodiment of the present application, the computer device converts the virtual address of the memory data to be read this time into the address of the target memory page to obtain the first address, and the first information is the first address. It should be noted that the first address is the starting address of the target memory page, and the starting address is a virtual address.
示例性地,假设内存的大小为100k,计算机设备按照每连续的4k将内存划分为连续的25个内存页,每个内存页对应一个内存页地址,每个内存页地址为对应的内存页的起始地址,例如,第一个内存页地址为0000,第二个内存页地址为0004,本次缺页异常的内存数据的虚拟地址为0011,那么用0011除以4得到的商乘以4,即得到本次缺页异常的内存页的起始地址为0008,也即第一地址为0008。Exemplarily, assuming that the size of the memory is 100k, the computer device divides the memory into 25 consecutive memory pages according to each consecutive 4k, each memory page corresponds to a memory page address, and each memory page address is the address of the corresponding memory page. The starting address, for example, the address of the first memory page is 0000, the address of the second memory page is 0004, the virtual address of the memory data of this page fault exception is 0011, then the quotient obtained by dividing 0011 by 4 is multiplied by 4 , that is, the starting address of the memory page where this page fault exception is obtained is 0008, that is, the first address is 0008.
步骤202:根据历史内存访问信息,预测与第一信息对应的多个预取信息,历史内存访问信息用于表征历史访问内存的规律。Step 202: Predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to represent the regularity of the historical memory access.
在本申请实施例中,计算机设备在得到本次发生缺页异常的内存页的信息之后,也即得到第一信息之后,根据历史内存访问信息,预测与第一信息对应的多个预取信息。其中,历史内存访问信息用于表征历史访问内存的规律。In the embodiment of the present application, after obtaining the information of the memory page where the page fault exception occurred this time, that is, after obtaining the first information, the computer device predicts a plurality of prefetch information corresponding to the first information according to the historical memory access information . Among them, the historical memory access information is used to represent the law of historical memory access.
示例性地,第一信息为第一地址,预取信息为预取地址,计算机设备根据历史内存访问信息,预测与第一地址对应的多个预取地址。Exemplarily, the first information is a first address, the prefetch information is a prefetch address, and the computer device predicts a plurality of prefetch addresses corresponding to the first address according to historical memory access information.
计算机设备根据历史内存访问信息,预测与第一信息对应的多个预取信息的实现方式有多种,接下来详细介绍其中的一种。There are various implementation manners for the computer device to predict the plurality of prefetch information corresponding to the first information according to the historical memory access information, one of which is described in detail below.
在本申请实施例中,历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的。计算机设备从存储的历史内存访问信息中获取与第一信息对应的多个预取信息。In this embodiment of the present application, the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access. The computer device acquires a plurality of prefetch information corresponding to the first information from the stored historical memory access information.
可选地,在这种实现方式中,历史内存访问信息可以称为缺页关联信息。Optionally, in this implementation manner, the historical memory access information may be referred to as page fault associated information.
在本申请实施例中,计算机设备根据历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与第一信息对应的多个预取信息。也即是,本申请实施例中的计算机设备中存储有该关联关系,计算机设备可以根据该关联关系,预测预取信息。In the embodiment of the present application, the computer device acquires a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information. That is, the association relationship is stored in the computer device in the embodiment of the present application, and the computer device can predict the prefetch information according to the association relationship.
在本申请实施例中,历史内存访问信息包括序号、缺页信息和预取信息之间的对应关系,缺页信息是指发生缺页异常的内存页的信息,序号是通过对缺页信息进行哈希运算得到的。In the embodiment of the present application, the historical memory access information includes the sequence number, the corresponding relationship between page fault information and prefetch information. obtained by the hash operation.
基于此,计算机设备从存储的历史内存访问信息中获取与第一信息对应的多个预取信息的实现过程为:计算机设备对第一信息进行哈希运算,得到第一序号,根据第一序号和第一信息,从历史内存访问信息中查找对应的多个预取信息。Based on this, the implementation process for the computer device to obtain a plurality of prefetch information corresponding to the first information from the stored historical memory access information is as follows: the computer device performs a hash operation on the first information to obtain a first serial number, and according to the first serial number and the first information, and look up the corresponding pieces of prefetch information from the historical memory access information.
示例性地,以第一信息为第一地址、预取信息为预取地址为例,计算机设备对第一地址进行哈希运算,得到第一序号,根据第一序号和第一地址,从历史内存访问信息中查找对应的多个预取地址。其中,缺页地址是历史内存访问信息中存储的触发缺页异常的内存页的地址,历史内存访问信息能够存储多个序号以及对应的记录,每个序号对应的记录中能够存储多个缺页地址,每个缺页地址对应的记录中能够存储多个预取地址。Exemplarily, taking the first information as the first address and the prefetch information as the prefetch address as an example, the computer device performs a hash operation on the first address to obtain a first serial number, and according to the first serial number and the first address, from the historical Find the corresponding multiple prefetch addresses in the memory access information. The page fault address is the address of the memory page that triggers the page fault exception stored in the historical memory access information. The historical memory access information can store multiple serial numbers and corresponding records, and the records corresponding to each serial number can store multiple page faults. address. Multiple prefetch addresses can be stored in the record corresponding to each page fault address.
示例性地,假设内存包括100个内存页,也即有100个内存页地址,假设哈希运算的参数为10,那么对内存页地址进行哈希运算之后,最多能够得到10个序号,每个序号对应的记录中最多存储10个内存页地址,这样,历史内存访问信息能够存储10个序号对应的记录,每个序号对应的记录最多存储10个缺页地址。假设第一地址为0024,计算机设备对第一地址进行哈希运算之后,得到第一序号为4,那么计算机设备根据第一序号4以及第一地址0024,从存储的历史内存访问信息中查找对应的多个预取地址。Exemplarily, assuming that the memory includes 100 memory pages, that is, there are 100 memory page addresses, and assuming that the parameter of the hash operation is 10, then after hashing the memory page addresses, at most 10 serial numbers can be obtained, each A maximum of 10 memory page addresses are stored in the record corresponding to the serial number, so that the historical memory access information can store 10 records corresponding to the serial number, and the record corresponding to each serial number can store a maximum of 10 page fault addresses. Assuming that the first address is 0024, after the computer device performs a hash operation on the first address, the first sequence number is 4, then the computer device searches the stored historical memory access information for the corresponding address according to the first sequence number 4 and the first address 0024. multiple prefetch addresses.
需要说明的是,计算机设备中配置有行数阈值(ROW),行数阈值用于指示关于内存页信息(如地址)的哈希结果的最大值,也即用于限制序号的最大值,示例性地,行数阈值为10,那么序号可以为0-9(或者1-10等),也即序号的最大值为9(或者10等)。It should be noted that a row number threshold (ROW) is configured in the computer device, and the row number threshold is used to indicate the maximum value of the hash result of memory page information (such as addresses), that is, to limit the maximum value of the sequence number. For example Typically, if the threshold of the number of rows is 10, then the sequence number can be 0-9 (or 1-10, etc.), that is, the maximum value of the sequence number is 9 (or 10, etc.).
在本申请实施例中,计算机设备根据第一序号和第一信息,从历史内存访问信息中查找对应的多个预取信息时,历史内存访问信息中有可能会存储第一信息对应的多个预取信息,也有可能没有存储第一信息对应的多个预取信息。接下来对这两种情况分别进行说明。In the embodiment of the present application, when the computer device searches the historical memory access information for a plurality of corresponding prefetch information according to the first sequence number and the first information, the historical memory access information may store a plurality of corresponding prefetch information in the historical memory access information. For the prefetch information, it is also possible that multiple pieces of prefetch information corresponding to the first information are not stored. Next, these two cases will be described separately.
历史内存访问信息中存储有第一信息对应的多个预取信息的情况:The case where multiple prefetch information corresponding to the first information is stored in the historical memory access information:
计算机设备从历史内存访问信息中查找第一序号和第一信息所在的记录,如果从历史内存访问信息中查找到第一序号和第一信息所在的记录,则从第一序号和第一信息所在的记录中查找对应的多个预取信息。The computer device searches the historical memory access information for the record where the first serial number and the first information are located. If the record where the first serial number and the first information are located is found from the historical memory access information, Find the corresponding multiple prefetch information in the records of .
示例性地,计算机设备从历史内存访问信息中查找第一序号和第一地址所在的记录,如果从历史内存访问信息中查找到第一序号和第一地址所在的记录,则从第一序号和第一地址所在的记录中查找对应的多个预取地址。Exemplarily, the computer equipment searches for the record where the first sequence number and the first address are located from the historical memory access information, and if the record where the first sequence number and the first address are located is found from the historical memory access information, then the first sequence number and the record where the first address is located are searched from the historical memory access information. The corresponding multiple prefetch addresses are searched in the record where the first address is located.
在一些实施例中,计算机设备从第一序号和第一信息所在的记录中查找对应的预取信息后,将该记录中所有的预取信息作为获取到的多个预取信息。例如,预取信息为预取地址,计算机设备将查找到的所有预取地址作为获取到的多个预取地址。In some embodiments, after searching for the corresponding prefetch information in the record where the first sequence number and the first information are located, the computer device uses all the prefetch information in the record as the acquired multiple prefetch information. For example, the prefetch information is a prefetch address, and the computer device uses all the prefetch addresses found as multiple acquired prefetch addresses.
在另一些实施例中,计算机设备按照预取深度,从第一序号和第一信息所在的记录中查找对应的多个预取信息。也即是,计算机设备从第一序号和第一信息所在的记录中查找对应的预取信息后,将该记录中总数量不超过预取深度的多个预取信息作为获取到的多个预取信 息。例如,计算机设备将查找到的记录中总数量不超过预取深度的多个预取地址作为获取到的多个预取地址。In other embodiments, the computer device searches for a plurality of corresponding pieces of prefetch information from the record where the first sequence number and the first information are located according to the prefetch depth. That is, after the computer device searches for the corresponding prefetch information from the record in which the first sequence number and the first information are located, multiple prefetch information whose total number does not exceed the prefetch depth in the record are used as the obtained multiple prefetch information. get information. For example, the computer device takes multiple prefetch addresses whose total number does not exceed the prefetch depth in the found records as the obtained multiple prefetch addresses.
需要说明的是,计算机设备中还配置有预取深度(PD),预取深度用于指示每次获取的多个预取信息(如地址)的最大数量。如果第一序号和第一信息所在的记录中的预取信息的总数量不超过PD,则计算机设备将该记录中的所有预取信息均作为获取到的多个预取信息。如果第一序号和第一信息所在的记录中的预取信息的数量超过预取深度,则计算机设备将该记录中PD个预取信息作为查找到的多个预取信息,例如,计算机设备从该记录中随机选择PD个预取信息,或者,计算机设备按照预取信息的存储时间顺序或位置顺序等方式选择PD个预取信息。It should be noted that a prefetch depth (PD) is also configured in the computer device, and the prefetch depth is used to indicate the maximum number of multiple pieces of prefetch information (eg, addresses) acquired each time. If the total quantity of the prefetch information in the record where the first sequence number and the first information are located does not exceed the PD, the computer device regards all the prefetch information in the record as the acquired multiple prefetch information. If the number of prefetch information in the record where the first sequence number and the first information are located exceeds the prefetch depth, the computer device uses PD pieces of prefetch information in the record as the found multiple prefetch information. PD pieces of prefetch information are randomly selected from the record, or the computer device selects PD pieces of prefetch information according to the storage time sequence or location sequence of the prefetch information.
历史内存访问信息中没有存储第一信息对应的多个预取信息的情况:The case where multiple prefetch information corresponding to the first information is not stored in the historical memory access information:
在本申请实施例中,如果未获取到与第一信息对应的多个预取信息,则计算机设备根据第一序号和第一信息,更新历史内存访问信息,其中,第一序号是对第一信息进行哈希运算得到的。In this embodiment of the present application, if multiple pieces of prefetch information corresponding to the first information are not obtained, the computer device updates the historical memory access information according to the first sequence number and the first information, where the first sequence number is a The information is obtained by hash operation.
示例性地,计算机设备从历史内存访问信息中查找第一序号和第一地址所在的记录,如果从历史内存访问信息中未查找到第一序号和第一地址所在的记录,则计算机设备根据第一序号和第一地址,更新历史内存访问信息。Exemplarily, the computer equipment searches for the record where the first sequence number and the first address are located from the historical memory access information, and if the record where the first sequence number and the first address are located is not found from the historical memory access information, then the computer equipment A serial number and a first address to update historical memory access information.
其中,在历史内存访问信息未存储第一序号和第一信息的情况下,计算机设备在历史内存访问信息中创建第一序号和第一信息所在的记录,以更新历史内存访问信息。在历史内存访问信息存储有第一序号,但未存储第一信息的情况下,计算机设备在第一序号的记录中存储第一信息,以更新历史内存访问信息。Wherein, when the historical memory access information does not store the first serial number and the first information, the computer device creates a record where the first serial number and the first information are located in the historical memory access information to update the historical memory access information. In the case where the historical memory access information is stored with the first serial number but does not store the first information, the computer device stores the first information in the record of the first serial number to update the historical memory access information.
示例性地,以内存页的信息为内存页的地址为例,计算机设备在第一次根据一个触发缺页异常的内存页的地址,查找预取地址时,历史内存访问信息中未存储任何信息,计算机设备将本次缺页异常的第一地址、以及对第一地址哈希运算得到的第一序号存储在历史内存访问信息中,以更新历史内存访问信息。随着计算机设备不断根据每次缺页异常的第一地址和第一序号对历史内存访问信息的更新,历史内存访问信息中不断增加新的序号和对应的缺页地址。Exemplarily, taking the information of the memory page as the address of the memory page as an example, when the computer device searches for the prefetch address according to the address of a memory page that triggers a page fault exception for the first time, no information is stored in the historical memory access information. , the computer device stores the first address of the current page fault exception and the first serial number obtained by hashing the first address in the historical memory access information, so as to update the historical memory access information. As the computer device continuously updates the historical memory access information according to the first address and the first serial number of each page fault exception, new serial numbers and corresponding page fault addresses are continuously added to the historical memory access information.
其中,计算机设备在第一序号的记录中存储第一信息的一种实现方式为:如果第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则计算机设备在第一序号的记录中存储第一信息;如果第一序号的记录中存储的缺页信息的数量达到第一数量阈值,则计算机设备删除第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在第一序号的记录中存储第一信息。Wherein, an implementation manner for the computer device to store the first information in the record of the first sequence number is: if the number of page fault information stored in the record of the first sequence number does not reach the first quantity threshold, the computer device stores the first sequence number in the first sequence number. Store the first information in the record of the first serial number; if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, then the computer equipment deletes the page fault information with the earliest storage time and the corresponding prefetching in the record of the first serial number information, the first information is stored in the record of the first serial number.
需要说明的是,在本申请实施例中,计算机设备中还配置有第一数量阈值(ASSOC),第一数量阈值用于指示同一个序号的记录中能够存储的缺页信息(如地址)的最大数量。这样,如果第一序号的记录中存储的缺页信息的数量达到ASSOC,则计算机设备删除第一序号的记录中最早存储的缺页信息以及对应的预取信息,并将第一信息存储在第一序号的记录中,也即淘汰旧信息,将最新信息更新在历史内存访问信息中。It should be noted that, in this embodiment of the present application, the computer device is also configured with a first quantity threshold (ASSOC), and the first quantity threshold is used to indicate the page fault information (such as an address) that can be stored in the records of the same serial number. greatest amount. In this way, if the number of page fault information stored in the record of the first serial number reaches ASSOC, the computer device deletes the earliest stored page fault information and the corresponding prefetch information in the record of the first serial number, and stores the first information in the first serial number. In the record of a serial number, the old information is eliminated, and the latest information is updated in the historical memory access information.
示例性地,假设内存包括100个内存页,也即有100个内存页地址,假设行数阈值ROW为10,那么对内存页地址进行哈希运算之后,最多能够得到10个序号,每个序号的记录中最多对应存储10个内存页地址,这样,历史内存访问信息能够存储10个序号以及对应的记 录,每个序号的记录中最多存储10个缺页地址。假设第一数量阈值为4,也即每个序号最多对应存储4个缺页地址,第一序号的记录中已经存储有4个缺页地址,那么计算机设备将这4个缺页地址中最早存储的缺页地址以及对应的预取地址删除,再将第一地址存储在第一序号对应的记录中。Exemplarily, assuming that the memory includes 100 memory pages, that is, there are 100 memory page addresses, and assuming that the row number threshold ROW is 10, after hashing the memory page addresses, at most 10 serial numbers can be obtained, each serial number. A maximum of 10 memory page addresses can be stored in the records of , so that the historical memory access information can store 10 serial numbers and corresponding records, and a maximum of 10 page fault addresses can be stored in the records of each serial number. Assuming that the first number threshold is 4, that is, each serial number stores at most 4 page fault addresses, and the record of the first serial number has already stored 4 page fault addresses, then the computer device stores the earliest of these 4 page fault addresses. The page fault address and the corresponding prefetch address are deleted, and then the first address is stored in the record corresponding to the first serial number.
需要说明的是,第一数量阈值ASSOC的值可以小于每个序号最多对应存储的内存页地址的数量,例如,在上述示例中,每个序号最多对应存储10个内存页地址,但第一数量阈值设置为4,小于10,这样,计算机设备通过对内存页地址的哈希运算,以及设置第一数量阈值较小,以减小存储的数据量,仅在历史内存访问信息中存储相对较新的信息,在保证预取准确率的同时,加快从历史内存访问信息中获取预取信息的速率。It should be noted that the value of the first number threshold ASSOC may be smaller than the number of memory page addresses that each sequence number stores at most. For example, in the above example, each sequence number corresponds to storing 10 memory page addresses at most, but the first number The threshold is set to 4, which is less than 10. In this way, the computer device can reduce the amount of stored data by hashing the memory page addresses and setting the first number threshold smaller, and only store relatively new data in historical memory access information. information, while ensuring the accuracy of prefetching, and speeding up the rate of obtaining prefetching information from historical memory access information.
上述将第一信息存储在第一序号的记录中的方式可以理解为一种LRU的方式,通过这种方式淘汰最早存储的缺页信息。The above-mentioned method of storing the first information in the record of the first serial number can be understood as a LRU method, in which the earliest stored page fault information is eliminated.
不管历史内存访问信息中是否存储有第一信息对应的多个预取信息,在计算机设备确定第一信息之后,还能够根据缺页队列,更新历史内存访问信息。Regardless of whether multiple prefetch information corresponding to the first information is stored in the historical memory access information, after the computer device determines the first information, the historical memory access information can also be updated according to the page fault queue.
需要说明的是,在本申请实施例中,计算机设备中还存储有缺页队列,缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息,也即按照时间顺序存储历史访问内存时触发缺页异常的内存页的信息。It should be noted that, in the embodiment of the present application, a page fault queue is also stored in the computer device, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order, that is, to store the historical access memory in chronological order. Information about the memory page that triggers the page fault exception.
在本申请实施例中,计算机设备根据缺页队列MQ,更新历史内存访问信息的实现方式包括如下几个步骤:In the embodiment of the present application, the implementation manner of the computer device updating historical memory access information according to the page fault queue MQ includes the following steps:
(1)将第一信息存储在缺页队列中。(1) Store the first information in the page fault queue.
在本申请实施例中,计算机设备在缺页队列中存储第一信息的实现方式有多种,接下来介绍其中的两种实现方式。In the embodiments of the present application, there are multiple implementations for the computer device to store the first information in the page fault queue, and two implementations are described below.
方式1,计算机设备将第一信息(如地址)存储在缺页队列的队尾。在这种存储方式中,可选地,计算机设备每隔一个时间周期删除缺页队列中的过期数据,例如将存储时间距离当前时间超过时间阈值的内存页信息删除,或者,保留缺页队列中存储时间较近的指定数量的内存页信息,而将缺页队列中存储时间较早的其他内存页信息删除,以在节省存储空间的同时,保证缺页队列中存储的内存页信息的数据时效性。In Mode 1, the computer device stores the first information (eg, address) at the end of the page fault queue. In this storage method, optionally, the computer device deletes the expired data in the page fault queue every time period, for example, deletes the memory page information whose storage time exceeds the time threshold from the current time, or keeps the page fault queue in the The specified amount of memory page information with a relatively recent storage time is deleted, and other memory page information with an earlier storage time in the page fault queue is deleted, so as to save storage space and ensure the data aging of the memory page information stored in the page fault queue. sex.
在方式1中,最新存储的第一信息(如地址)总是位于缺页队列的队尾。In mode 1, the newly stored first information (eg, address) is always located at the end of the page fault queue.
方式2,计算机设备中还配置有缺页队列长度MQ_L,缺页队列长度用于指示缺页队列中能够存储的内存页信息(如地址)的最大数量。在这种存储方式中,计算机设备从第一次在MQ中记录内存页信息时开始计数,每次计数后得到的值作为缺页总数量,也即计算机设备累计缺页次数,得到缺页总数量。计算机设备在本次得到第一信息,并计数得到的缺页总数量后,计算缺页总数量除以缺页队列长度得到一个余数,根据该余数确定第一信息在缺页队列中的存储位置,将第一信息存储在该存储位置上。In mode 2, the computer device is further configured with a page fault queue length MQ_L, and the page fault queue length is used to indicate the maximum number of memory page information (eg addresses) that can be stored in the page fault queue. In this storage method, the computer device starts counting from the first time the memory page information is recorded in the MQ, and the value obtained after each count is used as the total number of page faults, that is, the computer device accumulates the number of page faults, and obtains the total number of page faults. quantity. After obtaining the first information this time and counting the total number of page faults obtained, the computer device calculates the total number of page faults divided by the length of the page fault queue to obtain a remainder, and determines the storage location of the first information in the page fault queue according to the remainder. , and store the first information in the storage location.
示例性地,假设缺页队列长度为128,也即缺页队列中最多存储128个发生缺页异常的内存页的信息,缺页队列的存储位置包括0-127(或者1-128)。Exemplarily, it is assumed that the length of the page fault queue is 128, that is, the page fault queue stores information on at most 128 memory pages where page fault exceptions occur, and the storage locations of the page fault queue include 0-127 (or 1-128).
假设计算机设备得到本次缺页异常的第一地址对应的缺页总数量为36,此时缺页队列还未存满,计算机设备用36除以128,得到余数36,那么计算机设备根据该余数确定第一信息的存储位置为35(或者36),将第一信息存储在缺页队列中的该存储位置上。Assuming that the total number of page faults corresponding to the first address of the page fault exception obtained by the computer device is 36, and the page fault queue is not full at this time, the computer device divides 36 by 128 to obtain a remainder of 36, then the computer device according to the remainder It is determined that the storage location of the first information is 35 (or 36), and the first information is stored in the storage location in the page fault queue.
假设计算机设备得到本次缺页异常的第一信息对应的缺页总数量为139,此时缺页队列 已经存满,计算机设备用139除以128,得到余数11,那么计算机设备根据该余数确定第一信息的存储位置为10(或者11),将第一信息存储在缺页队列中的该存储位置上,也即将该存储位置上之前存储的内存页信息覆盖掉。Assuming that the total number of page faults corresponding to the first information of this page fault exception obtained by the computer device is 139, and the page fault queue is full at this time, the computer device divides 139 by 128 to obtain a remainder of 11, then the computer device determines according to the remainder. The storage location of the first information is 10 (or 11), and the first information is stored in the storage location in the page fault queue, that is, the memory page information previously stored in the storage location is overwritten.
在方式2中,以循环存储的方式在缺页队列中存储第一信息(如地址),最新存储的第一信息并不一定位于缺页队列的队尾。In Mode 2, the first information (eg, address) is stored in the page fault queue in a circular storage manner, and the newly stored first information is not necessarily located at the end of the page fault queue.
由上述可知,在计算机设备中删除缺页队列中的过期数据,或者还配置有缺页队列长度的存储方式中,能够在节省存储空间的同时,保证缺页队列中存储的内存页信息的数据时效性。It can be seen from the above that in the computer device deleting the expired data in the page fault queue, or also configuring the storage mode of the page fault queue length, the data of the memory page information stored in the page fault queue can be guaranteed while saving storage space. Timeliness.
(2)获取缺页队列中位于第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息。(2) Acquire information of memory pages in the page fault queue that are located before the first information and whose quantity does not exceed a second quantity threshold, and obtain one or more pieces of second information.
需要说明的是,在本申请实施例中,计算机设备中还配置有第二数量阈值(LEVEL),第二数量阈值用于指示从缺页队列中获取的第二信息的最大数量。It should be noted that, in this embodiment of the present application, a second quantity threshold (LEVEL) is further configured in the computer device, and the second quantity threshold is used to indicate the maximum quantity of the second information obtained from the page fault queue.
由前述可知,计算机设备在缺页队列中存储第一信息的实现方式有多种,相应地,计算机设备从缺页队列中获取第二信息的实现方式也有多种,接下来介绍与上述在缺页队列中存储第一信息的方式1和方式2分别对应的两种实现方式。It can be seen from the foregoing that there are many ways for the computer device to store the first information in the page fault queue, and correspondingly, there are many ways for the computer device to obtain the second information from the page fault queue. There are two implementation manners corresponding to manner 1 and manner 2 of storing the first information in the page queue respectively.
假设计算机设备按照上述方式1在缺页队列中存储第一信息,也即总是将第一信息存储在缺页队列的队尾,那么计算机设备直接获取缺页队列中第一信息之前数量不超过第二数量阈值的内存页信息,即得到该一个或多个第二信息。Assuming that the computer device stores the first information in the page fault queue according to the above method 1, that is, always stores the first information at the end of the page fault queue, then the computer device directly obtains the first information in the page fault queue. The memory page information of the second quantity threshold is obtained, that is, the one or more pieces of second information are obtained.
例如,以内存页信息为内存页地址为例,缺页队列中当前存储的内存页地址包括m1、m2、m3、m4、m5,第一地址为m5,第二数量阈值为3,那么计算机设备获取m2、m3和m4作为获取的3个第二地址。For example, taking the memory page information as the memory page address as an example, the memory page addresses currently stored in the page fault queue include m1, m2, m3, m4, and m5, the first address is m5, and the second quantity threshold is 3, then the computer equipment Acquire m2, m3, and m4 as the acquired 3 second addresses.
假设计算机设备按照上述方式2在缺页队列中存储第一信息,也即第一信息不一定存储在缺页队列的队尾,在这种情况下,如果缺页队列中第一信息之前的内存页信息的数量不少于第二数量阈值,则计算机设备直接获取缺页队列中第一信息之前数量不超过第二数量阈值的内存页信息,即得到该一个或多个第二信息。如果缺页队列中第一信息之前的内存页信息的数量少于第二数量阈值,且缺页队列存满的情况下,计算机设备获取缺页队列中第一信息之前的内存页信息,以及获取从队尾往前的部分内存页信息,得到数量为第二数量阈值的一个或多个第二信息。也即是,在计算机设备通过循环存储的方式在缺页队列中存储第一信息时,计算机设备也通过往前循环的方式获取第二信息。It is assumed that the computer device stores the first information in the page fault queue according to the above method 2, that is, the first information is not necessarily stored at the end of the page fault queue. In this case, if the memory before the first information in the page fault queue is The quantity of page information is not less than the second quantity threshold, and the computer device directly obtains the memory page information whose quantity does not exceed the second quantity threshold before the first information in the page fault queue, that is, obtains the one or more second information. If the number of memory page information before the first information in the page fault queue is less than the second quantity threshold, and the page fault queue is full, the computer device obtains the memory page information before the first information in the page fault queue, and obtains Part of the memory page information from the end of the queue forward, obtains one or more second information whose quantity is the second quantity threshold. That is, when the computer device stores the first information in the page fault queue by means of circular storage, the computer device also acquires the second information by means of forward circular storage.
例如,以内存页信息为内存页地址为例,缺页队列中当前存储的内存页地址包括m1、m2、m3、m4、m5、m6、m7、m8,第一地址为m2,第二数量阈值为3,那么计算机设备获取m1、m8和m7作为获取的3个第二地址,这样在缺页队列中存储有除第一地址之外不少于第二数量阈值的内存页地址的情况下,保证获取到数量为第二数量阈值的一个或多个第二地址。For example, taking the memory page information as the memory page address as an example, the memory page addresses currently stored in the page fault queue include m1, m2, m3, m4, m5, m6, m7, m8, the first address is m2, and the second quantity threshold is 3, then the computer device acquires m1, m8 and m7 as the acquired 3 second addresses, so that when the page fault queue stores memory page addresses that are not less than the second number threshold in addition to the first address, One or more second addresses are guaranteed to be acquired in a quantity equal to the second quantity threshold.
(3)将第一信息作为该一个或多个第二信息中每个第二信息对应的预取信息,存储在历史内存访问信息中。(3) The first information is stored in the historical memory access information as the prefetch information corresponding to each of the one or more second information.
在本申请实施例中,计算机设备根据第一信息与该一个或多个第二信息中每个第二信息在缺页队列中的位置关系,在历史内存访问信息中存储第一信息与每个第二信息的关联关系。In the embodiment of the present application, the computer device stores the first information and each second information in the historical memory access information according to the positional relationship between the first information and the one or more second information in the page fault queue. The relationship of the second information.
可选地,在本申请实施例中,该一个或多个第二信息中的每个第二信息对应有一个或多 个相关组,该一个或多个相关组的数量为第二数量阈值,每个相关组对应有一个或多个信息位置,每个相关组对应一个相关级别,每个相关组用于存储预取信息。基于此,计算机设备从该一个或多个第二信息中选择一个第二信息,对于选择出的第二信息执行如下操作,直至对该一个或多个第二信息中的每个第二信息均执行如下操作为止:根据第一信息与选择出的第二信息在缺页队列中的位置,确定第一信息与选择出的第二信息的相关级别,得到参考级别,将第一信息存储在目标相关组的第一个信息位置上,其中,目标相关组为选择出的第二信息对应的相关级别为参考级别的相关组。Optionally, in this embodiment of the present application, each of the one or more second information corresponds to one or more related groups, and the number of the one or more related groups is a second number threshold, Each correlation group corresponds to one or more information locations, each correlation group corresponds to a correlation level, and each correlation group is used to store prefetch information. Based on this, the computer device selects one second information from the one or more second information, and performs the following operations on the selected second information until each of the one or more second information is Perform the following operations until: according to the positions of the first information and the selected second information in the page fault queue, determine the correlation level of the first information and the selected second information, obtain a reference level, and store the first information in the target at the first information position of the related group, wherein the target related group is a related group whose related level corresponding to the selected second information is a reference level.
需要说明的是,缺页队列中存储的两个内存页信息(如地址)的位置越近,在一定程度上表示这两个内存页信息的关联程度(相关程度)越高。基于此,计算机设备根据第一信息与每个第二信息在缺页队列中的位置,确定第一信息与相应第二信息的相关级别,得到参考级别,将第一信息存储在历史内存访问信息中相应第二信息对应的目标相关组中的第一个信息位置上。It should be noted that the closer the locations of the two memory page information (eg addresses) stored in the page fault queue are, the higher the correlation degree (correlation degree) of the two memory page information to a certain extent. Based on this, the computer device determines the correlation level of the first information and the corresponding second information according to the position of the first information and each second information in the page fault queue, obtains the reference level, and stores the first information in the historical memory access information at the first information position in the target related group corresponding to the corresponding second information in .
示例性地,以内存页信息为内存页地址、信息位置为地址位置为例,假设缺页队列包括m1、m2、m3、m4、m5、m6、m7、m8,第一地址为m4,第二数量阈值为3,m1、m2和m3为获取的3个第二地址,每个第二地址对应3个相关组,那么计算机设备根据m1和m4在缺页队列中的位置,确定m4与m1的相关级别为3,将m4存储在m1对应的第三个相关组中的第一个地址位置上;根据m2和m4在缺页队列中的位置,确定m4与m2的相关级别为2,将m4存储在m2对应的第二个相关组中的第一个地址位置上;根据m3和m4在缺页队列中的位置,确定m4与m3的相关级别为1,将m4存储在m1对应的第一个相关组中的第一个地址位置上。Exemplarily, taking the memory page information as the memory page address and the information location as the address location as an example, it is assumed that the page fault queue includes m1, m2, m3, m4, m5, m6, m7, and m8, the first address is m4, and the second The number threshold is 3, m1, m2, and m3 are the three acquired second addresses, and each second address corresponds to three related groups. Then the computer device determines the relationship between m4 and m1 according to the positions of m1 and m4 in the page fault queue. The correlation level is 3, and m4 is stored at the first address position in the third correlation group corresponding to m1; according to the positions of m2 and m4 in the page fault queue, the correlation level between m4 and m2 is determined to be 2, and m4 It is stored in the first address position in the second correlation group corresponding to m2; according to the positions of m3 and m4 in the page fault queue, determine that the correlation level between m4 and m3 is 1, and store m4 in the first address corresponding to m1. at the first address position in the associated group.
可选地,为了快速确定该一个或多个第二信息在历史内存访问信息中的位置,计算机设备对每个第二信息进行哈希运算,得到相应第二信息对应的序号,从历史内存访问信息中查找对应的序号,在从对应的序号的记录中存储的缺页信息中查找相应第二信息。Optionally, in order to quickly determine the position of the one or more second information in the historical memory access information, the computer device performs a hash operation on each second information, obtains the sequence number corresponding to the corresponding second information, and accesses the information from the historical memory. The corresponding serial number is searched in the information, and the corresponding second information is searched from the page fault information stored in the record of the corresponding serial number.
由于在将第一信息作为预取信息存储在历史内存访问信息中的目标相关组之前,目标相关组的第一个信息位置上可能已经存储有预取信息(也即存储有内存页信息),那么计算机设备需要先移动和/或删除相应第二信息包括的相关组中存储的预取信息后,将第一信息存储在目标相关组的第一个信息位置上。Because before the first information is stored as the prefetch information in the target related group in the historical memory access information, the prefetch information (that is, the memory page information is stored) may already be stored in the first information position of the target related group, Then, the computer device needs to first move and/or delete the prefetched information stored in the relevant group included in the corresponding second information, and then store the first information in the first information position of the target relevant group.
可选地,每个相关组对应的一个或多个信息位置的数量为第三数量阈值,该一个或多个相关组按照相关级别的顺序依次排列。也即是,在本申请实施例中,计算机设备中还配置有第三数量阈值(SUCC),第三数量阈值用于指示每个相关组中能够存储的预取信息(如地址)的最大数量。基于此,计算机设备将第一信息存储在目标相关组的第一个信息位置上包括多种情况:Optionally, the number of one or more information locations corresponding to each related group is a third number threshold, and the one or more related groups are arranged in order of related levels. That is, in this embodiment of the present application, the computer device is further configured with a third quantity threshold (SUCC), and the third quantity threshold is used to indicate the maximum quantity of prefetch information (such as addresses) that can be stored in each relevant group. . Based on this, the computer device stores the first information in the first information location of the target related group, including various situations:
情况1,如果目标相关组的第一个信息位置上未存储内存页信息,则计算机设备将第一信息存储在目标相关组的第一个信息位置上。In case 1, if the memory page information is not stored in the first information position of the target related group, the computer device stores the first information in the first information position of the target related group.
情况2,如果目标相关组的第一个信息位置上存储有内存页信息,且目标相关组存储的内存页信息的数量未达到第三数量阈值,则计算机设备将目标相关组中存储的每个内存页信息均后移一个信息位置后,将第一信息存储在目标相关组的第一个信息位置上。 Case 2, if there is memory page information stored in the first information position of the target related group, and the number of memory page information stored in the target related group does not reach the third quantity threshold, the computer device will store each memory page in the target related group. After the memory page information is moved back by one information position, the first information is stored in the first information position of the target related group.
情况3,如果目标相关组存储的内存页信息的数量达到第三数量阈值,且目标相关组为选择出的第二信息对应的最后一个相关组,则将目标相关组中的最后一个内存页信息删除, 将目标相关组中其余内存页信息后移一个信息位置后,将第一信息存储在目标相关组的第一个信息位置上。 Case 3, if the number of memory page information stored in the target related group reaches the third quantity threshold, and the target related group is the last related group corresponding to the selected second information, then the last memory page information in the target related group is stored. Deleting, after moving the remaining memory page information in the target related group by one information position, the first information is stored in the first information position of the target related group.
情况4,如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中存在空闲的信息位置,则将目标相关组以及位于目标相关组之后的相关组中首个空闲的信息位置之前的每个内存页信息均后移一个信息位置后,将第一信息存储在目标相关组的第一个信息位置上。Case 4, if the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the selected second information corresponds to the related group in the relevant group. If there is an idle information position in the related group after the target related group, move the target related group and each memory page information before the first free information position in the related group after the target related group by one information position. The first information is stored at the first information location of the target related group.
情况5,如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中不存在空闲的信息位置,则将选择出的第二信息对应的最后一个相关组中的最后一个内存页信息删除,将目标相关组以及位于目标相关组之后的相关组中的其余内存页信息均后移一个信息位置后,将第一信息存储在目标相关组的第一个信息位置上。Case 5, if the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the selected second information corresponds to the related group in the relevant group. If there is no free information location in the related group after the target related group, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related information located after the target related group are deleted. After the rest of the memory page information in the group is moved back by one information position, the first information is stored in the first information position of the target related group.
由上述可知,计算机设备通过一种顺次后移的方式,将第一信息存储在目标相关组的第一个信息位置上,可以将这种实现方式理解为通过MRU的方式将第一信息插入每个第二信息对应的目标相关组中。It can be seen from the above that the computer equipment stores the first information in the first information position of the target related group in a sequential backward manner. This implementation can be understood as inserting the first information into the MRU method. in a target related group corresponding to each second information.
可选地,计算机设备中配置一个第三数量阈值,或者,配置多个第三数量阈值,每个相关组对应一个第三数量阈值,这样,能够更加灵活地配置每个相关组中最多能够存储的预取信息的数量,例如配置相关程度较高(如相关级别为一级)的相关组对应的第三数量阈值较大,配置相关程度较低(如相关级别为三级)的相关组对应的第三数量阈值较小,这样可以在一定程度上提高预取准确率。Optionally, a third quantity threshold is configured in the computer device, or a plurality of third quantity thresholds are configured, and each relevant group corresponds to a third quantity threshold. The quantity of prefetch information, for example, the third quantity threshold corresponding to the related group with a high degree of configuration correlation (for example, the correlation level is level 1) is larger, and the related group with a low level of configuration correlation (for example, the correlation level is level 3) corresponds to The threshold of the third quantity is smaller, which can improve the prefetching accuracy to a certain extent.
通过以上方式,计算机设备在每次发生缺页异常后,从存储的历史内存访问信息中获取预取信息,以及对历史内存访问信息进行更新,上述介绍的实现方式可以理解为,计算机设备通过一种预取算法来预测预取信息(如地址),也即计算机设备中配置有预取算法,计算机设备通过运行预取算法不断地更新历史内存访问信息,通过历史内存访问信息记录历史访问内存的规律。Through the above methods, the computer device obtains prefetch information from the stored historical memory access information and updates the historical memory access information after each page fault exception occurs. A prefetch algorithm to predict prefetch information (such as addresses), that is, the computer device is configured with a prefetch algorithm, the computer device continuously updates the historical memory access information by running the prefetch algorithm, and records the historical memory access information through the historical memory access information. law.
可选地,计算机设备中配置有预取算法(可以理解为软件模块),配置的预取算法包括预取参数,预取参数包括上述介绍的行数阈值(ROW)、第一数量阈值(ASSOC)、第二数量阈值(LEVEL)、第三数量阈值(SUCC)、预取深度(PD)和缺页队列长度(MQ_L),其中,第一数量阈值、预取深度和缺页队列长度可选择配置或者不配置。在不配置第一数量阈值的情况下,每个序号能够存储最多的缺页信息(如地址),在不配置预取深度的情况下,将第一序号和第一信息的记录中的所有预取信息作为获取到的预取信息,在不配置缺页队列长度的情况下,计算机设备将第一信息存储在缺页队列的队尾。Optionally, a prefetch algorithm (which can be understood as a software module) is configured in the computer device, and the configured prefetch algorithm includes a prefetch parameter, and the prefetch parameter includes the row number threshold (ROW) and the first number threshold (ASSOC) introduced above. ), the second quantity threshold (LEVEL), the third quantity threshold (SUCC), the prefetch depth (PD) and the page fault queue length (MQ_L), wherein the first quantity threshold, the prefetch depth and the page fault queue length can be selected Configure or not configure. In the case where the first number threshold is not configured, each sequence number can store the most page fault information (such as addresses), and in the case where the prefetch depth is not configured, the first sequence number and all prefetched information in the record of the first information are stored. The information is taken as the acquired prefetch information, and the computer device stores the first information at the end of the page fault queue without configuring the length of the page fault queue.
以上介绍的关于计算机设备通过存储的历史内存访问信息中预测预取信息的实现方式,可选地,计算机设备可以以任一种存储数据的方式来存储历史内存访问信息,例如以表格形式存储历史内存访问信息。接下来介绍以表格形式存储历史内存访问信息,以及以内存页信息为内存页地址为例,再次对以上过程进行解释说明,可选地,表格形式的历史内存访问信息可以称为多级相关表MLCT,接下来以MLCT、且内存页的信息为内存页的地址为例进行介绍。Regarding the implementation of the computer device predicting the prefetch information from the stored historical memory access information described above, optionally, the computer device can store the historical memory access information in any way of storing data, such as storing the historical memory access information in a table form. Memory access information. Next, we will introduce the storage of historical memory access information in tabular form, and take the memory page information as the memory page address as an example, and explain the above process again. Optionally, the historical memory access information in tabular form can be called a multi-level correlation table. MLCT, the following is an example of MLCT, and the information of the memory page is the address of the memory page.
假设计算机设备种配置有预取算法,预取算法包括预取参数,预取参数包括行数阈值、 第一数量阈值、第二数量阈值、第三数量阈值、预取深度和缺页队列长度,计算机设备根据缺页队列更新存储的MLCT。Assuming that the computer device is configured with a prefetch algorithm, the prefetch algorithm includes a prefetch parameter, and the prefetch parameter includes a row number threshold, a first number threshold, a second number threshold, a third number threshold, a prefetch depth, and a page fault queue length, The computer device updates the stored MLCT according to the page fault queue.
在本申请实施例中,用户可以通过计算机设备配置预取算法,包括配置预取参数,其中,In this embodiment of the present application, a user may configure a prefetch algorithm through a computer device, including configuring a prefetch parameter, wherein:
ROW:R,关于内存页地址的哈希结果的最大值,也即用于限制序号的最大值;ROW: R, the maximum value of the hash result of the memory page address, that is, the maximum value used to limit the serial number;
ASSOC:同一个哈希结果对应的tags(T)中,能够记录的内存页地址的最大数量,也即同一个序号的记录中存储的内存页地址的最大数量;ASSOC: In the tags (T) corresponding to the same hash result, the maximum number of memory page addresses that can be recorded, that is, the maximum number of memory page addresses stored in the record of the same serial number;
LEVEL:LEV,每一个tag对应的内存页地址对应的相关组的数量;LEVEL: LEV, the number of related groups corresponding to the memory page address corresponding to each tag;
SUCC:每个相关组中能够存储的内存页地址的最大数量;SUCC: the maximum number of memory page addresses that can be stored in each relevant group;
PD:每次获取的多个预取地址的最大数量;PD: the maximum number of multiple prefetch addresses acquired each time;
MQ_L:缺页队列长度。MQ_L: The page fault queue length.
示例性地,用户在计算机设备中输入命令行insmod smap_prefetch.ko ROW=4 ASSOC=4 LEVEL=2 SUCC=3 PD=6 MQ_L=128,其中,insmod表示加载模块,smap_prefetch.ko为预取算法模块,计算机设备中的处理器根据该命令行加载预取算法模块,并将预取参数传递到预取算法模块。Exemplarily, the user enters the command line insmod smap_prefetch.ko ROW=4 ASSOC=4 LEVEL=2 SUCC=3 PD=6 MQ_L=128 in the computer device, wherein, insmod represents the loading module, and smap_prefetch.ko is the prefetching algorithm module , the processor in the computer device loads the prefetch algorithm module according to the command line, and transmits the prefetch parameter to the prefetch algorithm module.
参见图3,对缺页队列(MQ)、第三数量阈值(SUCC)进行解释说明。在图3中,MQ中按照时间顺序存储每次缺页异常的内存页的地址,包括A、B、C、D、E、F、G、H、I,假设本次发生缺页异常的第一地址为E,第三数量阈值为3,那么获取MQ中的B、C和D得到3个第二地址,其中,E与B的相关级别为3,E与C的相关级别为2,E与D的相关级别为1,可以理解为E是B的三级后继(level 3 successor,L3 SUCCE),E是C的二级后继(level 2 successor,L2 SUCCE),E是D的一级后继(level 1 successor,L1 SUCCE),那么将第一地址E存储在B的三级相关组中,将E存储在C的二级相关组中,将E存储在D的一级相关组中,得到存储有B、C和D以及对应的预取地址的多级相关表。Referring to FIG. 3 , the page fault queue (MQ) and the third quantity threshold (SUCC) will be explained. In Figure 3, MQ stores the addresses of the memory pages of each page fault exception in chronological order, including A, B, C, D, E, F, G, H, and I. Assume that the page fault occurs on the first page. One address is E, and the third quantity threshold is 3, then obtain B, C and D in MQ to get 3 second addresses, where the correlation level between E and B is 3, the correlation level between E and C is 2, and the correlation level between E and C is 2. The correlation level with D is 1, which can be understood as E is the third-level successor of B (level 3 successor, L3 SUCCE), E is the second-level successor of C (level 2 successor, L2 SUCCE), E is the first-level successor of D (level 1 successor, L1 SUCCE), then store the first address E in the third-level correlation group of B, store E in the second-level correlation group of C, and store E in the first-level correlation group of D, obtaining A multi-level correlation table storing B, C, and D and the corresponding prefetch addresses.
参见图4,对预取深度(PD)进行解释,图4所示的多级相关表中存储有第一地址E以及对应的预取地址,E对应的一级相关组(level 1 group,L1G)中存储有A和C,二级相关组(level 2 group,L2G)中存储有B和D,三级相关组中存储有H,假设预取深度为3,那么计算机设备获取A、C和B作为预取地址。Referring to Figure 4, the prefetch depth (PD) is explained. The multi-level correlation table shown in Figure 4 stores the first address E and the corresponding prefetch address, and the level 1 group corresponding to E (level 1 group, L1G). ), A and C are stored in ), B and D are stored in the level 2 group (L2G), and H is stored in the third-level correlation group. Assuming that the prefetch depth is 3, then the computer device obtains A, C and B as the prefetch address.
参见图5,计算机设备根据以下步骤来处理缺页异常。Referring to FIG. 5, the computer device handles the page fault exception according to the following steps.
1、当触发缺页异常时,确定缺失的内存数据的虚拟地址va,根据该虚拟地址va,确定本次缺页异常的内存页的起始地址,得到第一地址va p1. When a page fault exception is triggered, the virtual address va of the missing memory data is determined, and according to the virtual address va, the starting address of the memory page of the current page fault exception is determined, and the first address va p is obtained.
示例性地,假设内存的大小为100k,按照每连续的4k将内存划分为连续的25个内存页,每个内存页对应一个内存页地址,每个内存页地址为对应的内存页的起始地址,例如,第一个内存页地址为0000,第二个内存页地址为0004,本次缺页异常的内存数据的虚拟地址为0011,那么用0011除以4得到的商乘以4,即得到本次缺页异常的内存页的起始地址为0008,也即第一地址为0008。Exemplarily, assuming that the size of the memory is 100k, the memory is divided into 25 consecutive memory pages according to each consecutive 4k, each memory page corresponds to a memory page address, and each memory page address is the start of the corresponding memory page. For example, if the address of the first memory page is 0000, the address of the second memory page is 0004, and the virtual address of the memory data of this page fault exception is 0011, then the quotient obtained by dividing 0011 by 4 is multiplied by 4, that is, The starting address of the memory page where this page fault exception is obtained is 0008, that is, the first address is 0008.
2、对第一地址va p进行哈希运算,得到第一序号r p2. Perform a hash operation on the first address va p to obtain the first serial number rp .
示例性地,假设预取参数包括的行数阈值ROW为10,序号从0开始,哈希运算能够得到序号的最大值为9,第一地址为0008,根据哈希运算用0008除以10得到的商为0,将0作为第一序号。Exemplarily, assuming that the row number threshold ROW included in the prefetch parameter is 10, the sequence number starts from 0, the maximum value of the sequence number that can be obtained by the hash operation is 9, and the first address is 0008. According to the hash operation, divide 0008 by 10 to obtain The quotient is 0, and 0 is used as the first sequence number.
3、从多级相关表(MLCT)中查找第一序号r p,如果查找到第一序号r p,则从第一序号 r p对应的tags中查找第一地址va p,如果查找到第一地址va p,则计算机设备根据预取深度PD,获取对应的多个预取地址。其中tags对应的列用于存储缺页地址。 3. Find the first sequence number rp from the multi-level correlation table ( MLCT ). If the first sequence number rp is found, the first address va p is searched from the tags corresponding to the first sequence number rp . If the first sequence number rp is found address va p , the computer device obtains a plurality of corresponding prefetch addresses according to the prefetch depth PD. The column corresponding to tags is used to store the page fault address.
如果未查找到第一序号r p,则计算机设备在MLCT中增加第一序号r p,并将第一地址va p增加在第一序号r p对应的一个tag中; If the first sequence number rp is not found, the computer device adds the first sequence number rp in the MLCT , and adds the first address va p to a tag corresponding to the first sequence number rp ;
如果查找到第一序号r p,但未查找到va p,则计算机设备采用LRU的方式将第一地址va p存储在第一序号r p对应的一个tag中。 If the first serial number rp is found, but va p is not found, the computer device stores the first address va p in a tag corresponding to the first serial number rp in an LRU manner.
其中,采用LRU方式在第一序号中存储第一地址va p的方式为:如果该第一序号r p对应的tags中记录的内存页地址的数量达到第一数量阈值(ASSOC),则计算机设备将该tags中存储时间最早的内存页地址删除后,将第一地址va p增加在tags中;如果该第一序号r p对应的tags中记录的内存页地址的数量未达到第一数量阈值,则计算机设备直接将第一地址va p增加在tags中。 Wherein, the LRU method is used to store the first address va p in the first sequence number as follows: if the number of memory page addresses recorded in the tags corresponding to the first sequence number r p reaches the first number threshold (ASSOC), then the computer equipment After deleting the memory page address with the earliest storage time in the tags, the first address va p is added to the tags; if the number of memory page addresses recorded in the tags corresponding to the first serial number r p does not reach the first number threshold, Then the computer device directly adds the first address va p to tags.
4、如果获取到多个预取地址,则从指定存储空间中将对应的数据读取到内存中。4. If multiple prefetch addresses are obtained, the corresponding data is read into the memory from the specified storage space.
5、将第一地址va p存储在缺页队列MQ中,作为MQ中的m p(配置有缺页队列长度,以循环方式存储)。 5. Store the first address va p in the page fault queue MQ as mp in the MQ (configured with the page fault queue length and stored in a circular manner).
6、根据第二数量阈值(LEVEL,理解为几级后继),获取MQ中位于第一地址va p之前的不超过LEVEL个的内存页地址m i,假设levels=3,且MQ中有存储时间在第一地址va p之前的大于或等于3个内存页地址,则获取MQ中位于第一地址va p之前的3个内存页地址,按时间顺序依次为m1、m2、m3。 6. According to the second quantity threshold (LEVEL, understood as several levels of successors), obtain the memory page addresses m i that are not more than LEVEL before the first address va p in the MQ, assuming levels=3, and there is a storage time in the MQ If there are more than or equal to three memory page addresses before the first address va p , the three memory page addresses located before the first address va p in the MQ are acquired, which are m1, m2, and m3 in chronological order.
7、对每个m i进行哈希运算,得到对应的序号r i,从MLCT中分别找到每个m i对应的r i的位置,并根据每个m i与m p在MQ中的位置,找到对应的相关组(相关level),采用MRU的方式将m p(也即第一地址va p)存储在对应的相关组(目标相关组)中。 7. Perform a hash operation on each mi to obtain the corresponding serial number ri, find the position of ri corresponding to each mi from the MLCT , and according to the position of each mi and mp in the MQ, The corresponding correlation group (correlation level) is found, and mp (ie, the first address va p ) is stored in the corresponding correlation group (target correlation group) by means of MRU.
其中,采用MRU的方式在相关组中存储第一地址va page,可以理解为顺次后移的方式,具体实现方式参照前述实施例,这里不再赘述。 Wherein, storing the first address va page in the relevant group in an MRU manner may be understood as a manner of moving backward in sequence, and the specific implementation method refers to the foregoing embodiments, which will not be repeated here.
图6是本申请实施例示出的一个示例性的MLCT,在图6中,ROW(R)所在的列用于存储序号,ASSOC所在的列用于存储每个TAG(T)的序号,ASSOC这列为可选的,TAG所在的列存储每个序号对应的缺页地址,L1所在的列用于存储缺页地址(VA)对应的一级后继的预取地址,L2所在的列用于存储缺页地址对应的二级后继的预取地址(PVA)。FIG. 6 is an exemplary MLCT shown in an embodiment of the present application. In FIG. 6, the column where ROW(R) is located is used to store the serial number, and the column where ASSOC is located is used to store the serial number of each TAG(T). The column is optional, the column where TAG is located stores the page fault address corresponding to each serial number, the column where L1 is located is used to store the prefetch address of the first-level successor corresponding to the page fault address (VA), and the column where L2 is located is used to store The prefetch address (PVA) of the secondary successor corresponding to the page fault address.
通过以上过程,获取本次缺页异常的内存页对应的多个预取地址,并更新多级相关表。由于多级相关表是根据历史访问内存时发生的缺页异常的内存页之间的先后关系逐渐建立起来的,从多级相关表中获取的多个预取地址,很大概率也是历史访问第一地址对应的内存数据之后,需要继续访问的内存数据对应的内存页地址,也即是,本方案读取的多个预取地址对应的数据,很大概率就是处理器接下来要访问的内存数据,也即本方案更加精准地预读内存数据,能够避免造成严重的内存资源浪费,且能够降低再次发生缺页异常的概率,也即提高了预取命中率,有效降低了访存时延。Through the above process, multiple prefetch addresses corresponding to the memory page of the current page fault exception are obtained, and the multi-level correlation table is updated. Since the multi-level correlation table is gradually established according to the sequence relationship between the memory pages with page fault exceptions that occur during historical access to memory, the multiple prefetch addresses obtained from the multi-level correlation table are highly likely to be the first in historical access. After the memory data corresponding to an address, the memory page address corresponding to the memory data that needs to be accessed continuously, that is, the data corresponding to the multiple prefetch addresses read by this solution is very likely to be the memory to be accessed by the processor next. data, that is, this solution pre-reads memory data more accurately, which can avoid serious waste of memory resources, and can reduce the probability of page fault exceptions again, that is, improve the prefetch hit rate and effectively reduce the memory access delay. .
需要说明的是,计算机设备中应用的访存模式有多种,例如顺序访存模式、非顺序访存模式,非顺序访存模式包括跳读(strided)模式和混合(mixed)模式,本方案通过预取算法学习历史访问内存的规律建立MLCT,而非盲目的预取连续的内存页地址对应的数据到内存中,本方案对于顺序访存模式、跳读模式和混合模式均有良好的效果。It should be noted that there are many memory access modes applied in computer equipment, such as sequential memory access mode and non-sequential memory access mode. The non-sequential memory access mode includes strided mode and mixed mode. This solution The MLCT is established by learning the rules of historical memory access through the prefetch algorithm, instead of blindly prefetching the data corresponding to the consecutive memory page addresses into the memory. This scheme has good effects on sequential memory access mode, skip read mode and mixed mode. .
可选地,除以上介绍的通过存储历史内存访问信息(如MLCT)来预测预取信息之外, 在其他一些实施例中,计算机设备基于马尔可夫模型来预测第一信息对应的预取信息。例如,计算机设备根据历史内存访问信息构建马尔可夫模型,历史内存访问信息包括按照时间顺序排列的历史访问的内存页信息(如地址),或者按照时间顺序排列的缺页异常的内存页信息,计算机设备根据马尔可夫模型计算内存页信息的测量概率以及内存页信息之间的转移概率,之后根据测量概率和转移概率计算第一信息转移到其他内存页信息的概率,将计算得到的最大概率对应的内存页信息作为一个预取信息。可选地,在预测得到一个预取信息之后,计算机设备继续将该预取信息作为第一信息,继续通过马尔可夫模型预测下一个概率最大的预取信息,得到第二个预取信息,以此类推,直至得到数量为预取深度的多个预取信息。Optionally, in addition to predicting the prefetch information by storing historical memory access information (such as MLCT) described above, in some other embodiments, the computer device predicts the prefetch information corresponding to the first information based on a Markov model. . For example, a computer device constructs a Markov model based on historical memory access information, which includes historically accessed memory page information (such as addresses) arranged in chronological order, or memory page information of abnormal page faults arranged in chronological order, The computer device calculates the measurement probability of the memory page information and the transition probability between the memory page information according to the Markov model, and then calculates the probability that the first information is transferred to other memory page information according to the measurement probability and the transition probability, and calculates the maximum probability obtained by the calculation. The corresponding memory page information is used as a prefetch information. Optionally, after predicting to obtain a piece of prefetch information, the computer device continues to use the prefetch information as the first information, and continues to predict the next most probable prefetch information by using the Markov model, to obtain the second prefetch information, And so on, until a plurality of prefetch information with the number of the prefetch depth is obtained.
可选地,在另一些实施例中,计算机设备通过深度学习模型预测第一信息对应的预取信息,如通过人工智能(artificialnbsp intelligence,AI)模型预测预取信息。其中,历史内存访问信息包括按照时间顺序排列的历史访问的内存页信息(如地址),深度学习模型根据历史内存访问信息训练得到,例如,计算机设备将历史访问的一个内存页信息作为样本输入,将访问该内存页之后继续访问的数量为预取深度的多个内存页信息作为样本期望输出,得到一个训练样本,通过这种方式得到多个训练样本,每个训练样本包括一个样本输入和一个样本期望输出,计算机设备将训练样本输入初始模型,训练得到深度学习模型。计算机设备在得到本次发生缺页异常的内存页信息,也即得到第一信息之后,将第一信息输入深度学习模型,输出多个预取信息。可选地,计算机设备通过在线获取训练样本,在线训练的方式逐渐训练更新深度学习模型,或者计算机设备获取一定量的训练样本之后,通过离线训练的方式训练得到深度学习模型。Optionally, in other embodiments, the computer device predicts the prefetch information corresponding to the first information by using a deep learning model, such as predicting the prefetch information by using an artificial intelligence (artificial intelligence, AI) model. Among them, the historical memory access information includes historically accessed memory page information (such as addresses) arranged in chronological order, and the deep learning model is trained according to the historical memory access information. Use the information of multiple memory pages with the number of prefetch depths that continue to be accessed after accessing the memory page as the expected output of the sample, and obtain a training sample. In this way, multiple training samples are obtained. Each training sample includes a sample input and a The sample expected output, the computer equipment inputs the training sample into the initial model, and the deep learning model is obtained by training. After obtaining the memory page information of the page fault exception this time, that is, after obtaining the first information, the computer device inputs the first information into the deep learning model, and outputs a plurality of prefetch information. Optionally, the computer device obtains training samples online, and gradually trains and updates the deep learning model by means of online training, or after the computer device obtains a certain amount of training samples, the deep learning model is obtained by training by means of offline training.
步骤203:将该多个预取信息对应的数据读取到内存中相应的内存页上。Step 203: Read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
在本申请实施例中,计算机设备在预测得到多个预取信息(如地址)之后,将该多个预取信息对应的数据读取到内存中相应的内存页上。In this embodiment of the present application, after predicting and obtaining multiple pieces of prefetch information (eg, addresses), the computer device reads data corresponding to the multiple pieces of prefetch information to a corresponding memory page in the memory.
需要说明的是,以预取信息为预取地址为例,预取地址为虚拟地址,该多个预取地址对应的数据可能有部分已经在内存中相应的内存页上,计算机设备根据存储的内存的虚拟地址与物理地址的映射关系,判断该多个预取地址对应的数据是否已在相应的内存页上,将不在内存页上的数据读取到相应内存页上。It should be noted that, taking the prefetch information as the prefetch address as an example, the prefetch address is a virtual address, and some of the data corresponding to the multiple prefetch addresses may already be on the corresponding memory page in the memory. The mapping relationship between the virtual address and the physical address of the memory is used to determine whether the data corresponding to the multiple prefetch addresses are already on the corresponding memory page, and the data not on the memory page is read to the corresponding memory page.
在本申请实施例中,计算机设备根据该多个预取信息,从指定存储空间中读取对应的数据到内存中相应的内存页上。In the embodiment of the present application, the computer device reads the corresponding data from the designated storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
可选地,指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。Optionally, the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
需要说明的是,在计算机设备中设置指定存储空间,用于存储冷页面的数据,也即是存储未在内存的内存页上存储的数据。其中,XL-FLASH设备的读写速度快于磁盘的SWAP分区,且价格比内存条(如DRAM)低,容量大,能够提供比内存多几倍的容量,对于计算机设备来说,可供访问的内存空间包括DRAM和XL-FLASH设备,也即通过增加XL-FLASH设备将可供访问的内存空间增加了几倍,也即是对用户可见的访存空间增加了很多。It should be noted that a designated storage space is set in the computer device for storing the data of the cold page, that is, storing the data not stored in the memory page of the memory. Among them, the read and write speed of XL-FLASH devices is faster than that of SWAP partitions of disks, and the price is lower than that of memory sticks (such as DRAM), and the capacity is large, which can provide several times more capacity than memory. For computer equipment, it can be accessed The memory space includes DRAM and XL-FLASH devices, that is, by adding XL-FLASH devices, the accessible memory space is increased several times, that is, the access memory space visible to the user is increased a lot.
另外,需要说明的是,关于远端存储器,例如远端的一个计算机设备包括的磁盘、XL-FLASH等存储设备,本设备如果要访问远端存储器的存储空间,可以通过网络访问,如通过高速的互联网访问远端存储器。In addition, it should be noted that with regard to the remote storage, for example, a storage device such as a disk and XL-FLASH included in a remote computer device, if the device wants to access the storage space of the remote storage, it can be accessed through the network, such as through high-speed Internet access remote storage.
可选地,指定内存空间包括SWAP分区、XL-FLASH设备和远端存储器中的一个或多个 的存储空间。Optionally, the designated memory space includes the storage space of one or more of the SWAP partition, the XL-FLASH device and the remote storage.
可选地,计算机设备根据第一时间段内内存中的内存页的访问时间和访问数量,确定内存中的冷页面,并将冷页面上的数据从内存移动到指定存储空间中。也即是,除上述通过预取算法从指定存储空间中预取内存数据之外,处理器还能够结合扫描并淘汰内存中冷页面的方法,将内存中冷页面上的数据移动到指定存储空间中,也即淘汰内存中的冷页面。这样,能够将内存腾出更多的空间用于存放热度高的内存数据,提高内存的资源利用率。Optionally, the computer device determines the cold pages in the memory according to the access time and the number of accesses of the memory pages in the memory in the first time period, and moves the data on the cold pages from the memory to the designated storage space. That is, in addition to prefetching memory data from the specified storage space through the prefetch algorithm, the processor can also combine the method of scanning and eliminating cold pages in the memory to move the data on the cold pages in the memory to the specified storage space. , that is, eliminating cold pages in memory. In this way, more memory space can be freed up for storing hot memory data, thereby improving memory resource utilization.
在本申请实施例中,计算机设备获取第一时间段内内存中的内存页的访问时间和访问数量,根据该段时间内内存中的内存页的访问时间和访问数量,确定内存中的冷页面。In the embodiment of the present application, the computer device obtains the access time and the access quantity of the memory pages in the memory in the first time period, and determines the cold page in the memory according to the access time and the access quantity of the memory pages in the memory during the period of time .
示例性地,内存中每个内存页的访问数量对应权重w1,该段时间内内存中每个内存页的各个访问时间距离当前时间的时长的平均值为第一时长,第一时长对应权重w2,处理器计算内存中每个内存页的访问数量与权重w1的乘积加上第一时长与权重w2的乘积,得到相应内存页对应的访存统计值,处理器将内存中对应的访存统计值小于统计阈值的内存页确定为冷页面,或者处理器将内存中各个内存页对应的访问统计值从小到大排序,将排序靠后的指定比例的访问统计值对应的内存页确定为冷页面。Exemplarily, the number of accesses of each memory page in the memory corresponds to the weight w1, and the average of the durations between the respective access times of each memory page in the memory and the current time during this period is the first duration, and the first duration corresponds to the weight w2. , the processor calculates the product of the number of accesses of each memory page in the memory and the weight w1 plus the product of the first duration and the weight w2 to obtain the memory access statistics value corresponding to the corresponding memory page, and the processor calculates the corresponding memory access statistics in the memory A memory page whose value is less than the statistical threshold is determined as a cold page, or the processor sorts the access statistics corresponding to each memory page in the memory from small to large, and determines the memory page corresponding to the specified proportion of access statistics at the lower end of the sorting as a cold page .
可选地,计算机设备周期性地扫描和淘汰冷页面,第一时间段为本次扫描之前的一段时间,第一时间段的时长可以大于、等于或小于扫描周期。Optionally, the computer device periodically scans and eliminates cold pages, the first period of time is a period of time before the current scan, and the duration of the first period of time may be greater than, equal to or less than the scan period.
需要说明的是,扫描确定冷页面的策略可以有多种,每种策略以将访问数量越少,且访问时间越早的内存页确定为冷页面为目的,上述介绍的策略仅为一种示例。It should be noted that there are many strategies for scanning to determine cold pages. Each strategy aims to determine the memory pages with fewer accesses and earlier access times as cold pages. The strategy described above is only an example. .
可选地,计算机设备淘汰冷页面时,将内存中冷页面上的数据压缩后存储在指定存储空间中,预读内存数据时,从指定存储空间中将预取的内存数据解压之后读取到内存中。这样,通过数据压缩,节省指定存储空间的数据存储量,可以将更多的冷页面从内存中淘汰到指定存储空间中,这样,内存中能够存放更多的热度较高的内存数据,进一步提高内存的资源利用率。Optionally, when the computer device eliminates cold pages, it compresses the data on the cold pages in the memory and stores it in the specified storage space. When pre-reading the memory data, it decompresses the prefetched memory data from the specified storage space and reads the in memory. In this way, through data compression, the amount of data storage in the specified storage space can be saved, and more cold pages can be eliminated from the memory to the specified storage space. In this way, more hot memory data can be stored in the memory, further improving the Resource utilization of memory.
参见图7,计算机设备结合预取算法以及内存页面扫描,来预取内存数据以及淘汰内存数据,其中,计算机设备通过页面扫描模块扫描内存中的冷页面,并将冷页面的数据压缩后存储到指定存储空间中,计算机设备通过预取算法从指定存储空间中预取内存数据,其中通过内核压缩模块从指定存储空间中解压相应数据后读取到内存中(如DRAM),相当于是读取热页面数据。Referring to FIG. 7, the computer device combines the prefetch algorithm and the memory page scan to prefetch the memory data and eliminate the memory data, wherein the computer device scans the cold pages in the memory through the page scan module, and compresses the data of the cold pages and stores them in the memory. In the designated storage space, the computer equipment prefetches the memory data from the designated storage space through the prefetching algorithm, in which the corresponding data is decompressed from the designated storage space through the kernel compression module and then read into the memory (such as DRAM), which is equivalent to reading heat. page data.
可选地,计算机设备还能够接收预取算法性能查询指令,并显示预取算法性能信息,预取算法性能信息包括预取准确率和预取覆盖率。其中,预取准确率由预取总数量和预取命中数量确定,预取覆盖率由预取总数量和访问总数量确定,预取总数量是指第二时间段内获取的所有预取信息的总数量,预取命中数量是指第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,访问总数量是指第二时间段内被访问的所有内存页的总数量。Optionally, the computer device can also receive a prefetch algorithm performance query instruction, and display prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate. Among them, the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits, the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses, and the total number of prefetches refers to all the prefetch information obtained in the second time period. The total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period, and the total number of accesses refers to all the memory accessed in the second time period. The total number of pages.
可选地,第二时间段是指计算机设备从运行预取算法开始至接收到预取算法性能查询指令的一段时间,或者,第二时间段为接收到预取算法性能信息查询的时刻之前的指定时长的一段时间。Optionally, the second time period refers to a period of time from when the computer device runs the prefetch algorithm to when it receives the prefetch algorithm performance query instruction, or the second time period is before the moment when the prefetch algorithm performance information query is received. A period of time of the specified duration.
需要说明的是,预取准确率在一定程度上能够表征预取算法的准确度,预取覆盖率在一定程度上能够表征预取算法对于本设备运行的应用的有效程度。It should be noted that the prefetch accuracy rate can represent the accuracy of the prefetch algorithm to a certain extent, and the prefetch coverage rate can represent the effectiveness of the prefetch algorithm for applications running on the device to a certain extent.
示例性地,用户通过在计算机设备中输入/sys/kernel/mm/smap_prefetch/prefetch_stats或 /sys/kernel/mm/smap_prefetch_module/module_stats这样的命令行,获取预取算法性能信息,包括预取准确率、预取覆盖率、预取总数量、预取命中数量等。如果预取准确率较低,用户可以通过在计算机设备中输入命令行,调整预取参数,例如增大LEVEL、增大ASSOC或增大SUCC等,计算机设备根据调整后的预取参数更新历史内存访问信息(如MLCT),以在历史内存访问信息中记录更多的历史访问的内存页信息的关联关系。Exemplarily, the user obtains the performance information of the prefetch algorithm, including the prefetch accuracy, Prefetch coverage, total number of prefetches, number of prefetch hits, etc. If the prefetching accuracy rate is low, the user can adjust the prefetching parameters by entering a command line in the computer device, such as increasing LEVEL, increasing ASSOC or increasing SUCC, etc. The computer device updates the historical memory according to the adjusted prefetching parameters Access information (such as MLCT) to record the association relationship of more historically accessed memory page information in the historical memory access information.
也即是,计算机设备在显示预取算法性能信息之后,接收预取参数调整指令,预取参数调整指令由关于预取算法性能信息的用户反馈确定,计算机设备根据预取参数调整指令,更新历史内存访问信息。That is, after displaying the prefetch algorithm performance information, the computer device receives the prefetch parameter adjustment instruction, the prefetch parameter adjustment instruction is determined by user feedback on the prefetch algorithm performance information, the computer device adjusts the instruction according to the prefetch parameter, and updates the history. Memory access information.
在本申请实施例中,用户可以通过计算机设备查询预取算法性能信息,计算机设备在接收到预取算法性能查询指令之后显示预取算法性能信息,例如显示预取准确率和预取覆盖率,可选地,还可以显示预取总数量、预取命中数量等,用户可以选择根据预取准确率和预取覆盖率,通过计算机设备调整预取参数。以历史内存访问信息为MLCT为例,通常情况下,用户调整预取参数后对应的多级相关表越大,多级相关表能够记录的历史访问的内存页信息的关联关系也就越多,在一定程度上预取算法的性能也就越好。In this embodiment of the present application, a user can query prefetch algorithm performance information through a computer device, and the computer device displays the prefetch algorithm performance information after receiving the prefetch algorithm performance query instruction, such as the prefetch accuracy rate and the prefetch coverage rate, Optionally, the total number of prefetches, the number of prefetch hits, etc. can also be displayed, and the user can choose to adjust the prefetch parameters through the computer device according to the prefetch accuracy rate and the prefetch coverage rate. Taking the historical memory access information as MLCT as an example, under normal circumstances, the larger the corresponding multi-level correlation table after the user adjusts the prefetch parameters, the more the correlation relationship of the historically accessed memory page information that the multi-level correlation table can record. To a certain extent, the performance of the prefetching algorithm is better.
接下来以计算机设备中的软硬件模块对本申请实施例提供的内存缺页异常的处理方法进行示例性地说明。Next, the method for processing the memory page fault exception provided by the embodiment of the present application is exemplarily described by using the software and hardware modules in the computer device.
参见图8,计算机设备包括处理器(CPU)、内存以及指定存储空间(以XL-FLASH为例),将本方法理解为通过SMAP抽象三层模型实现,SMAP包括感知层、决策层和物理层,SMAP可以理解包括为本申请实施例提供的所有方法相应的功能。其中,计算机设备通过处理器和统计内存(主存)中的冷热页面,例如通过应用(application,APP)、操作系统(operaing system,OS)或虚拟机(如Hyper-v)统计内存冷热页面,也即通过软件层面的感知层内存冷热。计算机设备通过处理器运行预取算法和内存淘汰算法等,来预取或者淘汰内存页,也即通过软件以及硬件层面的决策层来预取或者淘汰内存页。计算机设备通过内存硬件模块执行介质的压缩与解压等,也即通过物理层的介质压缩提高存取速率以及节省存储空间。Referring to Figure 8, the computer equipment includes a processor (CPU), a memory and a designated storage space (taking XL-FLASH as an example), and this method is understood to be realized through an abstract three-layer model of SMAP, which includes a perception layer, a decision layer and a physical layer. , SMAP can be understood to include functions corresponding to all the methods provided in the embodiments of the present application. Among them, the computer device counts the hot and cold pages in the memory (main memory) through the processor and, for example, through the application (application, APP), the operating system (operaing system, OS) or the virtual machine (such as Hyper-v) statistics of memory cold and hot pages Pages, that is, memory hot and cold through the perception layer at the software level. A computer device prefetches or eliminates memory pages by running a prefetching algorithm and a memory elimination algorithm, etc. on the processor, that is, prefetching or eliminating memory pages through a decision layer at the software and hardware levels. The computer device performs media compression and decompression through the memory hardware module, that is, the media compression at the physical layer improves the access rate and saves storage space.
参见图9,以用户层面以及计算机设备中操作系统的内核层面为例,对本申请实施例提供的内存缺页异常的处理方法作示例性说明。在图9中,用户通过命令行等形式配置预取算法以及其他相关的算法(如扫描冷页面的内存淘汰算法),在操作系统的内核空间中,运行算法以实现内存页的数据预取,以及内存中冷页面的淘汰。Referring to FIG. 9 , taking the user plane and the kernel plane of the operating system in the computer device as examples, the processing method for the memory page fault exception provided by the embodiment of the present application is exemplarily described. In Figure 9, the user configures the prefetch algorithm and other related algorithms (such as the memory elimination algorithm for scanning cold pages) through the command line and other forms. In the kernel space of the operating system, the algorithm is run to realize the data prefetch of the memory page. And the elimination of cold pages in memory.
综上所述,在本申请实施例中,由于历史内存访问信息能够表征历史访问内存的规律,因此,根据历史内存访问信息来预测预取信息,从而将预取信息对应的数据读取到内存中,并非盲目的预取连续的多个内存页地址的数据到内存中,也即本方案预取命中率更高,能够有效减少后续缺页异常的次数,有效降低访存时延,且本方案预取的数据更加有效,对内存资源的损耗较低,内存资源不会很紧张。To sum up, in the embodiment of the present application, since the historical memory access information can represent the law of historical memory access, the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory It is not blindly prefetching the data of multiple consecutive memory page addresses into the memory, that is, the prefetching hit rate of this scheme is higher, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce the memory access delay, and this The data prefetched by the scheme is more effective, the consumption of memory resources is lower, and the memory resources are not very tight.
图10是本申请实施例提供的一种内存缺页异常的处理装置1000的结构示意图,该内存缺页异常的处理装置1000可以由软件、硬件或者两者的结合实现成为计算机设备的部分或者全部,该计算机设备可以为图1所示的计算机设备。参见图10,该装置1000包括:第一确定模块1001、预测模块1002和读取模块1003。FIG. 10 is a schematic structural diagram of an apparatus 1000 for processing a memory page fault exception provided by an embodiment of the present application. The apparatus 1000 for processing a memory page fault exception may be implemented as part or all of a computer device by software, hardware, or a combination of the two. , the computer device may be the computer device shown in FIG. 1 . Referring to FIG. 10 , the apparatus 1000 includes: a first determination module 1001 , a prediction module 1002 and a reading module 1003 .
第一确定模块1001,用于确定目标内存页的信息,得到第一信息,目标内存页为本次发 生缺页异常的内存页;具体实现方式参照前述图2实施例中步骤201的详细介绍,这里不再赘述。The first determination module 1001 is used to determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time; for the specific implementation method, refer to the detailed introduction of step 201 in the foregoing embodiment of FIG. 2 , I won't go into details here.
预测模块1002,用于根据历史内存访问信息,预测与第一信息对应的多个预取信息,历史内存访问信息用于表征历史访问内存的规律;具体实现方式参照前述图2实施例中步骤202的详细介绍,这里不再赘述。The prediction module 1002 is used to predict a plurality of prefetch information corresponding to the first information according to the historical memory access information, and the historical memory access information is used to represent the law of historical memory access; for the specific implementation method, refer to step 202 in the aforementioned embodiment of FIG. 2 The detailed introduction will not be repeated here.
读取模块1003,用于将该多个预取信息对应的数据读取到内存中相应的内存页上。具体实现方式参照前述图2实施例中步骤203的详细介绍,这里不再赘述。The reading module 1003 is configured to read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory. For a specific implementation manner, refer to the detailed introduction of step 203 in the foregoing embodiment of FIG. 2 , which will not be repeated here.
可选地,历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的;Optionally, the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access;
预测模块1002包括: Prediction module 1002 includes:
获取单元,用于根据历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与第一信息对应的多个预取信息;an obtaining unit, configured to obtain a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page in which the page fault exception occurs in the historical memory access information and the prefetch information;
可选地,历史内存访问信息包括序号、缺页信息与预取信息之间的对应关系,缺页信息是指发生缺页异常的内存页的信息,序号是通过对缺页信息进行哈希运算得到的;Optionally, the historical memory access information includes the sequence number, the correspondence between page fault information and prefetch information, the page fault information refers to the information of the memory page where the page fault exception occurs, and the serial number is obtained by performing a hash operation on the page fault information. owned;
获取单元包括:The acquisition unit includes:
哈希子单元,用于对第一信息进行哈希运算,得到第一序号;a hash subunit, configured to perform a hash operation on the first information to obtain the first serial number;
查找子单元,用于根据第一序号和第一信息,从历史内存访问信息中查找对应的多个预取信息。The search subunit is configured to search for a plurality of corresponding pieces of prefetch information from the historical memory access information according to the first sequence number and the first information.
可选地,查找子单元具体用于:Optionally, lookup subunits are specifically used to:
从历史内存访问信息中查找第一序号和第一信息所在的记录;Find the first serial number and the record where the first information is located from the historical memory access information;
如果从历史内存访问信息中查找到第一序号和第一信息所在的记录,则从第一序号和第一信息所在的记录中查找对应的多个预取信息。If the first sequence number and the record where the first information is located are found from the historical memory access information, the corresponding pieces of prefetch information are searched from the record where the first sequence number and the first information are located.
可选地,查找子单元具体用于:Optionally, lookup subunits are specifically used to:
按照预取深度,从第一序号和第一信息所在的记录中查找对应的多个预取信息。According to the prefetch depth, the corresponding pieces of prefetch information are searched from the first sequence number and the record where the first information is located.
可选地,该装置还包括:Optionally, the device also includes:
第一更新模块,用于如果未获取到与第一信息对应的多个预取信息,则根据第一序号和第一信息,更新历史内存访问信息,第一序号是对第一信息进行哈希运算得到的。The first update module is used to update the historical memory access information according to the first sequence number and the first information if multiple prefetch information corresponding to the first information is not obtained, and the first sequence number is to hash the first information obtained by operation.
可选地,第一更新模块包括:Optionally, the first update module includes:
第一更新单元,用于在历史内存访问信息未存储第一序号和第一信息的情况下,在历史内存访问信息中创建第一序号和第一信息所在的记录,以更新历史内存访问信息;The first update unit is used to create a record where the first serial number and the first information are located in the historical memory access information in the case that the historical memory access information does not store the first serial number and the first information, to update the historical memory access information;
第二更新单元,用于在历史内存访问信息存储有第一序号,但未存储第一信息的情况下,在第一序号的记录中存储第一信息,以更新历史内存访问信息。The second updating unit is configured to store the first information in the record of the first serial number to update the historical memory access information when the first serial number is stored in the historical memory access information but the first information is not stored.
可选地,第二更新单元包括:Optionally, the second update unit includes:
第一存储子单元,用于如果第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则在第一序号的记录中存储第一信息;The first storage subunit is used to store the first information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number does not reach the first quantity threshold;
第二存储子单元,用于如果第一序号的记录中存储的缺页信息的数量达到第一数量阈值,则删除第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在第一序号的记录中存储第一信息。The second storage subunit is used to delete the page fault information with the earliest storage time and the corresponding prefetch information in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold, The first information is stored in the record of the first serial number.
可选地,该装置还包括:Optionally, the device also includes:
第二更新模块,用于根据缺页队列,更新历史内存访问信息,缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息。The second update module is used to update historical memory access information according to the page fault queue, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
可选地,第二更新模块包括:Optionally, the second update module includes:
第一存储单元,用于将第一信息存储在缺页队列中;a first storage unit for storing the first information in the page fault queue;
获取单元,用于获取缺页队列中位于第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息;an acquisition unit, configured to acquire the memory page information that is located before the first information and whose quantity does not exceed the second quantity threshold in the page fault queue, and obtains one or more second information;
第二存储单元,用于将第一信息作为该一个或多个第二信息中每个第二信息对应的预取信息,存储至历史内存访问信息中。The second storage unit is configured to store the first information as prefetch information corresponding to each of the one or more second information in the historical memory access information.
可选地,第二存储单元包括:Optionally, the second storage unit includes:
第三存储子单元,用于根据第一信息与该一个或多个第二信息中每个第二信息在缺页队列中的位置关系,在历史内存访问信息中存储第一信息与每个第二信息的关联关系。The third storage subunit is configured to store the first information and each second information in the historical memory access information according to the positional relationship between the first information and each second information in the one or more second information in the page fault queue The relationship between the two information.
可选地,该一个或多个第二信息中的每个第二信息对应有一个或多个相关组,该一个或多个相关组的数量为第二数量阈值,每个相关组对应有一个或多个信息位置,每个相关组对应一个相关级别,每个相关组用于存储预取信息;Optionally, each of the one or more second information corresponds to one or more related groups, the number of the one or more related groups is the second quantity threshold, and each related group corresponds to one or multiple information locations, each related group corresponds to a related level, and each related group is used to store prefetch information;
第三存储子单元具体用于:The third storage subunit is specifically used for:
从该一个或多个第二信息中选择一个第二信息,对于选择出的第二信息执行如下操作,直至对该一个或多个第二信息中的每个第二信息均执行如下操作为止:Select one second information from the one or more second information, and perform the following operations on the selected second information until the following operations are performed on each of the one or more second information:
根据第一信息与选择出的第二信息在缺页队列中的位置,确定第一信息与选择出的第二信息的相关级别,得到参考级别;According to the positions of the first information and the selected second information in the page fault queue, determine the correlation level of the first information and the selected second information, and obtain the reference level;
将第一信息存储在目标相关组的第一个信息位置上,目标相关组为选择出的第二信息对应的相关级别为参考级别的相关组。The first information is stored in the first information position of the target related group, and the target related group is a related group whose correlation level corresponding to the selected second information is a reference level.
可选地,该一个或多个信息位置的数量为第三数量阈值,该一个或多个相关组按照相关级别的顺序依次排列;Optionally, the number of the one or more information locations is a third number threshold, and the one or more related groups are arranged in order of related levels;
第三存储子单元具体用于:The third storage subunit is specifically used for:
如果第一个信息位置上存储有内存页信息,且目标相关组存储的内存页信息的数量未达到第三数量阈值,则将目标相关组中存储的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If memory page information is stored in the first information location, and the number of memory page information stored in the target related group does not reach the third quantity threshold, move each memory page information stored in the target related group by one information location. After that, store the first information in the first information position;
如果目标相关组存储的内存页信息的数量达到第三数量阈值,且目标相关组为选择出的第二信息对应的最后一个相关组,则将目标相关组中的最后一个内存页信息删除,将其余内存页信息后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, and the target related group is the last related group corresponding to the selected second information, the last memory page information in the target related group is deleted, and the After the remaining memory page information is moved back by one information position, the first information is stored in the first information position;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中存在空闲的信息位置,则将目标相关组以及位于目标相关组之后的相关组中首个空闲的信息位置之前的每个内存页信息均后移一个信息位置后,将第一信息存储在第一个信息位置上;If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is an idle information position in the subsequent related groups, the target related group and each memory page information before the first free information position in the related group after the target related group are moved back by one information position, and the first Information is stored in the first information location;
如果目标相关组存储的内存页信息的数量达到第三数量阈值、目标相关组不是选择出的第二信息对应的最后一个相关组,且选择出的第二信息对应的相关组中位于目标相关组之后的相关组中不存在空闲的信息位置,则将选择出的第二信息对应的最后一个相关组中的最后一个内存页信息删除,将目标相关组以及位于目标相关组之后的相关组中的其余内存页信息 均后移一个信息位置后,将第一信息存储在第一个信息位置上。If the number of memory page information stored in the target related group reaches the third number threshold, the target related group is not the last related group corresponding to the selected second information, and the related group corresponding to the selected second information is located in the target related group If there is no free information location in the subsequent related groups, the last memory page information in the last related group corresponding to the selected second information is deleted, and the target related group and the related group located after the target related group are deleted. After the rest of the memory page information is moved back by one information position, the first information is stored in the first information position.
可选地,读取模块1003包括:Optionally, the reading module 1003 includes:
读取单元,用于根据该多个预取信息,从指定存储空间中读取对应的数据到内存中相应的内存页上。The reading unit is configured to read the corresponding data from the specified storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
可选地,该指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。Optionally, the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the storage space of the remote storage.
可选地,参见图11,该装置1000还包括:Optionally, referring to FIG. 11 , the apparatus 1000 further includes:
第二确定模块1004,用于根据第一时间段内内存中的内存页的访问时间和访问数量,确定内存中的冷页面;具体实现方式参照前述图2实施例中步骤203的详细介绍,这里不再赘述。The second determination module 1004 is configured to determine the cold page in the memory according to the access time and the number of accesses of the memory pages in the memory in the first time period; for the specific implementation method, refer to the detailed introduction of step 203 in the foregoing embodiment of FIG. 2 , here No longer.
移动模块1005,用于将冷页面上的数据从内存移动到指定存储空间中。The moving module 1005 is configured to move the data on the cold page from the memory to the designated storage space.
可选地,参见图12,该装置1000还包括:Optionally, referring to FIG. 12 , the apparatus 1000 further includes:
第一接收模块1006,用于接收预取算法性能查询指令;a first receiving module 1006, configured to receive a prefetch algorithm performance query instruction;
显示模块1007,用于显示预取算法性能信息,预取算法性能信息包括预取准确率和预取覆盖率;A display module 1007, configured to display prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate;
其中,预取准确率由预取总数量和预取命中数量确定,预取覆盖率由预取总数量和访问总数量确定,预取总数量是指第二时间段内获取的所有预取信息的总数量,预取命中数量是指第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,访问总数量是指第二时间段内被访问的所有内存页的总数量。Among them, the prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits, the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses, and the total number of prefetches refers to all the prefetch information obtained in the second time period. The total number of prefetch hits refers to the total number of memory pages accessed in the memory pages corresponding to all prefetch information obtained in the second time period, and the total number of accesses refers to all the memory accessed in the second time period. The total number of pages.
可选地,参见图13,该装置1000还包括:Optionally, referring to FIG. 13 , the apparatus 1000 further includes:
第二接收模块1008,用于接收预取参数调整指令,预取参数调整指令由关于预取算法性能信息的用户反馈确定;The second receiving module 1008 is configured to receive a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the performance information of the prefetch algorithm;
第三更新模块1009,用于根据预取参数调整指令,更新历史内存访问信息。The third update module 1009 is configured to adjust the instruction according to the prefetch parameter and update the historical memory access information.
在本申请实施例中,由于历史内存访问信息能够表征历史访问内存的规律,因此,根据历史内存访问信息来预测预取信息,从而将预取信息对应的数据读取到内存中,并非盲目的预取连续的多个内存页地址的数据到内存中,也即本方案预取命中率更高,能够有效减少后续缺页异常的次数,有效降低访存时延,且本方案预取的数据更加有效,对内存资源的损耗较低,内存资源不会很紧张。In the embodiment of the present application, since the historical memory access information can represent the law of historical memory access, the prefetch information is predicted according to the historical memory access information, so that the data corresponding to the prefetch information is read into the memory, which is not blind. Prefetching data from multiple consecutive memory page addresses into memory means that this solution has a higher prefetching hit rate, which can effectively reduce the number of subsequent page fault exceptions, effectively reduce memory access latency, and this solution prefetches data. It is more efficient, the consumption of memory resources is lower, and memory resources are not very tight.
需要说明的是:上述实施例提供的内存缺页异常的处理装置在内存缺页异常的处理时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的内存缺页异常的处理装置与内存缺页异常的处理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that: when the device for processing a memory page fault exception provided by the above-mentioned embodiment, when processing the memory page fault abnormality, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions may be allocated as required. It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the apparatus for processing a memory page fault exception provided by the above embodiment and the embodiment of the processing method for a memory page fault exception belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意结合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络或其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算 机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如:同轴电缆、光纤、数据用户线(digital subscriber line,DSL))或无线(例如:红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质,或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如:软盘、硬盘、磁带)、光介质(例如:数字通用光盘(digital versatile disc,DVD))或半导体介质(例如:固态硬盘(solid state disk,SSD))等。值得注意的是,本申请实施例提到的计算机可读存储介质可以为非易失性存储介质,换句话说,可以是非瞬时性存储介质。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general purpose computer, special purpose computer, computer network or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server, a data center, etc. that includes one or more available media integrated. The available media may be magnetic media (eg: floppy disk, hard disk, magnetic tape), optical media (eg: digital versatile disc (DVD)) or semiconductor media (eg: solid state disk (SSD)) Wait. It should be noted that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, may be a non-transitory storage medium.
应当理解的是,本文提及的“至少一个”是指一个或多个,“多个”是指两个或两个以上。在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。It should be understood that references herein to "at least one" refers to one or more, and "plurality" refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, "/" means or means, for example, A/B can mean A or B; "and/or" in this document is only an association that describes an associated object Relation, it means that there can be three kinds of relations, for example, A and/or B can mean that A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with basically the same function and effect. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like are not necessarily different.
以上所述为本申请提供的实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above-mentioned examples provided for this application are not intended to limit this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application. Inside.

Claims (32)

  1. 一种内存缺页异常的处理方法,其特征在于,所述方法包括:A method for processing a memory page fault exception, characterized in that the method comprises:
    确定目标内存页的信息,得到第一信息,所述目标内存页为本次发生缺页异常的内存页;Determine the information of the target memory page, and obtain the first information, and the target memory page is the memory page where the page fault exception occurs this time;
    根据历史内存访问信息,预测与所述第一信息对应的多个预取信息,所述历史内存访问信息用于表征历史访问内存的规律;predicting a plurality of prefetch information corresponding to the first information according to the historical memory access information, where the historical memory access information is used to represent the law of historical memory access;
    将所述多个预取信息对应的数据读取到所述内存中相应的内存页上。The data corresponding to the plurality of prefetch information is read into the corresponding memory page in the memory.
  2. 如权利要求1所述的方法,其特征在于,所述历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的。The method according to claim 1, wherein the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access.
  3. 如权利要求1或2所述的方法,其特征在于,所述根据历史内存访问信息,预测与所述第一信息对应的多个预取信息,包括:The method according to claim 1 or 2, wherein the predicting a plurality of prefetch information corresponding to the first information according to historical memory access information comprises:
    根据所述历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与所述第一信息对应的多个预取信息。A plurality of prefetch information corresponding to the first information is acquired according to the association relationship between the information of the memory page where the page fault exception occurs in the historical memory access information and the prefetch information.
  4. 如权利要求3所述的方法,其特征在于,所述历史内存访问信息包括序号、缺页信息与预取信息之间的对应关系,所述缺页信息是指发生缺页异常的内存页的信息,所述序号是通过对所述缺页信息进行哈希运算得到的。The method according to claim 3, wherein the historical memory access information includes a sequence number, a corresponding relationship between page fault information and prefetch information, and the page fault information refers to the memory page in which the page fault exception occurs. information, and the serial number is obtained by performing a hash operation on the page fault information.
  5. 如权利要求4所述的方法,其特征在于,所述方法还包括:The method of claim 4, wherein the method further comprises:
    如果未获取到与所述第一信息对应的多个预取信息,则根据第一序号和所述第一信息,更新所述历史内存访问信息,所述第一序号是对所述第一信息进行哈希运算得到的。If multiple pieces of prefetch information corresponding to the first information are not obtained, the historical memory access information is updated according to a first sequence number and the first information, where the first sequence number is a reference to the first information obtained by hashing.
  6. 如权利要求5所述的方法,其特征在于,所述根据第一序号和所述第一信息更新所述历史内存访问信息,包括:The method according to claim 5, wherein the updating the historical memory access information according to the first sequence number and the first information comprises:
    在所述历史内存访问信息未存储所述第一序号和所述第一信息的情况下,在所述历史内存访问信息中创建所述第一序号和所述第一信息所在的记录,以更新所述历史内存访问信息;In the case where the historical memory access information does not store the first serial number and the first information, a record containing the first serial number and the first information is created in the historical memory access information to update the historical memory access information;
    在所述历史内存访问信息存储有所述第一序号,但未存储所述第一信息的情况下,在所述第一序号的记录中存储所述第一信息,以更新所述历史内存访问信息。In the case where the first serial number is stored in the historical memory access information, but the first information is not stored, the first information is stored in the record of the first serial number to update the historical memory access information.
  7. 如权利要求6所述的方法,其特征在于,所述在所述第一序号的记录中存储所述第一信息,包括:The method of claim 6, wherein the storing the first information in the record of the first serial number comprises:
    如果所述第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则在所述第一序号的记录中存储所述第一信息;If the quantity of page fault information stored in the record of the first serial number does not reach the first quantity threshold, storing the first information in the record of the first serial number;
    如果所述第一序号的记录中存储的缺页信息的数量达到所述第一数量阈值,则删除所述第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在所述第一序号的记录中存储所述第一信息。If the number of page fault information stored in the record of the first serial number reaches the first quantity threshold, delete the page fault information with the earliest storage time and the corresponding prefetch information in the record of the first serial number, and then delete the page fault information and the corresponding prefetch information in the record of the first serial number. The first information is stored in the record of the first serial number.
  8. 如权利要求1-7任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-7, wherein the method further comprises:
    根据缺页队列,更新所述历史内存访问信息,所述缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息。According to the page fault queue, the historical memory access information is updated, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
  9. 如权利要求8所述的方法,其特征在于,所述根据缺页队列,更新所述历史内存访问信息,包括:The method of claim 8, wherein the updating the historical memory access information according to the page fault queue comprises:
    将所述第一信息存储在所述缺页队列中;storing the first information in the page fault queue;
    获取所述缺页队列中位于所述第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息;Acquiring memory page information in the page fault queue that is located before the first information and whose quantity does not exceed a second quantity threshold, and obtains one or more second information;
    将所述第一信息作为所述一个或多个第二信息中每个第二信息对应的预取信息,存储至所述历史内存访问信息中。The first information is stored in the historical memory access information as prefetch information corresponding to each of the one or more second information.
  10. 如权利要求9所述的方法,其特征在于,所述将所述第一信息作为所述一个或多个第二信息中每个第二信息对应的预取信息,存储至所述历史内存访问信息中,包括:The method of claim 9, wherein the first information is stored in the historical memory access as prefetch information corresponding to each second information in the one or more second information information, including:
    根据所述第一信息与所述一个或多个第二信息中每个第二信息在所述缺页队列中的位置关系,在所述历史内存访问信息中存储所述第一信息与每个第二信息的关联关系。According to the positional relationship between the first information and each of the one or more second information in the page fault queue, storing the first information and each second information in the historical memory access information The relationship of the second information.
  11. 如权利要求1-10任一所述的方法,其特征在于,所述将所述多个预取信息对应的数据读取到所述内存中相应的内存页上,包括:The method according to any one of claims 1-10, wherein the reading data corresponding to the plurality of prefetch information to a corresponding memory page in the memory comprises:
    根据所述多个预取信息,从指定存储空间中读取对应的数据到所述内存中相应的内存页上。According to the plurality of prefetch information, the corresponding data is read from the specified storage space to the corresponding memory page in the memory.
  12. 如权利要求11所述的方法,其特征在于,所述指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。The method according to claim 11, wherein the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the remote storage of storage space.
  13. 如权利要求11或12所述的方法,其特征在于,所述方法还包括:The method of claim 11 or 12, wherein the method further comprises:
    根据第一时间段内所述内存中的内存页的访问时间和访问数量,确定所述内存中的冷页面;Determine the cold page in the memory according to the access time and the access quantity of the memory page in the memory in the first time period;
    将所述冷页面上的数据从所述内存移动到所述指定存储空间中。moving data on the cold pages from the memory to the designated storage space.
  14. 如权利要求1-13任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-13, wherein the method further comprises:
    接收预取算法性能查询指令;Receive a prefetch algorithm performance query instruction;
    显示预取算法性能信息,所述预取算法性能信息包括预取准确率和预取覆盖率;Displaying prefetch algorithm performance information, where the prefetch algorithm performance information includes prefetch accuracy and prefetch coverage;
    其中,所述预取准确率由预取总数量和预取命中数量确定,所述预取覆盖率由预取总数量和访问总数量确定,所述预取总数量是指第二时间段内获取的所有预取信息的总数量,所述预取命中数量是指所述第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,所述访问总数量是指所述第二时间段内被访问的所有内存页的总数量。The prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits, the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses, and the total number of prefetches refers to the second time period. The total number of acquired prefetch information, the number of prefetch hits refers to the total number of accessed memory pages in the memory pages corresponding to all prefetch information acquired within the second time period, and the total number of accesses Refers to the total number of all memory pages accessed within the second time period.
  15. 如权利要求14所述的方法,其特征在于,所述显示预取算法性能信息之后,还包括:The method according to claim 14, wherein after the displaying the performance information of the prefetching algorithm, the method further comprises:
    接收预取参数调整指令,所述预取参数调整指令由关于所述预取算法性能信息的用户反馈确定;receiving a prefetch parameter adjustment instruction, the prefetch parameter adjustment instruction being determined by user feedback about the performance information of the prefetch algorithm;
    根据所述预取参数调整指令,更新所述历史内存访问信息。The historical memory access information is updated according to the prefetch parameter adjustment instruction.
  16. 一种内存缺页异常的处理装置,其特征在于,所述装置包括:A device for processing a memory page fault exception, characterized in that the device comprises:
    第一确定模块,用于确定目标内存页的信息,得到第一信息,所述目标内存页为本次发生缺页异常的内存页;a first determining module, configured to determine the information of the target memory page, and obtain the first information, where the target memory page is the memory page where the page fault exception occurs this time;
    预测模块,用于根据历史内存访问信息,预测与所述第一信息对应的多个预取信息,所述历史内存访问信息用于表征历史访问内存的规律;a prediction module, configured to predict a plurality of prefetch information corresponding to the first information according to historical memory access information, where the historical memory access information is used to characterize the law of historical memory access;
    读取模块,用于将所述多个预取信息对应的数据读取到所述内存中相应的内存页上。The reading module is configured to read the data corresponding to the plurality of prefetch information to the corresponding memory page in the memory.
  17. 如权利要求16所述的装置,其特征在于,所述历史内存访问信息是根据历史访问内存时发生缺页异常的内存页之间的先后关系确定的。The apparatus of claim 16, wherein the historical memory access information is determined according to the sequence relationship between memory pages in which a page fault exception occurs during historical memory access.
  18. 如权利要求16或17所述的装置,其特征在于,所述预测模块包括:The apparatus of claim 16 or 17, wherein the prediction module comprises:
    获取单元,用于根据所述历史内存访问信息中发生缺页异常的内存页的信息与预取信息之间的关联关系,获取与所述第一信息对应的多个预取信息。An obtaining unit, configured to obtain a plurality of prefetch information corresponding to the first information according to the association relationship between the information of the memory page where the page fault exception occurs in the historical memory access information and the prefetch information.
  19. 如权利要求18所述的装置,其特征在于,所述历史内存访问信息包括序号、缺页信息与预取信息之间的对应关系,所述缺页信息是指发生缺页异常的内存页的信息,所述序号是通过对所述缺页信息进行哈希运算得到的。The apparatus according to claim 18, wherein the historical memory access information includes a sequence number, a correspondence between page fault information and prefetch information, and the page fault information refers to the memory page in which the page fault exception occurs. information, and the serial number is obtained by performing a hash operation on the page fault information.
  20. 如权利要求19所述的装置,其特征在于,所述装置还包括:The apparatus of claim 19, wherein the apparatus further comprises:
    第一更新模块,用于如果未获取到与所述第一信息对应的多个预取信息,则根据第一序号和所述第一信息,更新所述历史内存访问信息,所述第一序号是对所述第一信息进行哈希运算得到的。A first update module, configured to update the historical memory access information according to the first sequence number and the first information if multiple prefetch information corresponding to the first information is not obtained, the first sequence number is obtained by performing a hash operation on the first information.
  21. 如权利要求20所述的装置,其特征在于,所述第一更新模块包括:The apparatus of claim 20, wherein the first update module comprises:
    第一更新单元,用于在所述历史内存访问信息未存储所述第一序号和所述第一信息的情况下,在所述历史内存访问信息中创建所述第一序号和所述第一信息所在的记录,以更新所述历史内存访问信息;a first update unit, configured to create the first serial number and the first serial number in the historical memory access information when the historical memory access information does not store the first serial number and the first information the record where the information is located to update the historical memory access information;
    第二更新单元,用于在所述历史内存访问信息存储有所述第一序号,但未存储所述第一信息的情况下,在所述第一序号的记录中存储所述第一信息,以更新所述历史内存访问信息。a second updating unit, configured to store the first information in the record of the first serial number when the historical memory access information stores the first serial number but does not store the first information, to update the historical memory access information.
  22. 如权利要求21所述的装置,其特征在于,所述第二更新单元包括:The apparatus of claim 21, wherein the second update unit comprises:
    第一存储子单元,用于如果所述第一序号的记录中存储的缺页信息的数量未达到第一数量阈值,则在所述第一序号的记录中存储所述第一信息;a first storage subunit, configured to store the first information in the record of the first serial number if the quantity of page fault information stored in the record of the first serial number does not reach the first quantity threshold;
    第二存储子单元,用于如果所述第一序号的记录中存储的缺页信息的数量达到所述第一数量阈值,则删除所述第一序号的记录中存储时间最早的缺页信息以及对应的预取信息,在所述第一序号的记录中存储所述第一信息。The second storage subunit is configured to delete the page fault information with the earliest storage time in the record of the first serial number if the quantity of the page fault information stored in the record of the first serial number reaches the first quantity threshold and the For the corresponding prefetch information, the first information is stored in the record of the first sequence number.
  23. 如权利要求16-22任一所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 16-22, wherein the device further comprises:
    第二更新模块,用于根据缺页队列,更新所述历史内存访问信息,所述缺页队列用于按照时间顺序存储发生缺页异常的内存页的信息。The second update module is configured to update the historical memory access information according to the page fault queue, and the page fault queue is used to store the information of the memory pages in which the page fault exception occurs in chronological order.
  24. 如权利要求23所述的装置,其特征在于,所述第二更新模块包括:The apparatus of claim 23, wherein the second update module comprises:
    第一存储单元,用于将所述第一信息存储在所述缺页队列中;a first storage unit, configured to store the first information in the page fault queue;
    获取单元,用于获取所述缺页队列中位于所述第一信息之前且数量不超过第二数量阈值的内存页信息,得到一个或多个第二信息;an acquisition unit, configured to acquire memory page information that is located before the first information and whose quantity does not exceed a second quantity threshold in the page fault queue, and obtains one or more second information;
    第二存储单元,用于将所述第一信息作为所述一个或多个第二信息中每个第二信息对应的预取信息,存储至所述历史内存访问信息中。A second storage unit, configured to store the first information in the historical memory access information as prefetch information corresponding to each of the one or more second information.
  25. 如权利要求24所述的装置,其特征在于,所述第二存储单元包括:The apparatus of claim 24, wherein the second storage unit comprises:
    第三存储子单元,用于根据所述第一信息与所述一个或多个第二信息中每个第二信息在所述缺页队列中的位置关系,在所述历史内存访问信息中存储所述第一信息与每个第二信息的关联关系。a third storage subunit, configured to store in the historical memory access information according to the positional relationship between the first information and each of the one or more second information in the page fault queue The association relationship between the first information and each second information.
  26. 如权利要求16-25任一所述的装置,其特征在于,所述读取模块包括:The device according to any one of claims 16-25, wherein the reading module comprises:
    读取单元,用于根据所述多个预取信息,从指定存储空间中读取对应的数据到所述内存中相应的内存页上。The reading unit is configured to read the corresponding data from the specified storage space to the corresponding memory page in the memory according to the plurality of prefetch information.
  27. 如权利要求26所述的装置,其特征在于,所述指定存储空间为本设备包括的磁盘上划分的SWAP分区的存储空间,或者本设备包括的XL-FLASH存储器的存储空间,或者远端存储器的存储空间。The apparatus according to claim 26, wherein the designated storage space is the storage space of the SWAP partition divided on the disk included in the device, or the storage space of the XL-FLASH memory included in the device, or the remote storage of storage space.
  28. 如权利要求26或27所述的装置,其特征在于,所述装置还包括:The apparatus of claim 26 or 27, wherein the apparatus further comprises:
    第二确定模块,用于根据第一时间段内所述内存中的内存页的访问时间和访问数量,确定所述内存中的冷页面;a second determining module, configured to determine the cold page in the memory according to the access time and the number of accesses of the memory pages in the memory in the first time period;
    移动模块,用于将所述冷页面上的数据从所述内存移动到所述指定存储空间中。A moving module, configured to move the data on the cold page from the memory to the designated storage space.
  29. 如权利要求16-28任一所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 16-28, wherein the device further comprises:
    第一接收模块,用于接收预取算法性能查询指令;a first receiving module, configured to receive a prefetch algorithm performance query instruction;
    显示模块,用于显示预取算法性能信息,所述预取算法性能信息包括预取准确率和预取覆盖率;a display module, configured to display prefetch algorithm performance information, where the prefetch algorithm performance information includes a prefetch accuracy rate and a prefetch coverage rate;
    其中,所述预取准确率由预取总数量和预取命中数量确定,所述预取覆盖率由预取总数量和访问总数量确定,所述预取总数量是指第二时间段内获取的所有预取信息的总数量,所 述预取命中数量是指所述第二时间段内获取的所有预取信息对应的内存页中被访问的内存页的总数量,所述访问总数量是指所述第二时间段内被访问的所有内存页的总数量。The prefetch accuracy rate is determined by the total number of prefetches and the number of prefetch hits, the prefetch coverage rate is determined by the total number of prefetches and the total number of accesses, and the total number of prefetches refers to the second time period. The total number of all acquired prefetch information, the number of prefetch hits refers to the total number of accessed memory pages in the memory pages corresponding to all prefetch information acquired within the second time period, and the total number of accesses Refers to the total number of all memory pages accessed within the second time period.
  30. 如权利要求29所述的装置,其特征在于,所述装置还包括:The apparatus of claim 29, wherein the apparatus further comprises:
    第二接收模块,用于接收预取参数调整指令,所述预取参数调整指令由关于所述预取算法性能信息的用户反馈确定;a second receiving module, configured to receive a prefetch parameter adjustment instruction, where the prefetch parameter adjustment instruction is determined by user feedback on the performance information of the prefetch algorithm;
    第三更新模块,用于根据所述预取参数调整指令,更新所述历史内存访问信息。A third update module, configured to update the historical memory access information according to the prefetch parameter adjustment instruction.
  31. 一种计算机设备,其特征在于,所述计算机设备包括处理器和存储器;A computer device, characterized in that the computer device includes a processor and a memory;
    所述存储器,用于存储权利要求1-15任一所述的方法所涉及的计算机程序;The memory is used to store the computer program involved in the method of any one of claims 1-15;
    所述处理器,用于执行所述计算机程序实现权利要求1-15任一所述的方法。The processor is configured to execute the computer program to implement the method of any one of claims 1-15.
  32. 一种计算机可读存储介质,其特征在于,所述存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-15任一所述的方法的步骤。A computer-readable storage medium, characterized in that, a computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1-15 are implemented.
PCT/CN2021/117898 2020-09-21 2021-09-13 Method and apparatus for handling missing memory page abnomality, and device and storage medium WO2022057749A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010998076.3 2020-09-21
CN202010998076.3A CN114253458B (en) 2020-09-21 2020-09-21 Memory page fault exception processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022057749A1 true WO2022057749A1 (en) 2022-03-24

Family

ID=80776448

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/117898 WO2022057749A1 (en) 2020-09-21 2021-09-13 Method and apparatus for handling missing memory page abnomality, and device and storage medium

Country Status (2)

Country Link
CN (1) CN114253458B (en)
WO (1) WO2022057749A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130565A (en) * 2023-10-25 2023-11-28 苏州元脑智能科技有限公司 Data processing method, device, disk array card and medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117931693A (en) * 2024-03-22 2024-04-26 摩尔线程智能科技(北京)有限责任公司 Memory management method and memory management unit

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200026663A1 (en) * 2018-07-20 2020-01-23 EMC IP Holding Company LLC Method, device and computer program product for managing storage system
CN110795363A (en) * 2019-08-26 2020-02-14 北京大学深圳研究生院 Hot page prediction method and page scheduling method for storage medium
CN110955495A (en) * 2019-11-26 2020-04-03 网易(杭州)网络有限公司 Management method, device and storage medium of virtualized memory
CN111427804A (en) * 2020-03-12 2020-07-17 深圳震有科技股份有限公司 Method for reducing missing page interruption times, storage medium and intelligent terminal

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104133780B (en) * 2013-05-02 2017-04-05 华为技术有限公司 A kind of cross-page forecasting method, apparatus and system
CN103488523A (en) * 2013-09-26 2014-01-01 华为技术有限公司 Page access method, page access device and server
CN105095094B (en) * 2014-05-06 2018-11-30 华为技术有限公司 EMS memory management process and equipment
KR101940382B1 (en) * 2016-12-21 2019-04-11 연세대학교 산학협력단 Prefetching method and apparatus for pages
CN111143243B (en) * 2019-12-19 2023-06-27 上海交通大学 Cache prefetching method and system based on NVM hybrid memory

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200026663A1 (en) * 2018-07-20 2020-01-23 EMC IP Holding Company LLC Method, device and computer program product for managing storage system
CN110795363A (en) * 2019-08-26 2020-02-14 北京大学深圳研究生院 Hot page prediction method and page scheduling method for storage medium
CN110955495A (en) * 2019-11-26 2020-04-03 网易(杭州)网络有限公司 Management method, device and storage medium of virtualized memory
CN111427804A (en) * 2020-03-12 2020-07-17 深圳震有科技股份有限公司 Method for reducing missing page interruption times, storage medium and intelligent terminal

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130565A (en) * 2023-10-25 2023-11-28 苏州元脑智能科技有限公司 Data processing method, device, disk array card and medium
CN117130565B (en) * 2023-10-25 2024-02-06 苏州元脑智能科技有限公司 Data processing method, device, disk array card and medium

Also Published As

Publication number Publication date
CN114253458B (en) 2024-04-26
CN114253458A (en) 2022-03-29

Similar Documents

Publication Publication Date Title
US10198363B2 (en) Reducing data I/O using in-memory data structures
WO2022057749A1 (en) Method and apparatus for handling missing memory page abnomality, and device and storage medium
JP2021511588A (en) Data query methods, devices and devices
US8874823B2 (en) Systems and methods for managing data input/output operations
US20110087845A1 (en) Burst-based cache dead block prediction
US8086804B2 (en) Method and system for optimizing processor performance by regulating issue of pre-fetches to hot cache sets
US10061517B2 (en) Apparatus and method for data arrangement
US11907164B2 (en) File loading method and apparatus, electronic device, and storage medium
US11461239B2 (en) Method and apparatus for buffering data blocks, computer device, and computer-readable storage medium
US10339055B2 (en) Cache system with multiple cache unit states
US9851925B2 (en) Data allocation control apparatus and data allocation control method
US11481318B2 (en) Method and apparatus, and storage system for translating I/O requests before sending
KR102482516B1 (en) memory address conversion
CN116931838A (en) Solid-state disk cache management method, system, electronic equipment and storage medium
US10067678B1 (en) Probabilistic eviction of partial aggregation results from constrained results storage
CN115495394A (en) Data prefetching method and data prefetching device
US11461101B2 (en) Circuitry and method for selectively controlling prefetching of program instructions
CN114461590A (en) Database file page prefetching method and device based on association rule
US20150134919A1 (en) Information processing apparatus and data access method
CN117235088B (en) Cache updating method, device, equipment, medium and platform of storage system
WO2022223047A1 (en) Data read/write method, data read/write controller, and storage medium
CN117687936A (en) Method, device, equipment and storage medium for improving cache hit rate
CN106407242B (en) Packet processor forwarding database caching
CN117203624A (en) Intelligent caching of prefetchable data
CN118035132A (en) Cache data prefetching method, processor and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21868574

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21868574

Country of ref document: EP

Kind code of ref document: A1