Skip to content

Commit

Permalink
Remove FBREMAP experiment
Browse files Browse the repository at this point in the history
Summary:
The flag was removed in https://www.internalfb.com/diff/D28467996 (2c5f68d) but the code was not removed yet.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D33792884

fbshipit-source-id: 0ae5d904ca2ca94437ca63b495d41e47585fde33
  • Loading branch information
javache authored and facebook-github-bot committed Jan 27, 2022
1 parent 67355f6 commit 20b9ed9
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions ReactCommon/cxxreact/JSBigString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,65 +50,6 @@ JSBigFileString::~JSBigFileString() {
close(m_fd);
}

#ifdef WITH_FBREMAP
// Read and advance the pointer.
static uint16_t read16(char *&data) {
uint16_t result;
::memcpy(&result, data, sizeof(result));
data += sizeof(result);
return result;
}

// If the given file has a remapping table header, remap its pages accordingly
// and return the byte offset from the beginning to the unwrapped payload.
static off_t maybeRemap(char *data, size_t size, int fd) {
// A remapped file's size must be a multiple of its page size, so quickly
// filter out files with incorrect size, without touching any pages.
static const size_t kMinPageSize = 4096;
if (size < kMinPageSize || size % kMinPageSize != 0) {
return 0;
}
const auto begin = data;
static const uint8_t kRemapMagic[] = {
0xc6, 0x1f, 0xbc, 0x03, 0xc1, 0x03, 0x19, 0x1f, 0xa1, 0xd0, 0xeb, 0x73};
if (::memcmp(data, kRemapMagic, sizeof(kRemapMagic)) != 0) {
return 0;
}
data += sizeof(kRemapMagic);
const size_t filePS = static_cast<size_t>(1) << read16(data);
if (size & (filePS - 1)) {
return 0;
}
{
// System page size must be at least as granular as the remapping.
// TODO: Consider fallback that reads entire file into memory.
const size_t systemPS = sysconf(_SC_PAGESIZE);
CHECK(filePS >= systemPS)
<< "filePS: " << filePS << "systemPS: " << systemPS;
}
const off_t headerPages = read16(data);
uint16_t numMappings = read16(data);
size_t curFilePage = headerPages;
while (numMappings--) {
auto memPage = read16(data) + headerPages;
auto numPages = read16(data);
if (mmap(
begin + memPage * filePS,
numPages * filePS,
PROT_READ,
MAP_FILE | MAP_PRIVATE | MAP_FIXED,
fd,
curFilePage * filePS) == MAP_FAILED) {
CHECK(false) << " memPage: " << memPage << " numPages: " << numPages
<< " curFilePage: " << curFilePage << " size: " << size
<< " error: " << std::strerror(errno);
}
curFilePage += numPages;
}
return headerPages * filePS;
}
#endif // WITH_FBREMAP

const char *JSBigFileString::c_str() const {
if (m_size == 0) {
return "";
Expand All @@ -119,12 +60,6 @@ const char *JSBigFileString::c_str() const {
CHECK(m_data != MAP_FAILED)
<< " fd: " << m_fd << " size: " << m_size << " offset: " << m_mapOff
<< " error: " << std::strerror(errno);
#ifdef WITH_FBREMAP
// Remapping is only attempted when the entire file was requested.
if (m_mapOff == 0 && m_pageOff == 0) {
m_pageOff = maybeRemap(const_cast<char *>(m_data), m_size, m_fd);
}
#endif // WITH_FBREMAP
}
static const size_t kMinPageSize = 4096;
CHECK(!(reinterpret_cast<uintptr_t>(m_data) & (kMinPageSize - 1)))
Expand Down

0 comments on commit 20b9ed9

Please sign in to comment.