Skip to content
Permalink
Browse files

log the trigger of retranslateAll

Reviewed By: ottoni

Differential Revision: D13686238

fbshipit-source-id: 48aea7c163f2a00dda7444a5ff6362aacdd00337
  • Loading branch information...
binliu19 authored and hhvm-bot committed Jan 17, 2019
1 parent 3be29ab commit 7013c2ccf97bc708098a156e10be857bf1c3cfa7
Showing with 28 additions and 32 deletions.
  1. +27 −14 hphp/runtime/vm/jit/mcgen-translate.cpp
  2. +0 −9 hphp/runtime/vm/jit/prof-data.cpp
  3. +1 −9 hphp/runtime/vm/jit/prof-data.h
@@ -42,7 +42,7 @@

#include "hphp/runtime/base/program-functions.h"
#include "hphp/runtime/base/vm-worker.h"

#include "hphp/runtime/ext/server/ext_server.h"
#include "hphp/runtime/server/http-server.h"

#include "hphp/util/boot-stats.h"
@@ -545,6 +545,11 @@ translate(TransArgs args, FPInvOffset spOff,
TCA retranslate(TransArgs args, const RegionContext& ctx) {
VMProtect _;

if (RID().isJittingDisabled()) {
SKTRACE(2, args.sk, "punting because jitting code was disabled\n");
return nullptr;
}

auto sr = tc::findSrcRec(args.sk);
auto const initialNumTrans = sr->numTrans();

@@ -559,8 +564,8 @@ TCA retranslate(TransArgs args, const RegionContext& ctx) {
// answer to profileFunc() changes, so use a lambda rather than just
// storing the result.
auto kind = [&] {
return tc::profileFunc(args.sk.func()) ?
TransKind::Profile : TransKind::Live;
return tc::profileFunc(args.sk.func()) ? TransKind::Profile
: TransKind::Live;
};
args.kind = kind();

@@ -606,11 +611,6 @@ TCA retranslate(TransArgs args, const RegionContext& ctx) {
}
SKTRACE(1, args.sk, "retranslate\n");

if (UNLIKELY(RID().isJittingDisabled())) {
SKTRACE(2, args.sk, "punting because jitting code was disabled\n");
return nullptr;
}

args.kind = kind();
if (!writer.checkKind(args.kind)) return nullptr;

@@ -660,10 +660,25 @@ bool retranslateAllEnabled() {

void checkRetranslateAll(bool force) {
if (s_retranslateAllScheduled.load(std::memory_order_relaxed) ||
!retranslateAllEnabled() ||
!(force || hasEnoughProfDataToRetranslateAll())) {
!retranslateAllEnabled()) {
return;
}
auto const serverMode = RuntimeOption::ServerExecutionMode();
if (!force) {
auto const uptime = static_cast<int>(f_server_uptime()); // may be -1
if (uptime >= (int)RuntimeOption::EvalJitRetranslateAllSeconds) {
assertx(serverMode);
Logger::FInfo("retranslateAll: scheduled after {} seconds", uptime);
} else if (requestCount() >= RuntimeOption::EvalJitRetranslateAllRequest) {
if (serverMode) {
Logger::FInfo("retranslateAll: scheduled after {} requests",
requestCount());
}
} else {
return;
}
}

if (s_retranslateAllScheduled.exchange(true)) {
// Another thread beat us.
return;
@@ -676,7 +691,6 @@ void checkRetranslateAll(bool force) {
// additional locking on the ProfData. We use a fresh thread to avoid
// stalling the treadmill, the thread is joined in the processExit handler
// for mcgen.
Logger::Info("Scheduling the retranslation of all profiled translations");
Treadmill::enqueue([] {
s_retranslateAllThread = std::thread([] {
rds::local::init();
@@ -693,9 +707,8 @@ void checkRetranslateAll(bool force) {
retranslateAll();
});
}
if (!RuntimeOption::ServerExecutionMode()) { // script mode
s_retranslateAllThread.join();
}

if (!serverMode) s_retranslateAllThread.join();
}

bool retranslateAllPending() {
@@ -23,8 +23,6 @@

#include "hphp/util/logger.h"

#include "hphp/runtime/ext/server/ext_server.h"

#include "hphp/runtime/vm/jit/normalized-instruction.h"
#include "hphp/runtime/vm/jit/region-selection.h"
#include "hphp/runtime/vm/jit/translator.h"
@@ -291,11 +289,4 @@ std::vector<ProfData::TargetProfileInfo> ProfData::getTargetProfiles(

////////////////////////////////////////////////////////////////////////////////

bool hasEnoughProfDataToRetranslateAll() {
return requestCount() >= RuntimeOption::EvalJitRetranslateAllRequest ||
f_server_uptime() >= RuntimeOption::EvalJitRetranslateAllSeconds;
}

////////////////////////////////////////////////////////////////////////////////

}}
@@ -691,21 +691,13 @@ struct ProfData {
m_blockEndOffsets;

mutable folly::SharedMutex m_targetProfilesLock;
jit::fast_map<TransID, std::vector<TargetProfileInfo>> m_targetProfiles;
jit::fast_map<TransID, jit::vector<TargetProfileInfo>> m_targetProfiles;

bool m_wasDeserialized{false};
};

//////////////////////////////////////////////////////////////////////

/*
* Returns whether or not we've collected enough profile data to trigger
* retranslateAll.
*/
bool hasEnoughProfDataToRetranslateAll();

//////////////////////////////////////////////////////////////////////

}}

#endif

0 comments on commit 7013c2c

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.