在内存使用方面如何描述Erlang程序?

编程入门 行业动态 更新时间:2024-10-13 10:24:21
本文介绍了在内存使用方面如何描述Erlang程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想进一步提高现有Erlang计划的效率。首先我想确定瓶颈,然后决定在哪里进一步优化。

我尝试过 fprof ,但它只提供有关总计和平均运行时间的信息。我最希望看到类似于fprof的输出的日志,但是关于函数和过程的平均和总内存使用情况。

I have tryed fprof, but it only gives information on total and average runtime. I would most like to see a log similar to the output of fprof, but in terms of average and total memory usage with respect to functions and processes.

对于初学者来说,配置一个不会生成过程的单个模块是足够的,只有它的函数才被调用。这将有助于我将程序分成不同的模块进行测试。

For starters it would be enough to profile a single module, that does not spawn processes, only it's functions would be called. This would already help, for I could separate the program to distinct modules for testing.

典型的可疑点是,列表正在处理中。

Typical suspicious points are, where bigger lists are being handled.

这里使用 ++ 已经通过列表解析:反向([Head | Tail])类似语法

Here the usage of ++ has been resolved by lists:reverse([Head|Tail]) like syntax.

我也考虑使用ETS表而不是List

I am also considering using ETS tables instead of Lists for cases with more than a few hundred elements.

提前谢谢!

推荐答案

一些广告为了我自己的缘故:一段时间我写了一个erlang gen_server,记录和记录系统统计信息,结合一些perl脚本解析它们并输出漂亮的图表。

Doing some advertising for my own sake: I wrote a little erlang gen_server a while ago, that records and logs system statistics, combined with a little perl script that parses them and outputs pretty charts.

我发现在加载下进行内存监视等功能非常有用,因为它允许您持续监视内存使用的详细视图,例如测试不同的内容。

I've found it pretty useful for doing memory watching etc. under load, as it allows you to continuously monitor a detailed view of the memory usage, while for instance testing different things.

erlang部分是公平的非侵入式,一个简单的gen_server,你可以从任何地方开始,你可以把它放在你的监督树下。您可以配置轮询频率等,并以简单的json格式将统计信息写入文件。

The erlang part is fairly non-intrusive, a simple gen_server that you can start from anywhere, you can just put it under your supervision tree. You can configure the poll frequency etc, and it will write statistics to a file in a simple json format.

然后Perl脚本运行,并将日志聚合到绘制图表。有基类,如果你知道一点perl,你可以轻松地编写一个类来记录和绘制你想要的任何自定义参数。

The perl script then runs over it, and aggregates the logs to draw charts. There are base-classes, and if you know a little perl, you can easily write a class to log and chart any custom parameter you want.

可以获取脚本来自: github/Amadiro/erlang-statistics

样本图表(Erlang节点泄漏原子):样品图表monoc.mo.funpic.de/ram-usage-vs-time.png

Sample chart (Erlang node that leaks atoms): Sample Chart monoc.mo.funpic.de/ram-usage-vs-time.png

希望这可以帮助你:)

Hope this helps you :)

更多推荐

在内存使用方面如何描述Erlang程序?

本文发布于:2023-11-28 13:39:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   程序   Erlang

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!