Various V8 optimization guidelines recommend passing --js-flags="--trace-opt --trace-deopt"
and similar flags to Chrome to investigate performance problems with your JavaScript. However people trying this on Windows can’t see any output and are unable to redirect stdout via conventional >
. Here is a small hacky Python script I use to battle this problem:
Run it in a directory containing chrome.exe
and script will patch the executable: flipping Subsystem
field in IMAGE_OPTIONAL_HEADER
from IMAGE_SUBSYSTEM_WINDOWS_GUI
to IMAGE_SUBSYSTEM_WINDOWS_CUI
(and back if you run it again). When you run patched chrome.exe
Windows will attach console to it so that you can see (and redirect) what Chrome writes to stdout/stderr. For example to see a trace of optimized functions, failed optimization attempts and deoptimizations run Chrome like this:
chrome.exe --no-sandbox --js-flags="--trace-opt --trace-bailout --trace-deopt"
[`--no-sandbox` is apparently required to allow renderers to write to a shared console. But don't browse around with this flag :-)]