在尝试调试
tokio
构建花费 1 分钟时,我看到了这个:
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| Item | Self time | % of total time | Time | Item count | Incremental load time | Incremental result hashing time |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| run_linker | 34.77s | 65.531 | 34.77s | 1 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| metadata_register_crate | 6.76s | 12.749 | 30.08s | 256 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| expand_crate | 1.68s | 3.174 | 8.60s | 1 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| LLVM_module_codegen_emit_obj | 1.05s | 1.987 | 1.05s | 16 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| LLVM_passes | 964.32ms | 1.817 | 964.32ms | 1 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| metadata_decode_entry_exported_symbols | 806.92ms | 1.521 | 806.92ms | 256 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| metadata_decode_entry_impl_trait_ref | 695.17ms | 1.310 | 695.17ms | 885 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| incr_comp_load_dep_graph | 673.99ms | 1.270 | 673.99ms | 1 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
| crates | 552.37ms | 1.041 | 552.37ms | 1 | 0.00ns | 552.36ms |
+----------------------------------------+-----------+-----------------+----------+------------+-----------------------+---------------------------------+
Total cpu time: 53.058400104s
Filtered results account for 90.400% of total time.
+----------------------------+-----------------+
| Item | Artifact Size |
+----------------------------+-----------------+
| codegen_unit_size_estimate | 101624 bytes |
+----------------------------+-----------------+
| dep_graph | 9086838 bytes |
+----------------------------+-----------------+
| linked_artifact | 245759808 bytes |
+----------------------------+-----------------+
| object_file | 9317344 bytes |
+----------------------------+-----------------+
| query_cache | 2080949 bytes |
+----------------------------+-----------------+
| work_product_index | 12490 bytes |
+----------------------------+-----------------+
注意这一行:
-----+-----------------------+---------------------------------+
| metadata_register_crate | 6.76s | 12.749 | 30.08s | 256 | 0.00ns | 0.00ns |
+----------------------------------------+-----------+-----------------+----------+-------
还有30年代的时间。 我怎样才能减少这个?
metadata_register_crate
是什么意思?
我正在为我的链接器使用模具,但我仍然对高构建时间感到有点震惊。
另外:有什么方法可以解释这些行吗?我在 https://github.com/rust-lang/measureme/blob/master/summarize/README.md 上没有看到任何相关文档 或一般测量。
这是正在计时的代码。我没有使用过这段代码,但它似乎正在对板条箱及其依赖项进行递归解析,以便引用该板条箱的其他代码有一个可以引用的结构。
看起来您的构建涉及了 256 个 crate(#times 列),并且函数本身花费了 6 秒,当您考虑它调用的函数时,总共花费了 30 秒。
至于改进它,我不确定。使用热缓存构建是否同样慢?例如。货物构建--所有目标;货物干净;货物构建——所有目标?