Skip to content

Significant amount of time to compile an empty file #43300

Closed
@alexcrichton

Description

@alexcrichton

Compiling an empty file into an rlib takes about 200 milliseconds locally which is a pretty significant chunk of time! Various passes look like:

$ touch foo.rs
$ rustc +nightly foo.rs --crate-type lib -Z  perf-stats -Z time-passes
time: 0.000; rss: 50MB	parsing
time: 0.000; rss: 50MB	recursion limit
time: 0.000; rss: 50MB	crate injection
time: 0.000; rss: 50MB	plugin loading
time: 0.000; rss: 50MB	plugin registration
time: 0.033; rss: 75MB	expansion
time: 0.000; rss: 75MB	maybe building test harness
time: 0.000; rss: 75MB	maybe creating a macro crate
time: 0.000; rss: 75MB	creating allocators
time: 0.000; rss: 75MB	checking for inline asm in case the target doesn't support it
time: 0.000; rss: 75MB	early lint checks
time: 0.000; rss: 75MB	AST validation
time: 0.000; rss: 78MB	name resolution
time: 0.000; rss: 78MB	complete gated feature checking
time: 0.000; rss: 78MB	lowering ast -> hir
time: 0.000; rss: 78MB	indexing hir
time: 0.000; rss: 78MB	attribute checking
time: 0.000; rss: 78MB	language item collection
time: 0.000; rss: 78MB	lifetime resolution
time: 0.000; rss: 78MB	looking for entry point
time: 0.000; rss: 78MB	looking for plugin registrar
time: 0.000; rss: 78MB	loop checking
time: 0.000; rss: 78MB	static item recursion checking
time: 0.000; rss: 78MB	compute_incremental_hashes_map
time: 0.000; rss: 78MB	load_dep_graph
time: 0.000; rss: 78MB	stability index
time: 0.000; rss: 78MB	stability checking
time: 0.000; rss: 78MB	type collecting
time: 0.000; rss: 78MB	impl wf inference
time: 0.000; rss: 78MB	coherence checking
time: 0.000; rss: 78MB	variance testing
time: 0.000; rss: 78MB	wf checking
time: 0.000; rss: 78MB	item-types checking
time: 0.000; rss: 78MB	item-bodies checking
time: 0.000; rss: 78MB	const checking
time: 0.000; rss: 78MB	privacy checking
time: 0.000; rss: 78MB	intrinsic checking
time: 0.000; rss: 78MB	effect checking
time: 0.000; rss: 78MB	match checking
time: 0.000; rss: 78MB	liveness checking
time: 0.000; rss: 78MB	borrow checking
time: 0.000; rss: 78MB	reachability checking
time: 0.000; rss: 78MB	death checking
time: 0.000; rss: 78MB	unused lib feature checking
time: 0.000; rss: 81MB	lint checking
time: 0.000; rss: 81MB	resolving dependency formats
  time: 0.000; rss: 81MB	write metadata
  time: 0.000; rss: 81MB	translation item collection
  time: 0.000; rss: 81MB	codegen unit partitioning
  time: 0.000; rss: 108MB	internalize symbols
time: 0.064; rss: 108MB	translation
time: 0.000; rss: 108MB	assert dep graph
time: 0.000; rss: 108MB	serialize dep graph
  time: 0.000; rss: 108MB	llvm function passes [1]
  time: 0.000; rss: 108MB	llvm module passes [1]
  time: 0.001; rss: 109MB	codegen passes [1]
  time: 0.001; rss: 109MB	codegen passes [0]
time: 0.007; rss: 110MB	LLVM passes
time: 0.000; rss: 110MB	serialize work products
time: 0.001; rss: 110MB	linking
Total time spent computing SVHs:               0.000
Total time spent computing incr. comp. hashes: 0.000
Total number of incr. comp. hashes computed:   4
Total number of bytes hashed for incr. comp.:  87
Average bytes hashed per incr. comp. HIR node: 21
Total time spent computing symbol hashes:      0.013
Total time spent decoding DefPath tables:      0.028

Notably:

time: 0.033; rss: 75MB	expansion
time: 0.064; rss: 108MB	translation
time: 0.007; rss: 110MB	LLVM passes

I believe the expansion timings are all related to:

Total time spent computing symbol hashes:      0.013
Total time spent decoding DefPath tables:      0.028

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions