Skip to content

[Linux] Performance optimization for Process.memory_full_info() #2107

Closed
@itamarst

Description

Summary

  • OS: Linux
  • Type: performance

Description

Current Process().memory_full_info() reads /proc/<pid>/smaps, and then sums across maps. This can be slow if there are many maps.

Linux provides a /proc/<pid>/smaps_rollup that is the information in smaps summarized across the whole process: exactly what this function is calculating. For processes with large number of mmaps, using this file directly would reduce the cost of memory_full_info() significantly.

This was apparently added to Linux sometime in 2017 or 2018.

It's the same format, so you could the exact same code, even, just open that file instead if it exists.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions