feat(dedup): CDC sub-file deduplication with FastCDC + parallel chunk storage + dedup skip

- Replace whole-file SHA-256 dedup with FastCDC 2020 content-defined chunking
  (min 64KB, avg 256KB, max 1MB) + BLAKE3 hashing
- Add chunk_manifests table (file_hash → chunk_hashes[] + chunk_sizes[])
- Add put_blob_from_bytes to BlobStorageBackend trait (all 7 backends)
- 3-phase store_chunks pipeline:
  Phase 0: batch-check existing chunks (single PG query)
  Phase 1: selective disk read (skip existing chunks entirely)
  Phase 2: parallel upload with buffer_unordered(8)
- CDC-aware read_blob_stream and read_blob_range_stream with legacy fallback
- Transactional manifest + chunk ref-count cascade on remove_reference
- 12 CDC tests (determinism, reassembly, contiguity, sub-file dedup, etc.)
- Update deduplication.md to reflect new architecture
This commit is contained in:
Diocrafts
2026-04-14 23:17:39 +02:00
parent cd3733b459
commit 761d159a92
15 changed files with 1988 additions and 530 deletions
+28 -26
View File
@@ -7,8 +7,8 @@ default-run = "oxicloud"
[dependencies]
mimalloc = { version = "0.1.48", default-features = false }
axum = { version = "0.8.8", features = ["multipart", "http1", "http2", "tokio", "macros"] }
tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "io-util", "net", "time", "sync", "fs"] }
axum = { version = "0.8.9", features = ["multipart", "http1", "http2", "tokio", "macros"] }
tokio = { version = "1.52.0", features = ["rt-multi-thread", "macros", "io-util", "net", "time", "sync", "fs"] }
tokio-util = { version = "0.7.18", features = ["io", "codec", "compat"] }
tokio-stream = { version = "0.1.18", features = ["fs"] }
bytes = "1.11.1"
@@ -25,7 +25,7 @@ serde_json = "1.0.149"
futures = "0.3.32"
async-stream = "0.3.6"
mime_guess = "2.0.5"
uuid = { version = "1.21.0", features = ["v4", "serde"] }
uuid = { version = "1.23.0", features = ["v4", "serde"] }
thiserror = "2.0.18"
mockall = { version = "0.14.0", optional = true }
@@ -35,37 +35,39 @@ argon2 = "0.5.3"
rand_core = { version = "0.6", features = ["std", "getrandom"] }
quick-xml = "0.39.2"
dotenvy = "0.15.7"
moka = { version = "0.12", features = ["future", "sync"] }
moka = { version = "0.12.15", features = ["future", "sync"] }
http-range-header = "0.4"
image = { version = "0.25", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
image = { version = "0.25.10", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
id3 = "1.14"
mp3-duration = "0.1"
kamadak-exif = "0.5"
md-5 = "0.10"
sha2 = "0.10.9"
blake3 = { version = "1.8.3", features = ["rayon", "mmap"] }
kamadak-exif = "0.6.1"
md-5 = "0.11.0"
sha2 = "0.11.0"
blake3 = { version = "1.8.4", features = ["rayon", "mmap"] }
hex = "0.4.3"
http-body-util = "0.1.3"
percent-encoding = "2.3"
percent-encoding = "2.3.2"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-webpki-roots"] }
base64 = "0.22.1"
fs2 = "0.4"
rayon = "1.11"
rayon = "1.12.0"
infer = "0.19"
async-compression = { version = "0.4", features = ["tokio", "gzip"] }
async-compression = { version = "0.4.41", features = ["tokio", "gzip"] }
async_zip = { version = "0.0.18", features = ["tokio", "deflate"] }
dashmap = "6"
socket2 = { version = "0.6.2", features = ["all"] }
dashmap = "6.1.0"
socket2 = { version = "0.6.3", features = ["all"] }
urlencoding = "2.1.3"
utoipa = { version = "5", features = ["axum_extras", "uuid", "chrono"] }
aws-sdk-s3 = "1"
aws-config = { version = "1", features = ["behavior-version-latest"] }
aws-smithy-types = "1"
utoipa = { version = "5.4.0", features = ["axum_extras", "uuid", "chrono"] }
aws-sdk-s3 = "1.129.0"
aws-config = { version = "1.8.15", features = ["behavior-version-latest"] }
aws-smithy-types = "1.4.7"
azure_core = "0.21"
azure_storage = "0.21"
azure_storage_blobs = "0.21"
aes-gcm = "0.10"
lru = "0.12"
aes-gcm = "0.10.3"
lru = "0.16.4"
fastcdc = "4.0.0"
memmap2 = "0.9.10"
[features]
default = []
@@ -80,12 +82,12 @@ name = "generate-openapi"
path = "src/bin/generate-openapi.rs"
[build-dependencies]
oxc_allocator = "0.116"
oxc_parser = "0.116"
oxc_span = "0.116"
oxc_codegen = "0.116"
oxc_minifier = "0.116"
lightningcss = "1.0.0-alpha.70"
oxc_allocator = "0.125.0"
oxc_parser = "0.125.0"
oxc_span = "0.125.0"
oxc_codegen = "0.125.0"
oxc_minifier = "0.125.0"
lightningcss = "1.0.0-alpha.71"
[profile.release]
lto = "fat"