mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Improve efficiency of incremental manifest build.
Move the file.copy check before the manifest lookup to save a lookup and (probably) find for zero-length files when bundling. This also removes a layer of indentation which helps with readability.
This commit is contained in:
parent
48823b6cd3
commit
cf478bc753
@ -1686,35 +1686,32 @@ manifestBuildIncr(
|
||||
{
|
||||
ManifestFile file = manifestFile(this, fileIdx);
|
||||
|
||||
// Check if a prior file exists
|
||||
if (manifestFileExists(manifestPrior, file.name))
|
||||
// Check if a prior file exists for files that will be copied (i.e. not zero-length files when bundling). If a prior
|
||||
// file does exist it may be possible to reference it instead of copying the file.
|
||||
if (file.copy && manifestFileExists(manifestPrior, file.name))
|
||||
{
|
||||
const ManifestFile filePrior = manifestFileFind(manifestPrior, file.name);
|
||||
|
||||
// If the file will be copied then preserve values from the prior file when needed. Some files may have been
|
||||
// designated not to be copied at manifest build time, e.g. zero-length files when bundling.
|
||||
if (file.copy)
|
||||
{
|
||||
// If file size is equal to prior size then the file can be referenced instead of copied if it has not changed
|
||||
// (this must be determined during the backup).
|
||||
// If file size is equal to prior size then the file can be referenced instead of copied if it has not changed (this
|
||||
// must be determined during the backup).
|
||||
const bool fileSizeEqual = file.size == filePrior.size;
|
||||
|
||||
// If prior file was stored with block incremental and file size is at least prior file block size then preserve
|
||||
// prior values. If file size is less than prior file block size then the entire file will need to be stored and
|
||||
// the map will be useless as long as the file stays at this size. It is not possible to change the block size
|
||||
// in a backup set and the map info will be required to compare against the prior block incremental.
|
||||
// prior values. If file size is less than prior file block size then the entire file will need to be stored and the
|
||||
// map will be useless as long as the file stays at this size. It is not possible to change the block size in a
|
||||
// backup set and the map info will be required to compare against the prior block incremental.
|
||||
const bool fileBlockIncrPreserve = filePrior.blockIncrMapSize > 0 && file.size >= filePrior.blockIncrSize;
|
||||
|
||||
// Perform delta if enabled and file size is equal to prior but not zero. Files of unequal length are always
|
||||
// different while zero-length files are always the same, so it wastes time to check them. It is possible for
|
||||
// a file to be truncated down to equal the prior file during backup, but the overhead of checking for such an
|
||||
// unlikely event does not seem worth the possible space saved.
|
||||
// different while zero-length files are always the same, so it wastes time to check them. It is possible for a file
|
||||
// to be truncated down to equal the prior file during backup, but the overhead of checking for such an unlikely
|
||||
// event does not seem worth the possible space saved.
|
||||
file.delta = delta && fileSizeEqual && file.size != 0;
|
||||
|
||||
// Do not copy if size and prior size are both zero. Zero-length files are always equal so the file can simply
|
||||
// be referenced to the prior file. Note that this is only for the case where zero-length files are being
|
||||
// explicitly written to the repo. Bundled zero-length files disable copy at manifest build time and never
|
||||
// reference the prior file, even if it is also zero-length.
|
||||
// Do not copy if size and prior size are both zero. Zero-length files are always equal so the file can simply be
|
||||
// referenced to the prior file. Note that this is only for the case where zero-length files are being explicitly
|
||||
// written to the repo. Bundled zero-length files disable copy at manifest build time and never reference the prior
|
||||
// file, even if it is also zero-length.
|
||||
if (file.size == 0 && filePrior.size == 0)
|
||||
file.copy = false;
|
||||
|
||||
@ -1726,9 +1723,9 @@ manifestBuildIncr(
|
||||
ASSERT(file.copy || fileSizeEqual);
|
||||
ASSERT(!file.delta || fileSizeEqual);
|
||||
|
||||
// Preserve values if the file will not be copied, is possibly equal to the prior file, or will be stored with
|
||||
// block incremental and the prior file is also stored with block incremental. If the file will not be copied
|
||||
// then the file size must be equal to the prior file so there is no need to check that condition separately.
|
||||
// Preserve values if the file will not be copied, is possibly equal to the prior file, or will be stored with block
|
||||
// incremental and the prior file is also stored with block incremental. If the file will not be copied then the
|
||||
// file size must be equal to the prior file so there is no need to check that condition separately.
|
||||
if (fileSizeEqual || fileBlockIncrPreserve)
|
||||
{
|
||||
file.sizePrior = filePrior.size;
|
||||
@ -1762,7 +1759,6 @@ manifestBuildIncr(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
|
Loading…
x
Reference in New Issue
Block a user