Skip to content

Profile CGUs #89568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ bitflags::bitflags! {
const LLVM = 1 << 7;
const INCR_RESULT_HASHING = 1 << 8;

const CGU_NAMES = 1 << 9;

const DEFAULT = Self::GENERIC_ACTIVITIES.bits |
Self::QUERY_PROVIDERS.bits |
Self::QUERY_BLOCKED.bits |
Expand All @@ -136,6 +138,7 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
("args", EventFilter::ARGS),
("llvm", EventFilter::LLVM),
("incr-result-hashing", EventFilter::INCR_RESULT_HASHING),
("cgu-names", EventFilter::CGU_NAMES),
];

/// Something that uniquely identifies a query invocation.
Expand Down Expand Up @@ -425,6 +428,7 @@ pub struct SelfProfiler {
incremental_result_hashing_event_kind: StringId,
query_blocked_event_kind: StringId,
query_cache_hit_event_kind: StringId,
cgu_merge_event_kind: StringId,
}

impl SelfProfiler {
Expand All @@ -447,6 +451,7 @@ impl SelfProfiler {
profiler.alloc_string("IncrementalResultHashing");
let query_blocked_event_kind = profiler.alloc_string("QueryBlocked");
let query_cache_hit_event_kind = profiler.alloc_string("QueryCacheHit");
let cgu_merge_event_kind = profiler.alloc_string("CguMerged");

let mut event_filter_mask = EventFilter::empty();

Expand Down Expand Up @@ -491,6 +496,7 @@ impl SelfProfiler {
incremental_result_hashing_event_kind,
query_blocked_event_kind,
query_cache_hit_event_kind,
cgu_merge_event_kind,
})
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_monomorphize/src/partitioning/merging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub fn merge_codegen_units<'tcx>(
let mut consumed_cgu_names = cgu_contents.remove(&smallest.name()).unwrap();
cgu_contents.get_mut(&second_smallest.name()).unwrap().append(&mut consumed_cgu_names);

// TODO emit event indicating which CGU's were merged, and their sizes.

debug!(
"CodegenUnit {} merged into CodegenUnit {}",
smallest.name(),
Expand Down