如何确定代码在内核空间中的哪些地方花费了大量时间(系统调用)

发布于 2024-08-08 03:31:31 字数 154 浏览 4 评论 0原文

我注意到我的代码运行的 10% 是系统空间。但是我不知道哪个系统调用。不过,我怀疑它要么必须处理文件,要么必须处理时间戳。

有没有一个工具可以找出哪些系统调用是罪魁祸首?另外,我想知道呼叫(和被呼叫者)的频率(和位置)。

我在 AS3 上,

谢谢

I noticed that 10% my code run is system space. However I do NOT know which system calls. I suspect, though, it is either has to do files or timestamps.

Is there a tool to figure out which system calls are the culprits? Also, I want to know the frequency of (and location) of calls (and callee) .

I am on AS3

thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

请帮我爱他 2024-08-15 03:31:31

stracetruss 都将帮助您查看哪些系统调用正在花费时间。 strace 的两个有用选项是:

  1. -T 显示每个系统调用所花费的时间,
  2. -c 总结系统调用计数、调用、错误算作一张桌子。

但这两个选项是互斥的。

您可能需要一个完整的系统分析工具,以便更详细地分析内核。如果您的平台上有的话,DTrace 可能是最好的。

按平台,以下是一些选项:

DTrace 甚至可以帮助您使用 pid 提供程序分析 C/C++ 代码,例如,请参阅 此处

Both strace and truss will help you see which system calls are taking time. Two useful options for strace are:

  1. -T to show the time spent in each system call,
  2. -c to summarize syscall counts, calls, error counts as a table.

The two options are mutually exclusive though.

You may want a full system profiling tool, to allow you to profile the kernel in more detail. DTrace is probably the best if you have it on your platform.

By platform, here are some options:

DTrace can even help you profile your C/C++ code with the pid provider, e.g. see here.

你是我的挚爱i 2024-08-15 03:31:31

如果您使用的是 Linux,请查看 strace。

如果您使用的是其他 Unix 之一,请查看 truss 是否可用。

If you are on Linux have a look at strace.

If you're on one of the other Unixes see if truss is available.

睡美人的小仙女 2024-08-15 03:31:31

如果您的系统有它,那么 truss 命令应该可以执行您想要的操作。

If your system has it then the truss command should do what you want.

不美如何 2024-08-15 03:31:31

如果是 10%,那么 试试这个方法 30 个样品。您将看到大约 3 个样本(也许是 2 个,也许是 4 个)的准确调用。

If it is 10% then try this method for 30 samples. You will see the exact calls on ~3 samples, maybe 2, maybe 4.

冷血 2024-08-15 03:31:31

同样在 Linux 上,您可以尝试 oprofile 分析器。确保您有可用于 libc 和内核的调试符号(许多发行版都将这些符号放在单独的软件包中)。它分析整个系统,而不仅仅是单个进程。我从中得到了有价值的信息。

Again on Linux, you could try the oprofile profiler. Make sure you have debug symbols available for libc and the kernel (many distributions have these on separate packages). It profiles entire systems, not (just) single processes. I've gotten valuable information from it.

2024-08-15 03:31:31

在 Solaris 上,您可以使用 dtrace。

On Solaris, you can use dtrace.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文