재실행 시 영상 재처리로 인한 멈춤 완화 — ffmpeg/ffprobe 저우선순위 + 백업 하루 1회

증상: 영상이 많은 라이브러리에서 첫 로딩이 오래 걸리고, 다 불러온 뒤
재실행하면 멈춤. 원인은 미완료 영상 썸네일 백로그가 시작 시
enqueue_pending으로 재개되는데, ffmpeg/ffprobe가 '자식 프로세스'라
스레드 저우선순위(이전 수정)를 상속받지 못해 NORMAL로 전 코어를 포화시켜
WebView UI가 멈춘 것. (재실행 시 전체 재스캔은 없음 — 자동스캔은 dev 전용,
워처도 시작 시 스캔 안 함. 재처리는 미완료 썸네일 재개일 뿐.)

- ffmpeg::command(): Windows CREATE_NO_WINDOW에 BELOW_NORMAL_PRIORITY_CLASS 추가,
  Unix는 pre_exec로 setpriority(nice+10). 검증: 스캔 중 ffmpeg/ffprobe
  PriorityClass=BelowNormal 관측(ffmpeg 406, ffprobe 46 샘플).
- 시작 유지보수 스레드도 저우선순위로, DB 백업(VACUUM INTO=전체 복제)은
  24시간 내 백업 있으면 건너뜀 — 대용량 라이브러리 재실행 부하/디스크 낭비 감소.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
강 한
2026-07-19 20:05:41 +09:00
co-authored by Claude Fable 5
parent 8ba0c24ce8
commit 2bb1711ffa
2 changed files with 33 additions and 8 deletions
+11 -1
View File
@@ -187,8 +187,18 @@ fn main() {
std::thread::Builder::new()
.name("maintenance".into())
.spawn(move || {
// 유지보수는 백그라운드 — 시작 시 UI를 방해하지 않도록 저우선순위.
archive_indexer::prio::set_current_thread_low();
let backup = data_dir.join("archive.db.bak");
if let Err(e) = archive_indexer::maintenance::backup_db(&db, &backup) {
// 백업(VACUUM INTO = DB 전체 복제)은 하루 한 번만 — 대용량 라이브러리에서
// 매 실행 백업은 시작을 느리게 하고 디스크를 낭비한다.
let backup_fresh = std::fs::metadata(&backup)
.and_then(|m| m.modified())
.map(|t| t.elapsed().map(|e| e.as_secs() < 24 * 3600).unwrap_or(false))
.unwrap_or(false);
if backup_fresh {
tracing::debug!("최근(24h 내) 백업 존재 — 이번 실행은 백업 건너뜀");
} else if let Err(e) = archive_indexer::maintenance::backup_db(&db, &backup) {
tracing::warn!("DB 백업 실패: {e}");
}
let cutoff = now_ms() - 30 * 24 * 3600 * 1000;