v8/tools/turbolizer
wenqin.yang 3b4b217af2 Reland "[turbolizer] Show basic block id in schedule phase"
This is a reland of commit 347142f647

This CL fix a bug for bolck onclick event, and improve compatibility
for old turbo-x.json files.

Original change's description:
> [turbolizer] Show basic block id in schedule phase
>
> In the schedule phase of turbolizer, there is only RPO number was
> shown, when we want to debug Builtin PGO or other modules, we
> would like to see the block id instead of RPO number.
>
> this CL add the support for displaying basic block id for schedule
> phase in turbolizer.
>
> Change-Id: I7a71f259230564400b683d598f68b6d064f1eb4d
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4068103
> Commit-Queue: Wenqin Yang <wenqin.yang@intel.com>
> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#84625}

Change-Id: Ibaee4826678169d65e809bcad1e29587e480663f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4073861
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Wenqin Yang <wenqin.yang@intel.com>
Cr-Commit-Position: refs/heads/main@{#84645}
2022-12-05 13:39:11 +00:00
..
css [turbolizer] Bytecode sources view 2022-08-16 17:50:05 +00:00
img [turbolizer] Turboshaft custom blocks/nodes data 2022-08-12 07:04:18 +00:00
src Reland "[turbolizer] Show basic block id in schedule phase" 2022-12-05 13:39:11 +00:00
test [turbolizer] Enable even more tslint checks 2019-01-12 15:47:35 +00:00
deploy.sh [turbolizer] Fix CSS file path in deploy script 2022-06-14 01:48:23 +00:00
index.html [tools] Add placeholder comment for analytics code 2022-08-22 12:41:18 +00:00
info-view.html [turbolizer] Source and bytecode positions 2022-08-24 09:23:09 +00:00
OWNERS Update OWNERS files 2022-02-16 08:16:04 +00:00
package-lock.json [turbolizer] Initial TS code refactoring 2022-06-09 18:03:03 +00:00
package.json [turbolizer] Initial TS code refactoring 2022-06-09 18:03:03 +00:00
README.md [turbolizer] Update Readme regarding typescript migration 2020-05-14 10:55:23 +00:00
rollup.config.js [turbolizer] Initial TS code refactoring 2022-06-09 18:03:03 +00:00
tsconfig.json [turbolizer] Bytecode sources view 2022-08-16 17:50:05 +00:00
tsconfig.test.json [turbolizer] Initial HTML&CSS code refactoring 2022-05-30 08:22:26 +00:00
tsfmt.json [turbolizer] Display instruction ranges in turbolizer 2018-06-13 18:06:32 +00:00
tslint.json [turbolizer] Enable even more tslint checks 2019-01-12 15:47:35 +00:00
turbolizer.png [turbolizer] Add support for inlined functions 2018-05-16 13:43:14 +00:00

Turbolizer

Turbolizer is a HTML-based tool that visualizes optimized code along the various phases of Turbofan's optimization pipeline, allowing easy navigation between source code, Turbofan IR graphs, scheduled IR nodes and generated assembly code.

Turbolizer consumes .json files that are generated per-function by d8 by passing the '--trace-turbo' command-line flag.

Turbolizer is build using npm:

cd tools/turbolizer
npm i
npm run-script build

Afterwards, turbolizer can be hosted locally by starting a web server that serve the contents of the turbolizer directory, e.g.:

python -m SimpleHTTPServer 8000

To deploy to a directory that can be hosted the script deploy can be used. The following command will deploy to the directory /www/turbolizer:

npm run deploy -- /www/turbolizer

Optionally, profiling data generated by the perf tools in linux can be merged with the .json files using the turbolizer-perf.py file included. The following command is an example of using the perf script:

perf script -i perf.data.jitted -s turbolizer-perf.py turbo-main.json

The output of the above command is a json object that can be piped to a file which, when uploaded to turbolizer, will display the event counts from perf next to each instruction in the disassembly. Further detail can be found in the bottom of this document under "Using Perf with Turbo."

Using the python interface in perf script requires python-dev to be installed and perf be recompiled with python support enabled. Once recompiled, the variable PERF_EXEC_PATH must be set to the location of the recompiled perf binaries.

Graph visualization and manipulation based on Mike Bostock's sample code for an interactive tool for creating directed graphs. Original source is at https://github.com/metacademy/directed-graph-creator and released under the MIT/X license.

Icons derived from the "White Olive Collection" created by Breezi released under the Creative Commons BY license.

Using Perf with Turbo

In order to generate perf data that matches exactly with the turbofan trace, you must use either a debug build of v8 or a release build with the flag 'disassembler=on'. This flag ensures that the '--trace-turbo' will output the necessary disassembly for linking with the perf profile.

The basic example of generating the required data is as follows:

perf record -k mono /path/to/d8 --trace-turbo --perf-prof main.js
perf inject -j -i perf.data -o perf.data.jitted
perf script -i perf.data.jitted -s turbolizer-perf.py turbo-main.json

These commands combined will run and profile d8, merge the output into a single 'perf.data.jitted' file, then take the event data from that and link them to the disassembly in the 'turbo-main.json'. Note that, as above, the output of the script command must be piped to a file for uploading to turbolizer.

There are many options that can be added to the first command, for example '-e' can be used to specify the counting of specific events (default: cycles), as well as '--cpu' to specify which CPU to sample.

Turbolizer build process

The typescript sources reside in tools/turbolizer/src, and the typescript compiler will put the JavaScript output into tools/turbolizer/build/. The index.html file is set up to load the JavaScript from that directory.