File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1827,6 +1827,12 @@ The format can be found in hphp/tools/configs/generate_configs.rs
18271827 translations will be logged, and run_key column will be logged with
18281828 the value of this option.
18291829
1830+ - std::string Jit.SerializeDebugLocation = "/tmp/debugprof.jit", paulbiss
1831+
1832+ If jit profiles are disabled write serialized JIT data to disk for use in the
1833+ event of a crash. While crashing HHVM will map this file into memory so that
1834+ it may be retrieved from the core.
1835+
18301836- bool Jit.ProfileGuardTypes = false, UNKNOWN
18311837- uint32_t Jit.FilterLease = 1, UNKNOWN
18321838
Original file line number Diff line number Diff line change @@ -311,6 +311,29 @@ bool serializeProfDataAndLog() {
311311 return serializeOptProfEnabled () && Cfg::Jit::SerializeOptProfRestart;
312312}
313313
314+ void debugDumpProfDataAndLog () {
315+ auto const serverMode = Cfg::Server::Mode;
316+
317+ if (Cfg::Jit::SerializeDebugLocation.empty ()) return ;
318+
319+ if (serverMode) {
320+ Logger::Info (" retranslateAll: serializing profile data for debugging" );
321+ }
322+
323+ std::string errMsg;
324+ VMWorker ([&errMsg] () {
325+ errMsg = serializeProfData (Cfg::Jit::SerializeDebugLocation);
326+ }).run ();
327+
328+ if (serverMode) {
329+ if (errMsg.empty ()) {
330+ Logger::Info (" retranslateAll: serializing done" );
331+ } else {
332+ Logger::FError (" serializeProfData failed with: {}" , errMsg);
333+ }
334+ }
335+ }
336+
314337/*
315338 * Schedule serialization of optimized code's profile to happen in the future.
316339 */
@@ -410,6 +433,10 @@ void retranslateAll(bool skipSerialize) {
410433 // serialization of optimized code's profile is also enabled.
411434
412435 if (serialize && !skipSerialize && serializeProfDataAndLog ()) return ;
436+ if (!skipSerialize && !isJitSerializing () && !isJitDeserializing () &&
437+ Cfg::Repo::Authoritative) {
438+ debugDumpProfDataAndLog ();
439+ }
413440
414441 // 5) Generate machine code for all the profiled functions.
415442
Original file line number Diff line number Diff line change @@ -869,7 +869,9 @@ rds::Ordering::Item read_rds_ordering_item(ProfDataDeserializer& des) {
869869
870870void write_rds_ordering (ProfDataSerializer& ser) {
871871 rds::Ordering order;
872- if (Cfg::Eval::ReorderRDS) order = rds::profiledOrdering ();
872+ if (Cfg::Eval::ReorderRDS && isJitSerializing ()) {
873+ order = rds::profiledOrdering ();
874+ }
873875 write_container (ser, order.persistent , write_rds_ordering_item);
874876 write_container (ser, order.local , write_rds_ordering_item);
875877 write_container (ser, order.normal , write_rds_ordering_item);
@@ -2209,6 +2211,10 @@ std::string serializeProfData(const std::string& filename) {
22092211 s_lastMappers = std::move (ser.getMappers ());
22102212 }
22112213
2214+ // If we crash we can recover the current TC state using the profile we just
2215+ // serialized so ensure it gets mapped back into the core.
2216+ s_deserializedFile = filename;
2217+
22122218 return " " ;
22132219 } catch (std::runtime_error& err) {
22142220 return folly::sformat (" Failed to serialize profile data: {}" , err.what ());
You can’t perform that action at this time.
0 commit comments