调试符号会影响 Rust 的性能吗? [英] Will debug symbols affect the performance in Rust?

查看:77
本文介绍了调试符号会影响 Rust 的性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行使用调试符号编译的 Rust 实用程序.

I'm running Rust utilities that compiled with debug symbols.

cargo build 
# without the "--release" flag   

与用 C 编写的相同实用程序相比,这些真的很慢.

These are really slow compared to the same utilities written in C.

调试符号是否有可能影响性能?

Is it possible that the debug symbols affected the performance?

推荐答案

回答你的问题

使用调试符号进行编译通常会使您的二进制文件在 Linux 和类 UNIX 平台上变大.这可能意味着您需要从磁盘加载更多数据,这会影响性能.应该没有任何运行时差异.

Answering your question

Compiling with debug symbols will usually make your binary larger on Linux and UNIX-like platforms. This may mean that you need to load more data from disk, which can affect performance. There shouldn't really be any runtime difference.

您可以将调试信息拆分为单独的文件,以避免增加二进制文件的大小.Windows 默认使用 PDB 文件执行此操作,macOS 默认使用 dSYM 文件执行此操作.

You can split the debugging information into separate files to avoid increasing the size of your binaries. Windows does this by default with PDB files and macOS does this by default with dSYM files.

另见:

如果你不使用 --release 编译,你的代码会变慢.如果要判断性能,请使用 --release 编译.

If you don't compile with --release, your code will be slower. Compile with --release if you are judging performance.

在调试模式和发布模式之间切换可以改变的不仅仅是调试符号.优化级别是一个例子,溢出检查是另一个例子.据我所知,除了查看 Cargo 和 Rust 源代码之外,没有完整的更改列表.

Switching between debug mode and release mode can change more than just debug symbols. The level of optimization is one example, overflow checking is another. To my knowledge, there's no complete list of what changes, other than reviewing the Cargo and Rust source code.

另见:

这篇关于调试符号会影响 Rust 的性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆