Skip to content

Commit 28fcf16

Browse files
committed
pre-touch all pages before zip
1 parent a121297 commit 28fcf16

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/extensions/k12_engine.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,16 @@ class ContractStateEngine : public K12Engine
662662
madvise(_state + startOffset, len, MADV_DONTNEED); // remove only PTE mappings, all our data still safe. next read will trigger minor fault
663663
}
664664

665+
unsigned long long touchAllPages()
666+
{
667+
unsigned long long sum = 0;
668+
for (size_t offset = 0; offset < paddedSize; offset += SYSTEM_PAGE_SIZE)
669+
{
670+
sum += _state[offset];
671+
}
672+
return sum;
673+
}
674+
665675
int getHashAndReprotect(unsigned char* output, size_t outputByteLen)
666676
{
667677
int res = getHash(output, outputByteLen);

src/qubic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6519,6 +6519,7 @@ static bool saveContractStateFiles(CHAR16* directory)
65196519
CONTRACT_FILE_NAME[sizeof(CONTRACT_FILE_NAME) / sizeof(CONTRACT_FILE_NAME[0]) - 7] = (contractIndex % 100) / 10 + L'0';
65206520
CONTRACT_FILE_NAME[sizeof(CONTRACT_FILE_NAME) / sizeof(CONTRACT_FILE_NAME[0]) - 6] = contractIndex % 10 + L'0';
65216521
contractStateLock[contractIndex].acquireRead();
6522+
ContractStateEngine::getEngine(contractIndex)->touchAllPages();
65226523
savedSize = save(CONTRACT_FILE_NAME, contractDescriptions[contractIndex].stateSize, contractStates[contractIndex], directory, isLoadedFromSnapshot);
65236524
contractStateLock[contractIndex].releaseRead();
65246525
totalSize += savedSize;

0 commit comments

Comments
 (0)