WO2022188778A1 - Method and apparatus for processing page thrashing in memory recovery, and electronic device - Google Patents
Method and apparatus for processing page thrashing in memory recovery, and electronic device Download PDFInfo
- Publication number
- WO2022188778A1 WO2022188778A1 PCT/CN2022/079747 CN2022079747W WO2022188778A1 WO 2022188778 A1 WO2022188778 A1 WO 2022188778A1 CN 2022079747 W CN2022079747 W CN 2022079747W WO 2022188778 A1 WO2022188778 A1 WO 2022188778A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- thrashing
- page
- processor
- memory
- application scenario
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 238000012545 processing Methods 0.000 title claims abstract description 23
- 238000011084 recovery Methods 0.000 title abstract description 3
- 238000013480 data collection Methods 0.000 claims abstract description 5
- 241000282326 Felis catus Species 0.000 claims description 6
- 239000000284 extract Substances 0.000 claims description 4
- 238000012790 confirmation Methods 0.000 claims description 3
- 230000000694 effects Effects 0.000 abstract description 4
- 230000008569 process Effects 0.000 description 7
- 238000012217 deletion Methods 0.000 description 4
- 230000037430 deletion Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 2
- 238000003672 processing method Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004064 recycling Methods 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
Definitions
- the present application relates to the field of computer technology, and in particular, to a method, device, and electronic device for processing page thrashing in memory reclamation.
- the Linux kernel adopts the principle of "useable and usable, recycling when busy" for memory.
- the "excessive" reclamation of memory will cause some frequently used file pages to be scanned twice in a row, so that the activity is quickly reduced to INACTIVE (inactive), and finally reclaimed to the Buddy system (partner system).
- Subsequent applications visit the corresponding location of the file, causing the action of allocating physical pages or reading the contents of the file to occur again. This process is called page thrashing.
- One or two page thrashing is no problem, but if a large number of file pages are reclaimed due to memory requirements and then read in, this situation will cause system performance to drop, which is manifested as system freezes and inconsistencies. smooth.
- the method, device and electronic device for processing page thrashing in memory reclamation provided by the present application can reduce the impact of page thrashing on system performance.
- the present application provides a method for processing page thrashing in memory reclamation, the method comprising:
- the files corresponding to the page sets in which thrashing occurs in each application scenario are stored in a shared memory file system, wherein the shared memory file system is located in a random access memory.
- the method further includes:
- the performing data collection on multiple application scenarios, and acquiring the bump page data set corresponding to each application scenario includes:
- the same type includes: pid, time, dev, ino or ofs.
- the present application provides a device for processing page thrashing in memory reclamation, the device comprising:
- the acquisition unit is used to collect data for multiple application scenarios, and obtain the bump page data set corresponding to each application scenario;
- a generating unit configured to generate a page set in which thrashing occurs in each application scenario according to the thrashing page data set corresponding to each application scenario;
- the processing unit is configured to store the file corresponding to the page set in which thrashing occurs in each application scenario into a shared memory file system, wherein the shared memory file system is located in a random access memory.
- the device further includes:
- the confirmation unit is used for confirming whether a file is placed in the shared memory file system through the cat/proc/meminfo command and the method of searching the file system after the system is started.
- the acquisition unit is configured to extract the pagecache add/delete records in the ftrace information for each application scenario, and find the add/delete records that conform to the equality principle from the add/delete records as the bump page data. an element in the collection;
- the present application provides an electronic device, the electronic device comprising:
- the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
- the present application provides a chip, the chip comprising:
- the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
- the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the above-mentioned method for processing page thrashing in memory reclamation is implemented.
- the method, device, and electronic device for processing page thrashing in memory reclamation quantitatively analyze the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file in which the page thrashing occurs, and then The file with page thrashing is placed in the shared memory file system, and the shared memory can quickly read from the block device into the memory to reduce the impact of page thrashing on performance.
- FIG. 1 is a flowchart of a method for processing page thrashing in memory reclamation according to an embodiment of the present application
- FIG. 2 is a schematic structural diagram of a device for processing page thrashing in memory reclamation according to an embodiment of the present application.
- An embodiment of the present application provides a method for processing page thrashing in memory reclamation.
- the method is applied to an electronic device. As shown in FIG. 1 , the method includes:
- the method for dealing with page thrashing in memory reclamation quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then retrieve the file with page thrashing. Put it into the shared memory file system, and use the characteristics of shared memory to quickly read into memory from block devices, reducing the impact of page thrashing on performance.
- Ftrace is a powerful debug tool provided by the Linux kernel.
- Ftrace is an embedded debugging method that uses some functions in the GNU tool chain. Its functional framework is mature, supports arbitrary extensions, and has little interference to the load of the system itself.
- Ftrace has preset trace_event (point of outputting trace information) at the location where the file is read into memory (inode's page tree) and reclaimed by memory. These trace_events include the block device number, inode (inode) and file. The offset of the page, which constitutes the data object for analyzing memory reclamation and page thrashing.
- the equality principle is: addition records and deletion records of the same type and the same page in the addition/deletion records.
- the implementation method can specifically include:
- the system extracts the pagecache addition records and pagecache deletion records in the ftrace information, so that multiple pagecache addition records and multiple pagecache deletion records are obtained.
- the pagecache delete record searches for the same page of the same type, and the same page is included in multiple pagecache add records and multiple pagecache delete records.
- the same types as above can include: pid, time, dev, ino, or ofs, but are not limited thereto.
- list_thrashing_common For elements in list_thrashing_common, that is, pages with thrashing in all application scenarios;
- the shmem file is a memory-based file format provided by the Linux operating system. Compared with other file formats stored in non-volatile memory, shmem files can provide faster file reading speeds and smaller page thrashing penalties. . Compared with the previous MLock file page method, putting the files corresponding to the page set list_thrashing_common that has thrashed in the multiple application scenarios into the shmem file system can release more available memory for the system to use, and thrash the pages. Penalties are reduced to a minimum.
- the cold start of the application including facebook, messenger, templerun, camera, etc.
- the cold start of the application including facebook, messenger, templerun, camera, etc.
- the method for dealing with page thrashing in memory reclamation quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then retrieve the file with page thrashing. Put it into the shared memory file system, and take advantage of the feature that shared memory can quickly read memory from block devices, reduce the impact of page thrashing on performance, and avoid the use of non-thrashing scenarios brought by the lock-thrashing page method to a certain extent. Memory reduction.
- An embodiment of the present application further provides a device for processing page thrashing in memory reclamation.
- the device is located in an electronic device. As shown in FIG. 2 , the device includes:
- the acquiring unit 11 is configured to collect data for multiple application scenarios, and acquire a bump page data set corresponding to each application scenario;
- a generating unit 12 configured to generate a page set that thrashes in each application scenario according to the thrashing page data set corresponding to each application scenario;
- the processing unit 13 is configured to store the files corresponding to the page sets in which thrashing occurs in each application scenario into a shared memory file system, wherein the shared memory file system is located in a random access memory.
- the device for processing page thrashing during memory reclamation quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then treat the file with page thrashing. Put it into the shared memory file system, and use the characteristics of shared memory to quickly read into memory from block devices, reducing the impact of page thrashing on performance.
- the device further includes:
- the confirmation unit is used for confirming whether a file is placed in the shared memory file system through the cat/proc/meminfo command and the method of searching the file system after the system is started.
- the obtaining unit 11 is configured to extract the pagecache add/delete records in the ftrace information for each application scenario, and find the add/delete records that conform to the equality principle from the add/delete records as the thrashing page. an element in the dataset;
- the embodiment of the present application also provides an electronic device, the electronic device includes:
- the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
- the embodiment of the present application also provides a chip, the chip includes:
- the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
- Embodiments of the present application further provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the above-mentioned method for processing page thrashing in memory reclamation is implemented.
- the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM) or the like.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
Provided in the present application are a method and apparatus for processing page thrashing in memory recovery, and an electronic device. The method comprises: performing data collection on a plurality of application scenarios, and acquiring a thrashing page data set corresponding to each application scenario; according to the thrashing page data set corresponding to each application scenario, generating a set of pages that thrash in each application scenario; and storing, in a shared memory file system, a file corresponding to the set of pages that thrash in each application scenario, wherein the shared memory file system is located in a random access memory. By means of the present application, the effect of page thrashing on the system performance can be reduced.
Description
本申请要求于2021年3月8日提交中国专利局、申请号为CN202110252780.9、名称为“内存回收中页颠簸的处理方法、装置及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on March 8, 2021 with the application number CN202110252780.9 and entitled "Method, Apparatus and Electronic Equipment for Handling Page Bumps in Memory Recovery", the entire contents of which are Incorporated herein by reference.
本申请涉及计算机技术领域,尤其涉及一种内存回收中页颠簸的处理方法、装置及电子设备。The present application relates to the field of computer technology, and in particular, to a method, device, and electronic device for processing page thrashing in memory reclamation.
目前,Linux内核对于内存采用了“能用且用,忙时回收”的使用原则。内存的“过度”回收会造成一些频繁使用的文件页被连续扫描了两次,从而活动性快速降低为INACTIVE(不活跃),最终被回收到Buddy系统(伙伴系统)。后续应用又访问了文件的对应位置,使得分配物理页或读入文件内容的动作再次发生,这个过程被称为页颠簸。一两个页的颠簸是没有问题的,但是如果有大量的文件页因为内存需求被回收,继而又被读入,这种情况就会造成系统性能的下降,表现出来就是系统的卡顿和不流畅。At present, the Linux kernel adopts the principle of "useable and usable, recycling when busy" for memory. The "excessive" reclamation of memory will cause some frequently used file pages to be scanned twice in a row, so that the activity is quickly reduced to INACTIVE (inactive), and finally reclaimed to the Buddy system (partner system). Subsequent applications visit the corresponding location of the file, causing the action of allocating physical pages or reading the contents of the file to occur again. This process is called page thrashing. One or two page thrashing is no problem, but if a large number of file pages are reclaimed due to memory requirements and then read in, this situation will cause system performance to drop, which is manifested as system freezes and inconsistencies. smooth.
申请内容Application content
本申请提供的内存回收中页颠簸的处理方法、装置及电子设备,能够减小页颠簸对系统性能的影响。The method, device and electronic device for processing page thrashing in memory reclamation provided by the present application can reduce the impact of page thrashing on system performance.
第一方面,本申请提供一种内存回收中页颠簸的处理方法,所述方法包括:In a first aspect, the present application provides a method for processing page thrashing in memory reclamation, the method comprising:
对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合;Collect data for multiple application scenarios, and obtain the bump page data set corresponding to each application scenario;
根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合;generating, according to the thrashing page data set corresponding to each application scenario, a page set in which thrashing occurs in each application scenario;
将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。The files corresponding to the page sets in which thrashing occurs in each application scenario are stored in a shared memory file system, wherein the shared memory file system is located in a random access memory.
可选地,所述方法还包括:Optionally, the method further includes:
在系统启动后,通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了所述共享内存文件系统。After the system is started, confirm whether a file is placed in the shared memory file system through the cat /proc/meminfo command and by searching the file system.
可选地,所述对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合包括:Optionally, the performing data collection on multiple application scenarios, and acquiring the bump page data set corresponding to each application scenario includes:
对于每个应用场景,抽取ftrace信息中的pagecache添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素;For each application scenario, extract the pagecache add/delete records in the ftrace information, and find the add/delete records that conform to the equality principle from the add/delete records as an element in the thrashing page data set;
所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。The equality principle is: add records and delete records of the same type and the same page in the add/delete records.
可选地,所述相同类型包括:pid、time、dev、ino或ofs。Optionally, the same type includes: pid, time, dev, ino or ofs.
第二方面,本申请提供一种内存回收中页颠簸的处理装置,所述装置包括:In a second aspect, the present application provides a device for processing page thrashing in memory reclamation, the device comprising:
获取单元,用于对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸 页数据集合;The acquisition unit is used to collect data for multiple application scenarios, and obtain the bump page data set corresponding to each application scenario;
生成单元,用于根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合;a generating unit, configured to generate a page set in which thrashing occurs in each application scenario according to the thrashing page data set corresponding to each application scenario;
处理单元,用于将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。The processing unit is configured to store the file corresponding to the page set in which thrashing occurs in each application scenario into a shared memory file system, wherein the shared memory file system is located in a random access memory.
可选地,所述装置还包括:Optionally, the device further includes:
确认单元,用于在系统启动后,通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了所述共享内存文件系统。The confirmation unit is used for confirming whether a file is placed in the shared memory file system through the cat/proc/meminfo command and the method of searching the file system after the system is started.
可选地,所述获取单元,用于对于每个应用场景,抽取ftrace信息中的pagecache添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素;Optionally, the acquisition unit is configured to extract the pagecache add/delete records in the ftrace information for each application scenario, and find the add/delete records that conform to the equality principle from the add/delete records as the bump page data. an element in the collection;
所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。The equality principle is: add records and delete records of the same type and the same page in the add/delete records.
第三方面,本申请提供一种电子设备,所述电子设备包括:In a third aspect, the present application provides an electronic device, the electronic device comprising:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述内存回收中页颠簸的处理方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
第四方面,本申请提供一种芯片,所述芯片包括:In a fourth aspect, the present application provides a chip, the chip comprising:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述内存回收中页颠簸的处理方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
第五方面,本申请提供一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令被处理器执行时实现上述内存回收中页颠簸的处理方法。In a fifth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the above-mentioned method for processing page thrashing in memory reclamation is implemented.
本申请实施例提供的内存回收中页颠簸的处理方法、装置及电子设备,针对Linux系统的内存回收过程中引起的页颠簸进行了定量的分析,可以准确获得发生了页颠簸的文件,然后将发生页颠簸的文件放入共享内存文件系统中,利用共享内存能够快速从块设备读入内存的特点,减小页颠簸对性能的影响。The method, device, and electronic device for processing page thrashing in memory reclamation provided by the embodiments of the present application quantitatively analyze the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file in which the page thrashing occurs, and then The file with page thrashing is placed in the shared memory file system, and the shared memory can quickly read from the block device into the memory to reduce the impact of page thrashing on performance.
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative labor.
图1为本申请一实施例内存回收中页颠簸的处理方法的流程图;FIG. 1 is a flowchart of a method for processing page thrashing in memory reclamation according to an embodiment of the present application;
图2为本申请一实施例内存回收中页颠簸的处理装置的结构示意图。FIG. 2 is a schematic structural diagram of a device for processing page thrashing in memory reclamation according to an embodiment of the present application.
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments It is only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
本申请实施例提供一种内存回收中页颠簸的处理方法,所述方法应用于电子设备,如图1所示,所述方法包括:An embodiment of the present application provides a method for processing page thrashing in memory reclamation. The method is applied to an electronic device. As shown in FIG. 1 , the method includes:
S11、对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合。S11. Data collection is performed on multiple application scenarios, and a bump page data set corresponding to each application scenario is acquired.
S12、根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合。S12. Generate a page set in which thrashing occurs in each application scenario according to the thrashing page data set corresponding to each application scenario.
S13、将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。S13. Store the file corresponding to the page set in which thrashing occurs in each application scenario into a shared memory file system, where the shared memory file system is located in a random access memory.
本申请实施例提供的内存回收中页颠簸的处理方法,针对Linux系统的内存回收过程中引起的页颠簸进行了定量的分析,可以准确获得发生了页颠簸的文件,然后将发生页颠簸的文件放入共享内存文件系统中,利用共享内存能够快速从块设备读入内存的特点,减小页颠簸对性能的影响。The method for dealing with page thrashing in memory reclamation provided by the embodiments of the present application quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then retrieve the file with page thrashing. Put it into the shared memory file system, and use the characteristics of shared memory to quickly read into memory from block devices, reducing the impact of page thrashing on performance.
下面结合具体实施例对本申请内存回收中页颠簸的处理方法进行详细说明。The processing method for page thrashing in memory reclamation of the present application will be described in detail below with reference to specific embodiments.
本实施例提供的内存回收中页颠簸的处理方法包括如下步骤:The processing method for page thrashing in memory reclamation provided by this embodiment includes the following steps:
S21、对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合page_thrashing[]。S21 , data collection is performed on multiple application scenarios, and a thrashing page data set page_thrashing[] corresponding to each application scenario is obtained.
具体地,对于每个应用场景,抽取Ftrace信息中的pagecache(页面缓存)添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素。Specifically, for each application scenario, extract the pagecache (page cache) add/delete records in the Ftrace information, and find the add/delete records that conform to the equality principle from the add/delete records as one of the thrashing page data sets element.
其中,Ftrace为Linux内核提供的一个强大的debug工具,Ftrace是一个使用GNU工具链中部分功能的嵌入式调试手段,其功能框架成熟,支持任意的扩展且对系统本身的负载干扰很小。而Ftrace已经在文件被读入内存(inode的page tree)和被内存回收的位置预置了trace_event(输出trace信息的点),这些trace_event中包括了块设备的编号,inode(索引节点)和文件页的偏移,这些信息构成了分析内存回收和页颠簸的数据对象。Among them, Ftrace is a powerful debug tool provided by the Linux kernel. Ftrace is an embedded debugging method that uses some functions in the GNU tool chain. Its functional framework is mature, supports arbitrary extensions, and has little interference to the load of the system itself. Ftrace has preset trace_event (point of outputting trace information) at the location where the file is read into memory (inode's page tree) and reclaimed by memory. These trace_events include the block device number, inode (inode) and file. The offset of the page, which constitutes the data object for analyzing memory reclamation and page thrashing.
其中,所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。Wherein, the equality principle is: addition records and deletion records of the same type and the same page in the addition/deletion records.
其实现的方法具体可以包括:The implementation method can specifically include:
运行多个应用场景,每运行一个应用场景,系统抽取ftrace信息中的pagecache添加记录以及pagecache删除记录,这样即得到多个pagecache添加记录以及多个pagecache删除记录,从多个pagecache添加记录以及多个pagecache删除记录查找相同类型的相同页,该相同页即包含在多个pagecache添加记录之中,也包含在多个pagecache删除记录之中。Running multiple application scenarios, each time an application scenario is run, the system extracts the pagecache addition records and pagecache deletion records in the ftrace information, so that multiple pagecache addition records and multiple pagecache deletion records are obtained. The pagecache delete record searches for the same page of the same type, and the same page is included in multiple pagecache add records and multiple pagecache delete records.
上述相同类型可以包括:pid、time、dev、ino或ofs,但不仅限于此。The same types as above can include: pid, time, dev, ino, or ofs, but are not limited thereto.
S22、对所述颠簸页数据集合page_thrashing[]中各个元素求交集,得到所述多个应用场景中都发生颠簸的页集合list_thrashing_common;对所述颠簸页数据集合page_thrashing[]中各个元素求合集,得到所有发生过颠簸的页集合list_thrashing_all。S22, find the intersection of each element in the thrashing page data set page_thrashing[], and obtain the page set list_thrashing_common in which thrashing occurs in the multiple application scenarios; find a collection of each element in the thrashing page data set page_thrashing[], Get all thrashing page sets list_thrashing_all.
具体地,对颠簸页数据集合中各元素求交集,将所有应用场景中均发生颠簸的页集合到list_thrashing_common。对于list_thrashing_common中的元素,即所有的应用场景中均发生颠簸的页;Specifically, the intersection of each element in the thrashing page data set is obtained, and the pages that have thrashing in all application scenarios are collected into list_thrashing_common. For elements in list_thrashing_common, that is, pages with thrashing in all application scenarios;
对颠簸页数据集合中各元素求合集,将所有应用场景中发生过一次或多次颠簸的页集合到list_thrashing_all。对于list_thrashing_all中的元素,即至少一个应用场景中发生颠簸的页。Collect each element in the thrashing page data set, and collect the pages that have thrashed one or more times in all application scenarios into list_thrashing_all. For elements in list_thrashing_all, that is, at least one page where thrashing occurs in an application scenario.
S23、将所述多个应用场景中都发生颠簸的页集合list_thrashing_common对应的文件放入shmem(共享内存)文件系统。S23. Put the files corresponding to the page set list_thrashing_common in which thrashing occurs in the multiple application scenarios into the shmem (shared memory) file system.
依赖于该文件系统向基于DDR SDRAM(双倍速率同步动态随机存取存储器)的swap(交换)区进行压缩后交换的特点,其中的文件即使发生了颠簸也会以较快的速度从swap区域回到内存中,达到减小颠簸影响的效果。Relying on the characteristics of the file system to compress the swap (swap) area based on DDR SDRAM (double rate synchronous dynamic random access memory), the files in it will be removed from the swap area at a faster speed even if thrashing occurs. Back in memory to achieve the effect of reducing the impact of thrashing.
shmem文件是Linux操作系统提供的一种基于内存存储的文件形式,相比于其它存储于非易失性存储器的文件形式,shmem文件可以提供更快的文件读入速度和更小的页颠簸惩罚。相较于以往的MLock文件页方式,将所述多个应用场景中都发生颠簸的页集合list_thrashing_common对应的文件放入shmem文件系统,可以释放更多的可用内存给系统使用,并将页颠簸的惩罚减小到最小。The shmem file is a memory-based file format provided by the Linux operating system. Compared with other file formats stored in non-volatile memory, shmem files can provide faster file reading speeds and smaller page thrashing penalties. . Compared with the previous MLock file page method, putting the files corresponding to the page set list_thrashing_common that has thrashed in the multiple application scenarios into the shmem file system can release more available memory for the system to use, and thrash the pages. Penalties are reduced to a minimum.
进一步地,在系统启动后,可以通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了shmem文件系统,以确保所操作的系统下是否有文件进行了如上所述的页颠簸的处理方式。Further, after the system is started, you can use the cat/proc/meminfo command and the method of searching the file system to confirm whether there are files in the shmem file system to ensure whether there are files under the operating system. Bumpy handling.
通过在多个平台上进行验证,针对应用程序的冷启动,包括facebook、messenger、templerun,camera等,采用本实施例提供的方法,都会有10%左右的时间优化。Through verification on multiple platforms, the cold start of the application, including facebook, messenger, templerun, camera, etc., will be optimized by about 10% of the time by using the method provided in this embodiment.
本申请实施例提供的内存回收中页颠簸的处理方法,针对Linux系统的内存回收过程中引起的页颠簸进行了定量的分析,可以准确获得发生了页颠簸的文件,然后将发生页颠簸的文件放入共享内存文件系统中,利用共享内存能够快速从块设备读入内存的特点,减小页颠簸对性能的影响,并且能够在一定程度上避免采用锁颠簸页方式带来的非颠簸场景可用内存减少。The method for dealing with page thrashing in memory reclamation provided by the embodiments of the present application quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then retrieve the file with page thrashing. Put it into the shared memory file system, and take advantage of the feature that shared memory can quickly read memory from block devices, reduce the impact of page thrashing on performance, and avoid the use of non-thrashing scenarios brought by the lock-thrashing page method to a certain extent. Memory reduction.
本申请实施例还提供一种内存回收中页颠簸的处理装置,所述装置位于电子设备,如图2所示,所述装置包括:An embodiment of the present application further provides a device for processing page thrashing in memory reclamation. The device is located in an electronic device. As shown in FIG. 2 , the device includes:
获取单元11,用于对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合;The acquiring unit 11 is configured to collect data for multiple application scenarios, and acquire a bump page data set corresponding to each application scenario;
生成单元12,用于根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合;A generating unit 12, configured to generate a page set that thrashes in each application scenario according to the thrashing page data set corresponding to each application scenario;
处理单元13,用于将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。The processing unit 13 is configured to store the files corresponding to the page sets in which thrashing occurs in each application scenario into a shared memory file system, wherein the shared memory file system is located in a random access memory.
本申请实施例提供的内存回收中页颠簸的处理装置,针对Linux系统的内存回收过程中引起的页颠簸进行了定量的分析,可以准确获得发生了页颠簸的文件,然后将发生页颠簸的文件放入共享内存文件系统中,利用共享内存能够快速从块设备读入内存的特点,减小页颠簸对性能的影响。The device for processing page thrashing during memory reclamation provided by the embodiment of the present application quantitatively analyzes the page thrashing caused by the memory reclamation process of the Linux system, and can accurately obtain the file with page thrashing, and then treat the file with page thrashing. Put it into the shared memory file system, and use the characteristics of shared memory to quickly read into memory from block devices, reducing the impact of page thrashing on performance.
可选地,所述装置还包括:Optionally, the device further includes:
确认单元,用于在系统启动后,通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了所述共享内存文件系统。The confirmation unit is used for confirming whether a file is placed in the shared memory file system through the cat/proc/meminfo command and the method of searching the file system after the system is started.
可选地,所述获取单元11,用于对于每个应用场景,抽取ftrace信息中的pagecache添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素;Optionally, the obtaining unit 11 is configured to extract the pagecache add/delete records in the ftrace information for each application scenario, and find the add/delete records that conform to the equality principle from the add/delete records as the thrashing page. an element in the dataset;
所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。The equality principle is: add records and delete records of the same type and the same page in the add/delete records.
本实施例的装置,可以用于执行上述方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The apparatus of this embodiment can be used to implement the technical solutions of the foregoing method embodiments, and the implementation principles and technical effects thereof are similar, and details are not described herein again.
本申请实施例还提供一种电子设备,所述电子设备包括:The embodiment of the present application also provides an electronic device, the electronic device includes:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述内存回收中页颠簸的处理方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
本申请实施例还提供一种芯片,所述芯片包括:The embodiment of the present application also provides a chip, the chip includes:
至少一个处理器;以及at least one processor; and
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述内存回收中页颠簸的处理方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned method for processing page thrashing in memory reclamation.
本申请实施例还提供一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令被处理器执行时实现上述内存回收中页颠簸的处理方法。Embodiments of the present application further provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the above-mentioned method for processing page thrashing in memory reclamation is implemented.
本领域普通技术人员可以理解实现上述方法实施例中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。Those of ordinary skill in the art can understand that the realization of all or part of the processes in the above method embodiments can be accomplished by instructing relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. During execution, the processes of the embodiments of the above-mentioned methods may be included. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM) or the like.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应该以权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, All should be covered within the scope of protection of this application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims (10)
- 一种内存回收中页颠簸的处理方法,其中,所述方法包括:A method for processing page thrashing in memory reclamation, wherein the method includes:对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合;Collect data for multiple application scenarios, and obtain the bump page data set corresponding to each application scenario;根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合;generating, according to the thrashing page data set corresponding to each application scenario, a page set in which thrashing occurs in each application scenario;将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。The files corresponding to the page sets in which thrashing occurs in each application scenario are stored in a shared memory file system, wherein the shared memory file system is located in a random access memory.
- 根据权利要求1所述的方法,其中,所述方法还包括:The method of claim 1, wherein the method further comprises:在系统启动后,通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了所述共享内存文件系统。After the system is started, confirm whether a file is placed in the shared memory file system through the cat /proc/meminfo command and by searching the file system.
- 根据权利要求1或2所述的方法,其中,所述对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合包括:The method according to claim 1 or 2, wherein the performing data collection on multiple application scenarios, and acquiring the bump page data set corresponding to each application scenario comprises:对于每个应用场景,抽取ftrace信息中的pagecache添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素;For each application scenario, extract the pagecache add/delete records in the ftrace information, and find the add/delete records that conform to the equality principle from the add/delete records as an element in the thrashing page data set;所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。The equality principle is: add records and delete records of the same type and the same page in the add/delete records.
- 根据权利要求3所述的方法,其中,所述相同类型包括:pid、time、dev、ino或ofs。The method of claim 3, wherein the same type comprises: pid, time, dev, ino, or ofs.
- 一种内存回收中页颠簸的处理装置,其中,所述装置包括:A device for processing page thrashing in memory reclamation, wherein the device includes:获取单元,用于对多个应用场景进行数据采集,获取与每个应用场景对应的颠簸页数据集合;The acquisition unit is used to collect data for multiple application scenarios, and obtain the bump page data set corresponding to each application scenario;生成单元,用于根据所述与每个应用场景对应的颠簸页数据集合,生成每个应用场景中都发生颠簸的页集合;a generating unit, configured to generate a page set in which thrashing occurs in each application scenario according to the thrashing page data set corresponding to each application scenario;处理单元,用于将所述每个应用场景中都发生颠簸的页集合对应的文件存入共享内存文件系统,其中,所述共享内存文件系统位于随机存取存储器。The processing unit is configured to store the file corresponding to the page set in which thrashing occurs in each application scenario into a shared memory file system, wherein the shared memory file system is located in a random access memory.
- 根据权利要求5所述的装置,其中,所述装置还包括:The apparatus of claim 5, wherein the apparatus further comprises:确认单元,用于在系统启动后,通过cat/proc/meminfo命令和搜索文件系统的方式确认是否有文件放入了所述共享内存文件系统。The confirmation unit is used for confirming whether a file is placed in the shared memory file system through the cat/proc/meminfo command and the method of searching the file system after the system is started.
- 根据权利要求5或6所述的装置,其中,所述获取单元,用于对于每个应用场景,抽取ftrace信息中的pagecache添加/删除记录,从添加/删除记录中查找出符合相等原则的添加/删除记录作为所述颠簸页数据集合中的一个元素;The device according to claim 5 or 6, wherein the acquisition unit is configured to extract pagecache add/delete records in the ftrace information for each application scenario, and find out the add/delete records that meet the equality principle from the add/delete records. /Delete the record as an element in the bump page data set;所述相等原则为:相同类型且添加/删除记录中相同页的添加记录以及删除记录。The equality principle is: add records and delete records of the same type and the same page in the add/delete records.
- 一种电子设备,其中,所述电子设备包括:An electronic device, wherein the electronic device comprises:至少一个处理器;以及at least one processor; and与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1至4中任一项所述的方法。The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the execution of any one of claims 1 to 4 Methods.
- 一种芯片,其中,所述芯片包括:A chip, wherein the chip includes:至少一个处理器;以及at least one processor; and与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1至4中任一项所述的方法。The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the execution of any one of claims 1 to 4 Methods.
- 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令被处理器执行时实现如权利要求1至4中任一项所述的方法。A computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method of any one of claims 1 to 4.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110252780.9 | 2021-03-08 | ||
CN202110252780.9A CN113051186B (en) | 2021-03-08 | 2021-03-08 | Method and device for processing page bump in memory recovery and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022188778A1 true WO2022188778A1 (en) | 2022-09-15 |
Family
ID=76510740
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/079747 WO2022188778A1 (en) | 2021-03-08 | 2022-03-08 | Method and apparatus for processing page thrashing in memory recovery, and electronic device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113051186B (en) |
WO (1) | WO2022188778A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051186B (en) * | 2021-03-08 | 2022-06-24 | 北京紫光展锐通信技术有限公司 | Method and device for processing page bump in memory recovery and electronic equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5630097A (en) * | 1991-06-17 | 1997-05-13 | Digital Equipment Corporation | Enhanced cache operation with remapping of pages for optimizing data relocation from addresses causing cache misses |
CN102110073A (en) * | 2011-02-01 | 2011-06-29 | 中国科学院计算技术研究所 | Replacement device and method for chip shared cache and corresponding processor |
CN106371765A (en) * | 2016-08-29 | 2017-02-01 | 成都科鸿达科技有限公司 | Method for removing memory thrashing through efficient LTL ((Linear Temporal Logic) model detection of large-scale system |
CN111666227A (en) * | 2020-06-16 | 2020-09-15 | 北京紫光展锐通信技术有限公司 | Page bump protection method and device for memory recovery of operating system |
CN111666226A (en) * | 2020-06-16 | 2020-09-15 | 北京紫光展锐通信技术有限公司 | Page bump protection method for operating system memory recovery and user equipment |
CN113051186A (en) * | 2021-03-08 | 2021-06-29 | 北京紫光展锐通信技术有限公司 | Method and device for processing page jolt in memory recovery and electronic equipment |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1149736A (en) * | 1995-06-05 | 1997-05-14 | 北京航空航天大学 | Distributing storage sharing management method |
CN102004675A (en) * | 2010-11-11 | 2011-04-06 | 福建星网锐捷网络有限公司 | Cross-process data transmission method, device and network equipment |
-
2021
- 2021-03-08 CN CN202110252780.9A patent/CN113051186B/en active Active
-
2022
- 2022-03-08 WO PCT/CN2022/079747 patent/WO2022188778A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5630097A (en) * | 1991-06-17 | 1997-05-13 | Digital Equipment Corporation | Enhanced cache operation with remapping of pages for optimizing data relocation from addresses causing cache misses |
CN102110073A (en) * | 2011-02-01 | 2011-06-29 | 中国科学院计算技术研究所 | Replacement device and method for chip shared cache and corresponding processor |
CN106371765A (en) * | 2016-08-29 | 2017-02-01 | 成都科鸿达科技有限公司 | Method for removing memory thrashing through efficient LTL ((Linear Temporal Logic) model detection of large-scale system |
CN111666227A (en) * | 2020-06-16 | 2020-09-15 | 北京紫光展锐通信技术有限公司 | Page bump protection method and device for memory recovery of operating system |
CN111666226A (en) * | 2020-06-16 | 2020-09-15 | 北京紫光展锐通信技术有限公司 | Page bump protection method for operating system memory recovery and user equipment |
CN113051186A (en) * | 2021-03-08 | 2021-06-29 | 北京紫光展锐通信技术有限公司 | Method and device for processing page jolt in memory recovery and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN113051186B (en) | 2022-06-24 |
CN113051186A (en) | 2021-06-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3197403B2 (en) | Control method of computer system when application program failure occurs | |
JP2667039B2 (en) | Data management system and data management method | |
WO2016070529A1 (en) | Method and device for achieving duplicated data deletion | |
CN109522273B (en) | Method and device for realizing data writing | |
US20140365833A1 (en) | Capturing trace information using annotated trace output | |
WO2022188778A1 (en) | Method and apparatus for processing page thrashing in memory recovery, and electronic device | |
CN110019063B (en) | Method for computing node data disaster recovery playback, terminal device and storage medium | |
US9507657B2 (en) | Investigation program, information processing apparatus, and information processing method | |
US8402230B2 (en) | Recoverability while adding storage to a redirect-on-write storage pool | |
US9405786B2 (en) | System and method for database flow management | |
US10430115B2 (en) | System and method for optimizing multiple packaging operations in a storage system | |
WO2021068515A1 (en) | Data management method and device in storage system | |
CN103236938A (en) | Method and system for user action collection based on cache memory and asynchronous processing technology | |
WO2024131057A1 (en) | Method and apparatus for obtaining file system difference data, device, and medium | |
CN109032940B (en) | Test scene input method, device, equipment and storage medium | |
US11874753B2 (en) | Log compression | |
US10437812B2 (en) | Information processing method, information processing device, and medium | |
CN108121514B (en) | Meta information updating method and device, computing equipment and computer storage medium | |
US8984336B1 (en) | Systems and methods for performing first failure data captures | |
US9378009B2 (en) | Method and device for accelerating running of software | |
CN108958968B (en) | File processing method and device | |
CN105718357A (en) | Memory monitoring method | |
CN112286876A (en) | Log file capturing method and device and computer readable storage medium | |
CN111045787A (en) | Rapid continuous experiment method and system | |
CN110442565B (en) | Data processing method, device, computer equipment and storage medium |
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: 22766301 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 16.02.2024) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22766301 Country of ref document: EP Kind code of ref document: A1 |