Add more timing info to render_html
- Show `create_renderer` and `renderer_after_crate` by default - Don't rewrite `extra_verbose_generic_activity`
This commit is contained in:
parent
bf86fd5221
commit
1d1010f1af
3 changed files with 30 additions and 12 deletions
|
@ -12,6 +12,9 @@ use crate::formats::cache::{Cache, CACHE_KEY};
|
||||||
/// backend renderer has hooks for initialization, documenting an item, entering and exiting a
|
/// backend renderer has hooks for initialization, documenting an item, entering and exiting a
|
||||||
/// module, and cleanup/finalizing output.
|
/// module, and cleanup/finalizing output.
|
||||||
crate trait FormatRenderer<'tcx>: Clone {
|
crate trait FormatRenderer<'tcx>: Clone {
|
||||||
|
/// Gives a description of the renderer. Used for performance profiling.
|
||||||
|
fn descr() -> &'static str;
|
||||||
|
|
||||||
/// Sets up any state required for the renderer. When this is called the cache has already been
|
/// Sets up any state required for the renderer. When this is called the cache has already been
|
||||||
/// populated.
|
/// populated.
|
||||||
fn init(
|
fn init(
|
||||||
|
@ -57,16 +60,20 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
tcx: ty::TyCtxt<'tcx>,
|
tcx: ty::TyCtxt<'tcx>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let (krate, mut cache) = Cache::from_krate(
|
let (krate, mut cache) = tcx.sess.time("create_format_cache", || {
|
||||||
render_info.clone(),
|
Cache::from_krate(
|
||||||
options.document_private,
|
render_info.clone(),
|
||||||
&options.extern_html_root_urls,
|
options.document_private,
|
||||||
&options.output,
|
&options.extern_html_root_urls,
|
||||||
krate,
|
&options.output,
|
||||||
);
|
krate,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
let prof = &tcx.sess.prof;
|
||||||
|
|
||||||
let (mut format_renderer, mut krate) =
|
let (mut format_renderer, mut krate) = prof
|
||||||
T::init(krate, options, render_info, edition, &mut cache, tcx)?;
|
.extra_verbose_generic_activity("create_renderer", T::descr())
|
||||||
|
.run(|| T::init(krate, options, render_info, edition, &mut cache, tcx))?;
|
||||||
|
|
||||||
let cache = Arc::new(cache);
|
let cache = Arc::new(cache);
|
||||||
// Freeze the cache now that the index has been built. Put an Arc into TLS for future
|
// Freeze the cache now that the index has been built. Put an Arc into TLS for future
|
||||||
|
@ -83,6 +90,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
// Render the crate documentation
|
// Render the crate documentation
|
||||||
let mut work = vec![(format_renderer.clone(), item)];
|
let mut work = vec![(format_renderer.clone(), item)];
|
||||||
|
|
||||||
|
let unknown = rustc_span::Symbol::intern("<unknown item>");
|
||||||
while let Some((mut cx, item)) = work.pop() {
|
while let Some((mut cx, item)) = work.pop() {
|
||||||
if item.is_mod() {
|
if item.is_mod() {
|
||||||
// modules are special because they add a namespace. We also need to
|
// modules are special because they add a namespace. We also need to
|
||||||
|
@ -91,6 +99,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
if name.is_empty() {
|
if name.is_empty() {
|
||||||
panic!("Unexpected module with empty name");
|
panic!("Unexpected module with empty name");
|
||||||
}
|
}
|
||||||
|
let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str());
|
||||||
|
|
||||||
cx.mod_item_in(&item, &name, &cache)?;
|
cx.mod_item_in(&item, &name, &cache)?;
|
||||||
let module = match *item.kind {
|
let module = match *item.kind {
|
||||||
|
@ -104,9 +113,10 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
|
|
||||||
cx.mod_item_out(&name)?;
|
cx.mod_item_out(&name)?;
|
||||||
} else if item.name.is_some() {
|
} else if item.name.is_some() {
|
||||||
cx.item(item, &cache)?;
|
prof.generic_activity_with_arg("render_item", &*item.name.unwrap_or(unknown).as_str())
|
||||||
|
.run(|| cx.item(item, &cache))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
|
||||||
format_renderer.after_krate(&krate, &cache, diag)
|
.run(|| format_renderer.after_krate(&krate, &cache, diag))
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,10 @@ crate fn initial_ids() -> Vec<String> {
|
||||||
|
|
||||||
/// Generates the documentation for `crate` into the directory `dst`
|
/// Generates the documentation for `crate` into the directory `dst`
|
||||||
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||||
|
fn descr() -> &'static str {
|
||||||
|
"html"
|
||||||
|
}
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
mut krate: clean::Crate,
|
mut krate: clean::Crate,
|
||||||
options: RenderOptions,
|
options: RenderOptions,
|
||||||
|
|
|
@ -125,6 +125,10 @@ impl JsonRenderer<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
|
fn descr() -> &'static str {
|
||||||
|
"json"
|
||||||
|
}
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
krate: clean::Crate,
|
krate: clean::Crate,
|
||||||
options: RenderOptions,
|
options: RenderOptions,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue