Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

add option to report timing, as well as reporting time taken to output #381

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iximeow
Copy link
Contributor

@iximeow iximeow commented Dec 19, 2019

Adds a --report-times which makes for nice breakdowns via lucetc --report-times slow_to_compile.wat like:

======== ========  ==================================
   Total     Self  Pass
-------- --------  ----------------------------------
   0.000    0.000  Translate WASM module
   0.001    0.001  Translate WASM function
  12.435    3.888  Verify Cranelift IR
   0.005    0.005  Verify CSSA
   0.008    0.008  Verify live ranges
   0.005    0.005  Verify value locations
   0.086    0.086  Verify CPU flags
  15.781    0.006  Compilation passes
   0.049    0.049  Control flow graph
  10.828   10.828  Dominator tree
   0.260    0.260  Loop analysis
   0.003    0.003  Post-legalization rewriting
   0.000    0.000  Pre-legalization rewriting
   0.001    0.001  Dead code elimination
   0.009    0.009  Legalization
   0.002    0.002  Global value numbering
   0.402    0.000  Loop invariant code motion
   0.000    0.000  Remove unreachable blocks
   5.229    0.018  Register allocation
   0.002    0.002  RA liveness analysis
   0.001    0.001  RA coalescing CSSA
   0.006    0.006  RA spilling
   0.005    0.005  RA reloading
   0.007    0.007  RA coloring
   0.001    0.001  Prologue/epilogue insertion
   0.005    0.005  Instruction encoding shrinking
   0.990    0.588  Branch relaxation
   0.000    0.000  Binary machine code emission
   0.000    0.000  Layout full renumbering
   0.000    0.000  Emit output

or in json ( ../target/debug/lucetc tests/wasm/arith.wat --report-times --error-style json):

{"errors":null,"timing":{"pass_times":["   0.000    0.000  Translate WASM module","   0.000    0.000  Translate WASM function","   0.004    0.003  Verify Cranelift IR","   0.000    0.000  Verify CSSA","   0.000    0.000  Verify live ranges","   0.000    0.000  Verify value locations","   0.000    0.000  Verify CPU flags","   0.006    0.000  Compilation passes","   0.000    0.000  Control flow graph","   0.000    0.000  Dominator tree","   0.000    0.000  Loop analysis","   0.000    0.000  Post-legalization rewriting","   0.000    0.000  Pre-legalization rewriting","   0.000    0.000  Dead code elimination","   0.000    0.000  Legalization","   0.000    0.000  Global value numbering","   0.000    0.000  Loop invariant code motion","   0.000    0.000  Remove unreachable blocks","   0.002    0.000  Register allocation","   0.000
 0.000  RA liveness analysis","   0.000    0.000  RA coalescing CSSA","   0.000    0.000  RA spilling","   0.000    0.000  RA reloading","   0.000    0.000  RA coloring","   0.000    0.000  Prologue/epilogue insertion","   0.000    0.000  Instruction encoding shrinking","   0.000    0.000  Branch relaxation","   0.000    0.000  Binary machine code emission","   0.000    0.000  Emit output"]}}

lucetc/src/compiler.rs Outdated Show resolved Hide resolved
let cranelift_time_text = cranelift_codegen::timing::take_current().to_string();
// skip the header text from Cranelift's `Display`, then take until we hit the end (also
// "======= ======= ==...")
for pass in cranelift_time_text
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is some real nastyness but I don't see a way to record duration/times without stringifying and splitting. I'll follow up in cranelift and see about exposing this in a more friendly form.

ErrorStyle::Json => {
let errs: Option<Vec<SerializedLucetcError>> =
compile_result.err().map(|err| vec![err.into()]);
let result = json!({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change in output format for anyone mechanically processing lucetc output today, but the array of errors was probably a bit too rigid anyway?

@pchickey pchickey closed this Jun 26, 2020
@pchickey
Copy link
Contributor

This PR was closed as a byproduct of deleting the branch named master. If this is still an active PR, re-open as a new PR against main.

@acfoltzer acfoltzer reopened this Jun 26, 2020
@acfoltzer acfoltzer changed the base branch from master to main June 26, 2020 00:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants