简体   繁体   English

跟踪嵌入式实时 MPI 可执行文件中的 memory 使用情况

[英]Tracking memory usage in embedded real-time MPI executable

I have been doing some digging lately, and I am trying to see what the best approach is to track memory usage in real time software that is always running on Linux (in this case on a bunch of nodes, using MPI).我最近一直在做一些挖掘工作,我想看看最好的方法是在始终运行在 Linux 上的实时软件中跟踪 memory 的使用情况(在这种情况下,在一堆节点上,使用 MPI)。 Since there is no end-condition for the code, I want to be able to track the memory usage in real time, to see which MPI image is using the most, which functions are using the most, how much each node is using, and how much the entire executable is using across the entire system.由于代码没有结束条件,我希望能够实时跟踪 memory 的使用情况,查看哪个 MPI 图像使用最多,哪些功能使用最多,每个节点使用多少,以及整个可执行文件在整个系统中的使用量。

Are there tools already out there for such a thing?是否已经有工具可以做这样的事情? It seems like most things I find are profilers that give results after the fact.似乎我发现的大多数东西都是事后给出结果的分析器。 Hopefully the answer will be able to track the memory usage of my software, and 3rd party libs my software is using, which I have no access to source code.希望答案能够跟踪我的软件的 memory 使用情况,以及我的软件正在使用的第 3 方库,我无法访问源代码。

The OS can usually provide the data dynamically during the run time per executable/thread (see the linux ps command for example).操作系统通常可以在每个可执行文件/线程的运行时动态地提供数据(例如,参见 linux ps命令)。

If you want to trace the callers, then you can override the new and delete operators to gather run-time allocation/release data and trace which function called it and log it somewhere.如果要跟踪调用者,则可以覆盖newdelete运算符以收集运行时分配/释放数据并跟踪 function 调用它并将其记录在某处。

As littleadv proposed: I would override new/delete (probably malloc/free) and trace the allocations and the size of them.正如 littleadv 建议的那样:我将覆盖 new/delete(可能是 malloc/free)并跟踪分配和它们的大小。 A good way to keep track of such allocations is to just push them to a file or through a network stream to allow another program to analyze the logs.跟踪此类分配的一个好方法是将它们推送到文件或通过网络 stream 以允许另一个程序分析日志。 It's fairly simple to write a python/lua script to parse logs (if you format them well) that can present the information to you in a good way.编写一个 python/lua 脚本来解析日志(如果你格式化它们)是相当简单的,它可以很好地向你展示信息。

Overriding 3rd-party software memory allocations can be rough depending on how you link them.覆盖第 3 方软件 memory 分配可能很粗略,具体取决于您如何链接它们。 Memory overriding through DLL's are often a rough pain so see if you can link them statically to force them to use your allocations. Memory 通过 DLL 覆盖通常会很痛苦,因此请查看是否可以静态链接它们以强制它们使用您的分配。

Take a look into vstat .看看vstat ( man pages for vstat ) vstat 的手册页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM