Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
T
Tidal
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • PLN
  • Tidal
  • Repository

Switch branch/tag
  • Tidal
  • armada
  • api
  • tests
  • test_cache.py
Find file
BlameHistoryPermalink
  • PLN (Algolia)'s avatar
    feat(douanier): content-addressed cache — the margin lever (#26) · 394bec04
    Identical audio is analyzed ONCE and served forever. This is the economic core
    that makes cheap-analysis-at-scale viable, and it makes the live emotion
    endpoint feel instant on repeats.
    
    WHY: per the design, repeat calls must cost ~nothing — that's the margin story
    vs cloud egress. A re-analyzed track shouldn't pay the CLAP compute twice.
    
    WHAT:
    - cache.py — content_id = sha256 of DECODED PCM (+ samplerate) so re-encodes /
      re-uploads of the same sound dedupe; raw-bytes fallback for formats we can't
      decode here. params_hash folds engine settings (model, bars…) so different
      params cache separately. get/put (JSON inline or a result_ref path for big
      artifacts), yt-id/url → content_id aliases (#29 will use them), and an
      LRU/size-cap gc() that unlinks evicted artifact files (cache is transient on
      the freebox — rebuildable).
    - db.py — cache + aliases tables (WAL already on), LRU index on (kind, last_access).
    - app.py — /v1/analyze/emotion now content-addresses the upload, serves cached
      reads with X-Douanier-Cache: hit, computes+stores on miss. Engine call still
      behind engines.ears (unchanged contract).
    - douanier.py — cache stats / gc admin commands.
    
    VALIDATION:
    - 22/22 tests green (+7 cache: stable/decode-invariant content id, raw fallback,
      miss→put→hit, params separate entries, hit counter, alias resolve, LRU gc
      spares the recently-touched entry).
    - Real-CLAP end-to-end: same clip twice → call 1 miss 10.6s, call 2 hit 0.002s
      = 5663x speedup, identical V/A. The headline product benefit, measured.
    PLN (Algolia) authored Jun 25, 2026
    394bec04
test_cache.py 2.52 KB
EditWeb IDE
×

Replace test_cache.py

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.