Skip to content

Reuse precomputed source analysis and cache FFmpeg availability to speed up optimization#8

Open
MLyte wants to merge 1 commit intomainfrom
codex/audit-et-optimiser-la-vitesse-des-tests-de-mastering
Open

Reuse precomputed source analysis and cache FFmpeg availability to speed up optimization#8
MLyte wants to merge 1 commit intomainfrom
codex/audit-et-optimiser-la-vitesse-des-tests-de-mastering

Conversation

@MLyte
Copy link
Copy Markdown
Owner

@MLyte MLyte commented Apr 22, 2026

Motivation

  • The UI flow commonly runs analyze then optimize, but optimize() always re-ran full source analysis, causing redundant work and slower time-to-results.
  • Checking FFmpeg availability was repeated on each analysis call, adding an avoidable fixed startup cost.

Description

  • Added an _ffmpeg_checked flag and _ensure_ffmpeg_available() in EngineService to run assert_ffmpeg_available() only once per service instance.
  • Extended EngineService.optimize() with an optional source_analysis parameter and logic to reuse a provided SourceAnalysis when it matches the input file, avoiding a second analysis.
  • Updated the GUI WorkerRequest and EngineWorker to carry source_analysis and wired MainWindow to pass a cached analysis when the selected input file matches the current analysis, and to invalidate the cached analysis when the user changes file.
  • Added tests/test_service.py with unit tests that verify FFmpeg availability is checked once per instance and that optimize() reuses precomputed analysis without re-invoking analyze_source().

Testing

  • Ran pytest -q (default) which initially failed collection due to optimaster import resolution in this environment.
  • Ran PYTHONPATH=src pytest -q which executed the test suite and produced 6 passed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant