Skip to content

Commit

Permalink
Reduce default JIT structure sizes
Browse files Browse the repository at this point in the history
Right now HHVM allocates about 1.2 GB of memory by default.
Reduce this by a factor of ~10 for a better experience with small
applications, VMs with limited memory, evaluation and testing purposes,
etc.

The configuration settings are available to change this to the previous
behavior is reproduced here for ease of access:

Eval {
  JitAHotSize = 4194304
  JitASize = 536870912
  JitAProfSize = 536870912
  JitAStubsSize = 536870912
  JitGlobalDataSize = 134217728
}

Reviewed By: @markw65

Differential Revision: D1034305
  • Loading branch information
scannell authored and sgolemon committed Nov 5, 2013
1 parent 0cd1401 commit 5d60ea9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions hphp/runtime/base/runtime-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ std::set<string, stdltistr> RuntimeOption::DynamicInvokeFunctions;
bool RuntimeOption::RecordCodeCoverage = false;
std::string RuntimeOption::CodeCoverageOutputFile;
size_t RuntimeOption::VMTranslAHotSize = 4 << 20;
size_t RuntimeOption::VMTranslASize = 508 << 20;
size_t RuntimeOption::VMTranslAProfSize = 512 << 20;
size_t RuntimeOption::VMTranslAStubsSize = 512 << 20;
size_t RuntimeOption::VMTranslASize = 60 << 20;
size_t RuntimeOption::VMTranslAProfSize = 64 << 20;
size_t RuntimeOption::VMTranslAStubsSize = 64 << 20;
size_t RuntimeOption::VMTranslGDataSize = RuntimeOption::VMTranslASize >> 2;

std::string RuntimeOption::RepoLocalMode;
Expand Down
21 changes: 16 additions & 5 deletions hphp/util/data-block.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ namespace sz {
typedef uint8_t* Address;
typedef uint8_t* CodeAddress;

#define BLOCK_EMISSION_ASSERT(canEmitCheck) \
always_assert_log(canEmitCheck, \
[] { return \
"Data block emission failed. This almost certainly means the TC is " \
"full. If this is the case, increasing Eval.JitASize, " \
"Eval.JitAStubsSize and Eval.JitGlobalDataSize in the configuration " \
"file when running this script or application should fix this " \
"problem."; \
} \
)

/**
* DataBlock is a simple bump-allocating wrapper around a chunk of memory.
*/
Expand Down Expand Up @@ -118,28 +129,28 @@ struct DataBlock {
}

void byte(const uint8_t byte) {
always_assert(canEmit(sz::byte));
BLOCK_EMISSION_ASSERT(canEmit(sz::byte));
*m_frontier = byte;
m_frontier += sz::byte;
}
void word(const uint16_t word) {
always_assert(canEmit(sz::word));
BLOCK_EMISSION_ASSERT(canEmit(sz::word));
*(uint16_t*)m_frontier = word;
m_frontier += sz::word;
}
void dword(const uint32_t dword) {
always_assert(canEmit(sz::dword));
BLOCK_EMISSION_ASSERT(canEmit(sz::dword));
*(uint32_t*)m_frontier = dword;
m_frontier += sz::dword;
}
void qword(const uint64_t qword) {
always_assert(canEmit(sz::qword));
BLOCK_EMISSION_ASSERT(canEmit(sz::qword));
*(uint64_t*)m_frontier = qword;
m_frontier += sz::qword;
}

void bytes(size_t n, const uint8_t *bs) {
always_assert(canEmit(n));
BLOCK_EMISSION_ASSERT(canEmit(n));
if (n <= 8) {
// If it is a modest number of bytes, try executing in one machine
// store. This allows control-flow edges, including nop, to be
Expand Down

0 comments on commit 5d60ea9

Please sign in to comment.