Objprof for HHVM (Approx. instance counter)
commita7058991d1e53bedd2ba827f886170e3955f5004
authorShai Duvdevani <duv@fb.com>
Wed, 3 Sep 2014 05:27:15 +0000 (2 22:27 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Wed, 3 Sep 2014 07:23:06 +0000 (3 00:23 -0700)
tree062fad9b762ff57f739ad459261958cb20288274
parent87fbb72427f8e9145c92c7e2c9b8ad881568fc9c
Objprof for HHVM (Approx. instance counter)

Summary: A lot of times something happens and suddenly PHP land OOMs with bad requests spiking.
Today we record allocations stats and post them with every requests for triaging.
Once we know an endpoint has gone bad, there's still a lot of unknown as to what have happened (Every endpoint has a very large code base).

Objprof for HHVM is an extension that attempts to get approximation of instance count per class.
The extension will be triggered periodically and also upon memory outliers.
Using a comparison view of baseline vs. bad behavior should expose interesting aspects as to what takes the memory.

It isn't a lot of code. There are 3 phases to do it-
1. Map all the Class* known to HHVM
2. Traverse the slabs and increment for every valid Class*
3. Dump all mapped Class* with at least 1 instance back to PHP

Reviewed By: @markw65

Differential Revision: D1528183
hphp/compiler/parser/parser.cpp
hphp/runtime/base/memory-manager.cpp
hphp/runtime/base/memory-manager.h
hphp/runtime/ext/ext_objprof.cpp [new file with mode: 0644]
hphp/runtime/ext/ext_objprof.h [new file with mode: 0644]
hphp/runtime/ext/ext_objprof.php [new file with mode: 0644]
hphp/runtime/vm/unit.cpp
hphp/runtime/vm/unit.h
hphp/test/slow/objprof/objprof.php [new file with mode: 0644]
hphp/test/slow/objprof/objprof.php.expectf [new file with mode: 0644]
hphp/util/trace.h