[pbs-devel] [PATCH-SERIES v6 pxar proxmox-backup proxmox-widget-toolkit 0/29] fix #3174: improve file-level backup
Christian Ebner
c.ebner at proxmox.com
Thu Jan 25 14:25:39 CET 2024
Changes to the patch series since version 5 are based on the feedback
obtained via internal communication channels. Many thanks to Thomas,
Fabian, Wolfgang and Dominik for their continuous feedback.
This series of patches implements an metadata based file change
detection mechanism for improved pxar file level backup creation speed
for unchanged files.
The chosen approach is to skip encoding of regular file payloads,
for which metadata (currently ctime and size) did not change as
compared to a previous backup run. Instead of re-encoding the files, a
reference to a newly introduced appendix section of the pxar archive
will be written. The appendix section will be created as concatenation
of indexed chunks from the previous backup run, thereby containing the
sequential file payload at a calculated offset with respect to the
starting point of the appendix section.
Metadata comparison and calculation of the chunks to be indexed for the
appendix section is performed using the catalog of a previous backup as
reference. In order to be able to calculate the offsets, an updated
catalog file format version 2 is introduced which extends the previous
version by including the file offset with respect to the pxar archive
byte stream, as well as the files ctime. This allows to find the required
chunks indexes and the start padding within the concatenated chunks.
The catalog reader remains backwards compatible to the catalog file
format version 1.
During encoding, the chunks needed for the appendix section are injected
in the backup upload stream after forcing a chunk boundary when regular
pxar encoding is finished. Finally, the pxar archive containing an
appendix section are marked as such by appending a final pxar goodbye
lookup table only containing the offset to the appendix section start and
total size of that section, needed for random access as e.g. to mount
the archive via the fuse filesystem implementation.
The following lists the most notable changes included in this series since
the version 5:
- the archiver now implements lookahead caching in order to decide if to
reuse or reencode an entry, replacing the previously used heuristic.
This allows to reduce chunk fragmentation while being more predictable
and stable than the previous approach
- the pxar format version is now encoded as prefix entry to pxar archives
with version 2 in order for encoder/decoder implementations to early detect
the correct format.
- the encoder now stores an internal stack of encoder states, instead of
creating new EncoderImpl instances for each directory level. This was a
neccessary change in order to handle the entry caching for the lookahead
cache.
- Appendix chunks now have a dedicated type `AppendableDynamicEntry` to
clearly distingush them from regular chunks.
The following lists the most notable changes included in this series since
the version 4:
- fix an issue with premature injection queue chunk insertion on initialization
- fix an issue with the decoder state not being correctly set at the start of
the appendix section, leading to decoding errors in special cases.
- avoid double injection of chunks in cases where the chunk list to insert
starts with the first chunk of the list already being present, but not the
subsequent ones
- refactoring and renaming of the Encoder's `bytes_len` to `encoded_size`
The following lists the most notable changes included in this series since
the version 3:
- count appendix chunks as reused chunks, as they are not re-encoded and
re-uploaded.
- add a heuristic to reduce chunk fragmentation for appendix chunks for
multiple consecutive backup runs with metadata based file change detection.
- refactor the appendix list generation during pxar encoding in the archiver.
- switch from Vec to BTreeMap for the restoring the appendix entries so
entries are inserted in sorted order based on their offset, making it
unnecessary to sort afterwards.
- fix issue with chunk injection code which lead to data corruption in some
edge cases, add additional checks as fortification.
The following lists the most notable changes included in this series since
the version 2:
- avoid re-indexing the same chunks multiple times in the appendix
section by looking them up in the already present appendix chunks list
and calculate the appendix reference offset accordingly. This now
requires to sort entries by their appendix start offset for sequential
restore.
- reduce appendix reference chunk fragmentation by increasing the file
size threshold to 1k.
- Fix the WebUIs file browser and single file restore, broken in the
previous patch series.
- fixes previous catalog and/or dynamic index downloads when either the
backup group was empty or no archive with the same name present in the
backup
The following lists the most notable changes included in this series since
the version 1:
- fixes and refactors the missing chunk issue by modifying the logic to
avoid re-appending the same chunks multiple times if referenced by
multiple consecutive files.
- fixes a performance issue with catalog lookup being the bottleneck
for cases with directories with many entries, resulting in the
metadata based file change detection performing worse than the regular
mode.
- fixes the creation of multi archive backups. All of the archives use
the same reference catalog.
- the catalog file format is pushed to version 2, including the needed
archive offsets as well as ctime for file change detection.
- the catalog is fully backward compatible to catalog file format
version 1, so both can be decoded by the reader. However, the new
version of the catalog file format will be used for all new backups
- it is now possible to perform multiple consecutive runs of the backup
with metadata based file change detection, no more need to perform the
regular run previous to the other one.
- change from `incremental` flag to enum based `BackupDetectionMode`
parameter for command invocations.
- includes a new `proxmox-backup-test-suite` binary to create and run
benchmarks to compare the performance of the different detection modes.
An invocation of a backup run with this patches now is:
```bash
proxmox-backup-client backup <label>.pxar:<source-path> --change-detection-mode=metadata
```
During the first run, no reference catalog can be used, the backup will
be a regular run. Following backups will however utilize the catalog and
index files of the previous run to perform file change detection.
As benchmarks, the linux source code as well as the coco dataset for
computer vision and pattern recognition can be used.
The benchmarks can be performed by running:
```bash
proxmox-backup-test-suite detection-mode-bench prepare --target /<path-to-bench-source-target>
proxmox-backup-test-suite detection-mode-bench run linux.pxar:/<path-to-bench-source-target>/linux
proxmox-backup-test-suite detection-mode-bench run coco.pxar:/<path-to-bench-source-target>/coco
```
Above command invocations assume the default repository and credentials
to be set as environment variables, they might however be passed as
additinal optional parameters instead.
Benchmark runs using these test data show a significant improvement in
the time needed for the backups:
For the linux source code backup:
Completed benchmark with 5 runs for each tested mode.
Completed regular backup with:
Total runtime: 49.20 s
Average: 9.84 ± 0.07 s
Min: 9.74 s
Max: 9.92 s
Completed metadata detection mode backup with:
Total runtime: 12.20 s
Average: 2.44 ± 0.06 s
Min: 2.34 s
Max: 2.48 s
Differences (metadata based - regular):
Delta total runtime: -37.00 s (-75.20 %)
Delta average: -7.40 ± 0.09 s (-75.20 %)
Delta min: -7.40 s (-75.98 %)
Delta max: -7.43 s (-74.97 %)
For the coco dataset backup:
Completed benchmark with 5 runs for each tested mode.
Completed regular backup with:
Total runtime: 513.10 s
Average: 102.62 ± 0.46 s
Min: 102.15 s
Max: 103.23 s
Completed metadata detection mode backup with:
Total runtime: 114.32 s
Average: 22.86 ± 0.58 s
Min: 22.40 s
Max: 23.86 s
Differences (metadata based - regular):
Delta total runtime: -398.78 s (-77.72 %)
Delta average: -79.76 ± 0.74 s (-77.72 %)
Delta min: -79.76 s (-78.07 %)
Delta max: -79.37 s (-76.89 %)
Above tests were performed inside a test VM backing up to a local
datastore.
pxar:
Christian Ebner (9):
fix #3174: decoder: factor out skip_bytes from skip_entry
fix #3174: decoder: impl skip_bytes for sync dec
fix #3174: encoder: calc filename + metadata byte size
fix #3174: enc/dec: impl PXAR_APPENDIX_REF entrytype
fix #3174: enc/dec: impl PXAR_APPENDIX entrytype
fix #3174: encoder: helper to add to encoder position
fix #3174: enc/dec: impl PXAR_APPENDIX_TAIL entrytype
fix #3174: add pxar format version entry
fix #3174: enc: move from instance per dir to state stack
examples/mk-format-hashes.rs | 16 ++
examples/pxarcmd.rs | 8 +-
src/accessor/mod.rs | 142 ++++++++++--
src/decoder/mod.rs | 83 ++++++-
src/decoder/sync.rs | 5 +
src/encoder/aio.rs | 77 +++++--
src/encoder/mod.rs | 435 +++++++++++++++++++++++++++--------
src/encoder/sync.rs | 60 ++++-
src/format/mod.rs | 29 ++-
src/lib.rs | 13 ++
10 files changed, 706 insertions(+), 162 deletions(-)
proxmox-backup:
Christian Ebner (19):
fix #3174: index: add fn index list from start/end-offsets
fix #3174: api: double catalog upload size
fix #3174: catalog: introduce extended format v2
fix #3174: archiver/extractor: impl appendix ref
fix #3174: catalog: add specialized Archive entry
fix #3174: extractor: impl seq restore from appendix
fix #3174: archiver: store ref to previous backup
fix #3174: upload stream: impl reused chunk injector
fix #3174: chunker: add forced boundaries
fix #3174: backup writer: inject queued chunk in upload steam
fix #3174: archiver: reuse files with unchanged metadata
fix #3174: specs: add backup detection mode specification
fix #3174: client: Add detection mode to backup creation
catalog: use format version 2 conditionally
tools: add optional path prefix to line based output
pxar-bin: implement listing for appendix entries
test-suite: add detection mode change benchmark
test-suite: Add bin to deb, add shell completions
pxar: add lookahead caching to reduce chunk fragmentation
Cargo.toml | 1 +
Makefile | 13 +-
debian/proxmox-backup-client.bash-completion | 1 +
debian/proxmox-backup-client.install | 2 +
debian/proxmox-backup-test-suite.bc | 8 +
examples/test_chunk_speed2.rs | 9 +-
pbs-client/src/backup_specification.rs | 33 +
pbs-client/src/backup_writer.rs | 89 ++-
pbs-client/src/catalog_shell.rs | 4 +-
pbs-client/src/chunk_stream.rs | 42 +-
pbs-client/src/inject_reused_chunks.rs | 152 ++++
pbs-client/src/lib.rs | 1 +
pbs-client/src/pxar/create.rs | 707 ++++++++++++++++--
pbs-client/src/pxar/extract.rs | 150 +++-
pbs-client/src/pxar/lookahead_cache.rs | 41 +
pbs-client/src/pxar/mod.rs | 3 +-
pbs-client/src/pxar/tools.rs | 24 +-
pbs-client/src/pxar_backup_stream.rs | 8 +-
pbs-datastore/src/catalog.rs | 621 +++++++++++++--
pbs-datastore/src/dynamic_index.rs | 55 ++
pbs-datastore/src/file_formats.rs | 3 +
proxmox-backup-client/src/main.rs | 192 ++++-
proxmox-backup-test-suite/Cargo.toml | 18 +
.../src/detection_mode_bench.rs | 291 +++++++
proxmox-backup-test-suite/src/main.rs | 17 +
.../src/proxmox_restore_daemon/api.rs | 21 +-
pxar-bin/src/main.rs | 78 +-
src/api2/backup/upload_chunk.rs | 4 +-
src/tape/file_formats/snapshot_archive.rs | 9 +-
tests/catar.rs | 3 +
zsh-completions/_proxmox-backup-test-suite | 13 +
31 files changed, 2395 insertions(+), 218 deletions(-)
create mode 100644 debian/proxmox-backup-test-suite.bc
create mode 100644 pbs-client/src/inject_reused_chunks.rs
create mode 100644 pbs-client/src/pxar/lookahead_cache.rs
create mode 100644 proxmox-backup-test-suite/Cargo.toml
create mode 100644 proxmox-backup-test-suite/src/detection_mode_bench.rs
create mode 100644 proxmox-backup-test-suite/src/main.rs
create mode 100644 zsh-completions/_proxmox-backup-test-suite
proxmox-widget-toolkit:
Christian Ebner (1):
file-browser: support pxar archive and fileref types
src/Schema.js | 2 ++
src/window/FileBrowser.js | 16 ++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
--
2.39.2
More information about the pbs-devel
mailing list