Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run BackgroundTask while searching for matching blocks #122

Merged
merged 2 commits into from
Jan 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions lib/backupstore/BackupStoreFileDiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "BackupStoreFileEncodeStream.h"
#include "BackupStoreFileWire.h"
#include "BackupStoreObjectMagic.h"
#include "BackgroundTask.h"
#include "CommonException.h"
#include "FileStream.h"
#include "MD5Digest.h"
Expand All @@ -51,7 +52,8 @@ static void FindMostUsedSizes(BlocksAvailableEntry *pIndex, int64_t NumBlocks, i
static void SearchForMatchingBlocks(IOStream &rFile,
std::map<int64_t, int64_t> &rFoundBlocks, BlocksAvailableEntry *pIndex,
int64_t NumBlocks, int32_t Sizes[BACKUP_FILE_DIFF_MAX_BLOCK_SIZES],
DiffTimer *pDiffTimer);
DiffTimer *pDiffTimer,
BackgroundTask* pBackgroundTask);
static void SetupHashTable(BlocksAvailableEntry *pIndex, int64_t NumBlocks, int32_t BlockSize, BlocksAvailableEntry **pHashTable);
static bool SecondStageMatch(BlocksAvailableEntry *pFirstInHashList, RollingChecksum &fastSum, uint8_t *pBeginnings, uint8_t *pEndings, int Offset, int32_t BlockSize, int64_t FileBlockNumber,
BlocksAvailableEntry *pIndex, std::map<int64_t, int64_t> &rFoundBlocks);
Expand Down Expand Up @@ -197,7 +199,7 @@ std::auto_ptr<BackupStoreFileEncodeStream> BackupStoreFile::EncodeFileDiff
sizeOfInputFile = file.BytesLeftToRead();
// Find all those lovely matching blocks
SearchForMatchingBlocks(file, foundBlocks, pindex,
blocksInIndex, sizesToScan, pDiffTimer);
blocksInIndex, sizesToScan, pDiffTimer, pBackgroundTask);

// Is it completely different?
completelyDifferent = (foundBlocks.size() == 0);
Expand Down Expand Up @@ -476,7 +478,8 @@ static void FindMostUsedSizes(BlocksAvailableEntry *pIndex, int64_t NumBlocks, i
// --------------------------------------------------------------------------
static void SearchForMatchingBlocks(IOStream &rFile, std::map<int64_t, int64_t> &rFoundBlocks,
BlocksAvailableEntry *pIndex, int64_t NumBlocks,
int32_t Sizes[BACKUP_FILE_DIFF_MAX_BLOCK_SIZES], DiffTimer *pDiffTimer)
int32_t Sizes[BACKUP_FILE_DIFF_MAX_BLOCK_SIZES], DiffTimer *pDiffTimer,
BackgroundTask* pBackgroundTask)
{
Timer maximumDiffingTime(0, "MaximumDiffingTime");

Expand Down Expand Up @@ -577,7 +580,14 @@ static void SearchForMatchingBlocks(IOStream &rFile, std::map<int64_t, int64_t>
abortSearch = true;
break;
}


if(pBackgroundTask)
{
pBackgroundTask->RunBackgroundTask(
BackgroundTask::Searching_Blocks,
fileBlockNumber, 0);
}

if(pDiffTimer)
{
pDiffTimer->DoKeepAlive();
Expand Down Expand Up @@ -726,7 +736,7 @@ static void SearchForMatchingBlocks(IOStream &rFile, std::map<int64_t, int64_t>

if(abortSearch) break;
}

// Free buffers and hash table
::free(pbuffer1);
pbuffer1 = 0;
Expand Down