Skip to content

[playlists] Speed up the project playlist endpoint#1108

Merged
frankrousseau merged 2 commits into
cgwire:mainfrom
frankrousseau:playlist-payload-perf
Jun 14, 2026
Merged

[playlists] Speed up the project playlist endpoint#1108
frankrousseau merged 2 commits into
cgwire:mainfrom
frankrousseau:playlist-payload-perf

Conversation

@frankrousseau

Copy link
Copy Markdown
Contributor

Problems

  • Opening a large playlist was slow (~1.8s server time for a 400-shot playlist): the revisions query hydrated full PreviewFile ORM rows with the heavy annotations/data JSONB for every revision, then re-serialized the whole payload.

Solutions

  • Build the payload from scalar columns (Row tuples) instead of thousands of PreviewFile ORM objects, skipping the annotations/data JSONB unless asked.
  • Omit annotation blobs from the web playlist payload (loaded on demand); the shared guest player keeps them inline.
  • Drop the redundant final serialize pass; the dict is already JSON-safe.

frankrousseau and others added 2 commits June 14, 2026 10:21
Annotation JSONB blobs are the heaviest part of a playlist and are now
loaded on demand by the web client. Make their inclusion opt-in
(with_annotations, default True) and have the logged-in project playlist
endpoint opt out. The shared/guest path keeps the default so the guest
player, which has no lazy-loading, still receives annotations inline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
set_preview_files_for_entities loaded full PreviewFile ORM objects for
every revision of every entity (~7k rows for a 400-shot playlist), then
serialized the whole enriched dict a second time. Hydrating that many ORM
instances dominated the request (it was the bulk of the ~1.8s server time
together with the heavy JSONB columns).

- Select only the scalar columns we serialize, as Row tuples, skipping ORM
  hydration and the heavy `annotations`/`data` JSONB (annotations only when
  the caller asked for them). Mirrors get_preview_files_for_entity().
- Drop the redundant final serialize_value() pass: the dict is already
  JSON-safe (playlist.serialize() + BuildJob.present() + per-row serialized
  values).

Server time for a 414-shot / ~7k-revision playlist dropped from ~1.8s to
~0.1s (with the earlier annotation-blob removal).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@frankrousseau frankrousseau merged commit ea7dff6 into cgwire:main Jun 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant