asset_face, stack and workflow were the only tables with an updateId
column but no index on it. Face and stack sync (AssetFacesV1/V2,
StacksV1, PartnerStacksV1) filter and order on updateId, so every mobile
sync seq-scanned every face on the instance and walked all of the user's
(or partners') stacks, even when nothing had changed. workflow isn't
synced; it gets the index for consistency.
Incremental sync with nothing changed, PG 14:
| query | before | after |
| ---------------------------------- | -------- | -------- |
| assetFace.getUpserts (425k faces) | 33-37 ms | 0.15 ms |
| stack.getUpserts (6k stacks) | 0.8 ms | 0.004 ms |
| partnerStack.getUpserts (6k) | 0.6 ms | 0.007 ms |
The face scan grows with the instance's face count (~10x that at 4M
faces); the stack one with the user's stack count.
(cherry picked from commit 9df807ed4a9536a28dad463270082095ec1fe94d)
* fix(server): require upload access for checksum duplicate check
* fix(server): use the upload access check for the checksum short circuit
(cherry picked from commit 5c02b17495947d7332cce13273226082bd8ae2a1)
SharedLinkRepository.get (shared link page load, /shared-links/me, and the
OpenGraph tags rendered for /share/:key) json_agg'd every asset of the
album, with its full exif row, ordered by fileCreatedAt. The only things
used from it are the asset count and the first/last localDateTime.
Load the album without assets and fill assetCount/startDate/endDate from
getMetadataForIds, which is what GET /albums/:id already uses. The counts
now also respect the default visibility filter, and the dates are
formatted the same as on /albums/:id.
150k-asset album link, PG 14:
| | before | after |
|------------------------|-----------------|--------|
| query | 4.2-6.5 s | ~0.26 s (metadata aggregate) |
| JSON built by postgres | 261 MB | - |
| GET /shared-links/me | - | 0.28 s, 961 B |
(cherry picked from commit ac453b5557e42ad45962d3079a4e4450671053e9)
* perf(server): stop loading every album asset to build album responses
Album create, update (rename, description, cover, sort order, activity
toggle) and add-users json_agg'd every asset of the album with its exif
row, only for mapAlbum to read the count and the first/last
localDateTime. Use getMetadataForIds for those fields, as GET /albums/:id
already does, and drop the now unused withAssets option from getById.
The responses now carry the same date format and lastModifiedAssetTimestamp
as GET /albums/:id.
PATCH /albums/:id on a 150k-asset album, PG 14 (response is ~900 B either
way): 3.4-3.6 s -> 0.13-0.16 s.
* refactor(server): share album metadata mapping
(cherry picked from commit 2a4e876ec990a4a8d5fdca00291cbeebd3d1bccf)
* perf(server): check shared link asset access without scanning the album
checkSharedLinkAccess runs on every thumbnail, preview, playback and asset
info request made through a shared link. It joined every asset of the
link's album and only then filtered on an array overlap across four
outer-joined columns, so each request cost O(album size).
Split it into two branches (link assets, album assets) that find the
requested ids through the asset pkey / livePhotoVideoId index and then
probe the album_asset pkey.
Median per request, PG 14, 1.36M-asset instance:
| album behind the link | before | after |
|-----------------------|--------|---------|
| 290 assets | 2.1 ms | 0.17 ms |
| 150k assets | 296 ms | 0.19 ms |
* chore: clean up
---------
Co-authored-by: Jason Rasmussen <jason@rasm.me>
(cherry picked from commit bb024c862609c9e2baffc08fef795cfa3418df16)
fix: include unamed people in otherPeople (#32237)
(cherry picked from commit 9971dade1b2db76a5a79d287eb2d725152cb0323)
Co-authored-by: Jason Rasmussen <jason@rasm.me>
fix: include partner shared assets for people even without showInTimeline (#32219)
(cherry picked from commit 5fa7789e2672350c76b9b026f2b8c2bc3ffdf7c4)
Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
fix(server): don't select an audio stream ffprobe could not identify (#30901)
iPhone videos recorded with Apple Spatial Audio carry two audio tracks: an
AAC track and an APAC track that ffmpeg has no decoder for. Both are marked
default, so `compareStreams` ties on disposition and falls through to
bitrate, where the APAC track wins because spatial audio is encoded at a
higher rate. `audioStreams[0]` is then persisted and mapped into the
transcode command, and ffmpeg fails before it starts encoding:
[aist#0:2/none] Decoding requested, but no decoder found for: none
Error opening output file .../out.mp4
Error opening output files: Invalid argument
Drop audio streams ffprobe reported as `unknown` before the existing
disposition/bitrate ordering runs. A stream with no codec to decode is not a
usable audio stream, so an asset whose every audio track is unidentified is
treated as having no audio at all. The video pipeline is unchanged, since the
evidence here covers audio selection only.
(cherry picked from commit 69f06a29ca67613355348172480054ebd7e09f6c)
Co-authored-by: Lin, Chiang-Yu <110763842+RxChi1d@users.noreply.github.com>
Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>