perf: replace SHA-256 with BLAKE3 in WebDAV/WOPI, fix JOIN index usage, add LIMIT to favorites, remove dead lru crate, trim tokio features
- WebDAV PUT and WOPI PutFile: replace sha2::Sha256 with blake3::Hasher (~5x faster hashing, compatible with dedup service) - Fix TEXT↔UUID JOIN anti-pattern in favorites and recent_items repos (enables PK index usage) - Add LIMIT 500 to get_favorites query to prevent unbounded memory allocation - Remove unused lru crate from Cargo.toml (superseded by moka) - Replace tokio features=["full"] with explicit feature list (removes signal, process, test-util)
This commit is contained in:
@@ -39,11 +39,12 @@ impl FavoritesRepositoryPort for FavoritesPgRepository {
|
||||
COALESCE(f.updated_at, fld.updated_at) AS "modified_at"
|
||||
FROM auth.user_favorites uf
|
||||
LEFT JOIN storage.files f ON uf.item_type = 'file'
|
||||
AND uf.item_id = f.id::TEXT
|
||||
AND f.id = uf.item_id::UUID
|
||||
LEFT JOIN storage.folders fld ON uf.item_type = 'folder'
|
||||
AND uf.item_id = fld.id::TEXT
|
||||
AND fld.id = uf.item_id::UUID
|
||||
WHERE uf.user_id = $1::TEXT
|
||||
ORDER BY uf.created_at DESC
|
||||
LIMIT 500
|
||||
"#,
|
||||
)
|
||||
.bind(user_uuid)
|
||||
|
||||
@@ -38,9 +38,9 @@ impl RecentItemsRepositoryPort for RecentItemsPgRepository {
|
||||
COALESCE(f.folder_id::TEXT, fld.parent_id::TEXT) AS "parent_id"
|
||||
FROM auth.user_recent_files ur
|
||||
LEFT JOIN storage.files f ON ur.item_type = 'file'
|
||||
AND ur.item_id = f.id::TEXT
|
||||
AND f.id = ur.item_id::UUID
|
||||
LEFT JOIN storage.folders fld ON ur.item_type = 'folder'
|
||||
AND ur.item_id = fld.id::TEXT
|
||||
AND fld.id = ur.item_id::UUID
|
||||
WHERE ur.user_id = $1::TEXT
|
||||
ORDER BY ur.accessed_at DESC
|
||||
LIMIT $2
|
||||
|
||||
@@ -268,7 +268,7 @@ impl DedupService {
|
||||
/// never held during disk I/O.
|
||||
///
|
||||
/// If `pre_computed_hash` is `Some`, the file will NOT be re-read for
|
||||
/// SHA-256 — saving one full sequential read (the biggest I/O win).
|
||||
/// BLAKE3 — saving one full sequential read (the biggest I/O win).
|
||||
pub async fn store_from_file(
|
||||
&self,
|
||||
source_path: &Path,
|
||||
@@ -615,7 +615,7 @@ impl DedupService {
|
||||
/// of `VERIFY_CONCURRENCY` using `buffer_unordered`.
|
||||
pub async fn verify_integrity(&self) -> Result<Vec<String>, DomainError> {
|
||||
/// Max blobs verified concurrently. Each spawns a blocking
|
||||
/// thread for SHA-256 so this also caps blocking-pool pressure.
|
||||
/// thread for BLAKE3 so this also caps blocking-pool pressure.
|
||||
const VERIFY_CONCURRENCY: usize = 16;
|
||||
|
||||
let mut row_stream = sqlx::query_as::<_, (String, i64)>(
|
||||
|
||||
Reference in New Issue
Block a user