For visualization, timeline graphs can be plotted to show where V8 is spending time. This can be used to find bottlenecks and spot things that are unexpected (for example, too much time spent in unoptimized code). Data for the plot are gathered by both sampling and instrumentation. Since the latter distorts the performance, the plot script attempts to undistort the logged timestamps. Requirements
$ make native -j32
Profiling in d8To profile a script in d8, run d8 with the appropriate flags
For example $ out/native/d8 --prof --log-timer-events imaging-darkroom.js The log entries will be written into Profiling in ChromeTo profile a web site in chrome, pass the same flags to V8 using--js-flags and with --no-sandbox to enable writing into v8.log. Additionally --noprof-lazy has to be passed to V8 to force sampling ticks.For example $ ./chrome --no-sandbox --js-flags="--prof --noprof-lazy --log-timer-events" mail.google.com & sleep 10; kill $! Given that Gmail is already logged into, this profiles the first 10 seconds after starting Chrome and loading Gmail, before Chrome is killed. PlottingMake sure you have thev8.log file created during profiling. From V8's source directory, run$ tools/plot-timer-events [location of v8.log] A Some optional environment variables are available:
Colors and layout details are constants in Interpretation of the plot. A case study.Let's profile Octane's pdfjs benchmark. Due to the nature of the benchmark, having many accesses to typed arrays, we expect a considerable amount of time being spent in external callbacks (which implement typed arrays). Figure 1: Using only Figure 2: Adding the option Figure 3: Using Figure 4: Having the distortion parameter automatically calibrated (plot range is manually set for easier comparison), we can see that due to the instrumentation overhead, the benchmark run with instrumentation only executed a fraction of what would have been without instrumentation. The background to this is that Octane benchmarks are repeated until a minimum length of run time has been reached. The un-instrumented run manages to complete more iterations of the benchmark than the instrumented run, in the same length of run time. Now that the plot has been undistorted, it almost completely agrees with previous plots in figures 1 and 2. Figure 5: Zooming into the interesting part of the undistorted plot. Other resources |





