我正在开发一个 C++ 程序,完成后,我想检查内存泄漏,但我发现 valgrind 出现了一个奇怪的错误:
\n\n ==9106== Invalid free() / delete / delete[] / realloc()\n ==9106== at 0x4006C58: free (vg_replace_malloc.c:427)\n ==9106== by 0x42EB637D: free_mem (in /lib/libc-2.5.so)\n ==9106== by 0x42EB5F16: __libc_freeres (in /lib/libc-2.5.so)\n ==9106== by 0x4002451: _vgnU_freeres (vg_preloaded.c:61)\n ==9106== by 0x42E38EA3: _Exit (in /lib/libc-2.5.so)\n ==9106== by 0x42DC0DF3: (below main) (in /lib/libc-2.5.so)\n ==9106== Address 0x403f818 is not stack\'d, malloc\'d or (recently) free\'d\nRun Code Online (Sandbox Code Playgroud)\n\n由于它没有告诉任何有关无效删除所在的行号的信息,因此我不得不使用注释块的方法。
\n\n令人惊讶的是,直到我注释了所有代码,错误仍然出现。
\n\n我终于有了这段代码:
\n\nint main(int argc, char** argv) {\n /* ... all other code */\n return …Run Code Online (Sandbox Code Playgroud) 在 mongoDB 中 - 我可以在 shell 中设置分析级别:
db.setProfilingLevel
问题是,当我重新启动 mongod 时,它会恢复到默认值。
我怎样才能永久设置它(可能在mongod.conf但我似乎找不到这方面的文档)
我正在尝试通过捕获 GPU 帧来分析 Metal 内核。在具有 Metal runloop 的应用程序中,我会单击调试区域中的“相机按钮”,但是每个应用程序生命周期我只调度内核一次,因此我无法单击“相机按钮”(它保持灰色)。
\n\n因此,我尝试通过在第一次调用之前使用“捕获 GPU 帧”操作设置断点来解决此问题mQueue.insertDebugCaptureBoundary()(请参阅下面的代码)。
我期望发生的事情是这样的\ xe2\x80\x93 ,即每个内核函数的执行持续时间的概述,以及执行各行内核函数所花费的时间百分比。
\n\n实际发生的情况是:我很少得到所描述的预期分析概述。大多数时候(大约 95% 的时间)我没有得到这样的分析概述,而是在构建并运行应用程序后发生以下情况之一:
\n\n下面的代码显示了我的问题的简化示例(如果您想知道;不,我在 ViewController 中没有计算逻辑 - 下面的代码只是一个玩具示例;))。
\n\nclass ViewController : UIViewController { \n // initialize Metal, create buffers, etc. \n\n override func viewDidLoad() { \n tick() …Run Code Online (Sandbox Code Playgroud) 我刚开始使用 Google Compute Engine。我想使用 Linux 性能工具对我的应用程序进行一些各种性能事件测量,并最终进行示例分析。我已在 Ubuntu 16.04 LTS VM 上安装了 linux perf 工具。然而,即使是像周期这样的基本事件也会显示为“不支持”。我猜测底层 KVM 管理程序没有启用虚拟 PMU 支持,尽管我相信 KVM 确实通过非默认标志设置支持这一点。有什么办法可以让它发挥作用吗?
# perf stat -e cycles -a sleep 10
Performance counter stats for 'system wide':
<not supported> cycles
10.000598339 seconds time elapsed
Run Code Online (Sandbox Code Playgroud) 我有一个 Node 应用程序,它监听 websocket 数据源并通过与另一个 API 对话来对其进行操作。我现在遇到了性能问题。大多数时候,一切都很安静,CPU 利用率约为 2-5%,但有时(每 24 小时约 3 次)我们收到的 Websocket feed 突然变得疯狂几分钟,包含大量数据。这使得应用程序执行大量计算,导致 CPU 峰值达到 100%,并引发各种其他问题。我无法预测这些繁忙时间,也无法在测试设置中真正复制它。由于这些原因,我很难分析这些峰值。
我不是 Node 专家,但我尝试使用该node --prof标志,后跟该--prof-process标志(在 3GBisolate-0x321c640-v8.log文件上)来分析该应用程序。这没什么问题,但问题是,如果我这样做,我会分析它运行的整个时间,而不是它运行的高流量部分。
我检查了该isolate-0x321c640-v8.log文件(请参阅下面的摘录),希望在每一行上都有某种时间戳,以便我可以隔离我感兴趣的时间,但我在那里找不到类似的内容。
tick,0x8ad1f58c24,26726463388,0,0x3fedc8b5859026ea,0,0x8ad76332f8,0x8ad7619f68,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1f6d472,26726464443,0,0x3ff76afe21366278,0,0x8ad7633873,0x8ad7619f68,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1206bd5,26726465499,0,0x8ad1f58c40,0,0x8ad76332f8,0x8ad7619f68,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1f6d472,26726466552,0,0x400040d9bba74cfb,0,0x8ad763377d,0x8ad7619f68,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1f591fa,26726467615,0,0x3fe94cccccccccce,0,0x8ad7626638,0x8ad761c1d9,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1f6d472,26726468680,0,0x7ffcc894f270,0,0x8ad1f59054,0x8ad7626638,0x8ad761c1d9,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
tick,0x8ad1f6d41c,26726469744,0,0x329ab68,0,0x8ad7626cc9,0x8ad761c1d9,0x84113fbe10b,0x8ad12fd54f,0x8ad734f837,0x8ad735192b,0x8ad59c2598,0x8ad59c9765
Run Code Online (Sandbox Code Playgroud)
有没有一种好方法可以在运行时分析这些特定时间?
鉴于 MiniProfiler 实际上并未针对非本地请求运行,原因如下:
protected void Application_BeginRequest()
{
if (Request.IsLocal)
MiniProfiler.Start();
}
Run Code Online (Sandbox Code Playgroud)
ProfiledDbConnection那么(在性能方面)在生产代码中保留使用还可以吗?
var db = new MyDataContext(new StackExchange.Profiling.Data.ProfiledDbConnection(new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString), MiniProfiler.Current))
Run Code Online (Sandbox Code Playgroud) asp.net-mvc performance profiling linq-to-sql mvc-mini-profiler
前段时间,我问了以下问题“如何计算进程 id 的执行指令数(包括子进程)”,@M-Iduoad 好心提供了一个解决方案来pgrep捕获所有子 PID 并将其与 perf stat 中的 -p 一起使用。效果很好!
然而,我遇到的一个问题是多线程应用程序以及当生成新线程时。由于我不是算命先生(太糟糕了!),我不知道tid新生成的线程,因此我无法将它们添加到perf stat-p 或 -t 参数中。
举个例子,假设我有一个多线程 Nodejs 服务器(作为容器部署在 Kubernetes 之上),具有以下内容pstree:
root@node2:/home/m# pstree -p 4037791\nnode(4037791)\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80sh(4037824)\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80node(4037825)\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80{node}(4037826)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037827)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037828)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037829)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037830)\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80{node}(4037831)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037805)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037806)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037807)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037808)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037809)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037810)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037811)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037812)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037813)\n \xe2\x94\x94\xe2\x94\x80{node}(4037814) \nRun Code Online (Sandbox Code Playgroud)\n当然,我可以使用以下perf stat命令来观察其线程:
perf stat --per-thread -e instructions,cycles,task-clock,cpu-clock,cpu-migrations,context-switches,cache-misses,duration_time -p $(pgrep --ns 4037791 | paste -s -d ",")\nRun Code Online (Sandbox Code Playgroud)\n … 1/output当我想使用clang编译器进行分析时,我应该期待什么?\n2/对于使用编译器CMake` 作为构建工具的程序
,我该如何做?profilingC++ projectclangand
1/ 首先,我使用valgrind工具来检查cpp executable.
\n2/ 后来,我使用g++ compiler并经历了这个,我看到了使用gprof. 使用gprof我已经通过命令行完成的事情。从这个来源我了解到gprof可以提供文本文件的输出(称为analysis.txt),其中写入了函数调用号、执行时间等。
clang编译器和CMake构建工具。我读过 clang 文档,主要是这个和这个。cpp file同一个目录中(这显然不是所需的项目结构),并按照以下命令查看 Instrumentation 是如何完成的以及outcome接下来会发生什么clang++-10 -fprofile-instr-generate -fcoverage-mapping test_gprof.cpp test_gprof_new.cpp -o code_coverage\nLLVM_PROFILE_FILE="code_coverage.profraw" ./code_coverage\nllvm-profdata merge -sparse code_coverage.profraw -o code_coverage.profdata\nllvm-cov show …Run Code Online (Sandbox Code Playgroud) 我想观看从某个应用程序发出的所有HTTP请求,并在需要时取消它们.
有没有办法在C#中做到这一点?
我有一个使用大量矢量图形的Windows CE应用程序,并且在某些地方非常慢.我目前正在使用GDI通过位图进行渲染,以实现无闪烁刷新.通常情况下,我正在看一个大型3D地图的一部分.在某些设备上(例如166mhz SH4),大数据集的刷新时间为3-5秒.我的问题是这个;
有没有人对Windows Mobile与Win32的图形操作的相对速度进行任何比较.换句话说,假设我们只是在寻找GDI调用,是从适用于WinCE版本的软件的Win32版本中分析结果.
有没有人尝试在WinCE平台(C++应用程序)上进行性能分析,如果是的话,使用什么工具.
是否有人知道任何提高Windows CE绘图速度的方法.我目前正在关注FastGraph 之前的问题反馈,但这是一个稍长期的解决方案.糟糕而且全部都是这样,我正在为即将发布的版本更快地寻找更好的东西.
profiling ×10
c++ ×2
linux ×2
perf ×2
performance ×2
asp.net-mvc ×1
c# ×1
clang ×1
cmake ×1
cpu ×1
gdi ×1
http ×1
ios ×1
javascript ×1
kvm ×1
linq-to-sql ×1
metal ×1
mongodb ×1
node.js ×1
valgrind ×1
windows-ce ×1
xcode ×1