Optimize instrToString
commit5e160d7f7ac9d04e94ce668271bead71e5dd3a6e
authorMark Williams <mwilliams@fb.com>
Tue, 22 Aug 2017 22:22:47 +0000 (22 15:22 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 22 Aug 2017 22:40:28 +0000 (22 15:40 -0700)
treec7321f7d95038899b9a0a684d62c3ad54c0cc896
parent8f8e7ce0e3294c02c8fa83ec5fae03eaa459fa2f
Optimize instrToString

Summary:
After D5668519, emitting bytecode-as-text from hhvm --hphp is about
100x faster than before, but still very slow (it was taking a little
longer to emit the text versions of the bytecode than for hhbbc to
optimize the bytecode).

According to perf, at least 30% of the time was being spent in
std::locale::locale() and std::locale::~locale(), mostly called from
instrToString, with lots more in various ostringstream related
activities. So I made it write to strings directly using
folly::format, and got a roughly 3x speedup.

Reviewed By: mxw

Differential Revision: D5670431

fbshipit-source-id: f8a77e9a37870b26318607ff8d179944dd6c95c5
hphp/hhbbc/show.cpp
hphp/runtime/vm/hhbc.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/preclass.cpp