Bun.serve reads a request body as fast as the client sends it, whether the handler takes it or not. Whenever the store was slower than the client, one PUT of a film put the whole film in the relay's memory: a 512 MiB upload peaked at 762 MiB (disk) and 1011 MiB (S3). A sealed file over 16 MiB now goes up as POST /v1/media/:id/upload plus 16 MiB PATCH pieces, each signed over its offset and length, up to 4 in flight and landing in any order. Uploads under way are durable: on disk uploads/<id>.part + .json + .log (the log names a piece only after fsync), and in S3 a row in shade_media_uploads beside the multipart upload, where piece n is part n+1. A dropped connection, a relay restart or the next piece landing on another instance costs only the pieces in flight. The client asks how far the upload got and sends the rest. Uploads count against quota and are swept after 24 h without a piece. An upload still receiving pieces is never swept, however old its multipart upload is. The sweep is now part of every MediaStore and runs from createMediaService (onSweep) instead of two copies of the timer. No route takes more than 64 MiB, so Bun's 128 MiB cap stays and the container's body limit covers every route. `media put` shows progress. bench/media-store.ts: the relay's peak RSS is 330–369 MiB at both 512 MiB and 1.5 GiB (worst of 3 runs, both stores). Also found: - Bun 1.3.5 fetch never finishes sending a Bun.file().slice() body, so the client reads each piece itself. - postgres.js reads a NULL element of a TEXT[] as the string "NULL", so etags are selected as JSON. Tests: - tests/upload.test.ts (11). - S3 across two instances (+2). - PG index (+1). - media 114, storage-postgres 21, server 55, cli 15. - All 27 packages type-check. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
126 lines
2.8 KiB
JSON
126 lines
2.8 KiB
JSON
[
|
||
{
|
||
"type": "bar",
|
||
"title": "Sealed film store: disk vs S3 (MiB/s)",
|
||
"subtitle": "1536 MiB film through the real media routes, median of 3 runs; relay in its own process; S3 = local SeaweedFS",
|
||
"y": {
|
||
"label": "MiB/s",
|
||
"min": 0
|
||
},
|
||
"note": "Bun 1.3.5. Uploads go up in 16 MiB pieces, up to 4 in flight. Disk: each piece fsynced before it is acknowledged. S3: each piece is one SHA-256-signed multipart part.",
|
||
"source": {
|
||
"path": "media-store-results.json"
|
||
},
|
||
"series": [
|
||
{
|
||
"name": "disk (FileMediaStore)",
|
||
"data": [
|
||
[
|
||
"upload (pieces)",
|
||
286.6
|
||
],
|
||
[
|
||
"read + verify (Range)",
|
||
199.6
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"name": "S3 + Postgres (ObjectMediaStore)",
|
||
"data": [
|
||
[
|
||
"upload (pieces)",
|
||
79.3
|
||
],
|
||
[
|
||
"read + verify (Range)",
|
||
107.4
|
||
]
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"type": "bar",
|
||
"title": "Relay memory does not grow with the film",
|
||
"subtitle": "Peak relay RSS growth during one upload (VmHWM − RSS before), worst of 3 runs, per film size",
|
||
"y": {
|
||
"label": "MiB",
|
||
"min": 0
|
||
},
|
||
"note": "Bounded by the upload window (4 pieces of 16 MiB) and garbage not yet collected. Before pieces, one PUT of a 512 MiB film put 762 MiB (disk) and 1011 MiB (S3) in the relay: Bun.serve reads a request body as fast as the client sends.",
|
||
"source": {
|
||
"path": "media-store-results.json"
|
||
},
|
||
"series": [
|
||
{
|
||
"name": "disk (FileMediaStore)",
|
||
"data": [
|
||
[
|
||
"512 MiB film",
|
||
330
|
||
],
|
||
[
|
||
"1536 MiB film",
|
||
369
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"name": "S3 + Postgres (ObjectMediaStore)",
|
||
"data": [
|
||
[
|
||
"512 MiB film",
|
||
360
|
||
],
|
||
[
|
||
"1536 MiB film",
|
||
358
|
||
]
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"type": "bar",
|
||
"title": "Seek latency, disk vs S3 (ms)",
|
||
"subtitle": "64 KiB at a random offset of the 1536 MiB film, fresh reader each (n = 50 per run, median of 3 runs)",
|
||
"y": {
|
||
"label": "ms",
|
||
"min": 0
|
||
},
|
||
"note": "Includes opening: footer + trailer + root check, then the range.",
|
||
"source": {
|
||
"path": "media-store-results.json"
|
||
},
|
||
"series": [
|
||
{
|
||
"name": "disk (FileMediaStore)",
|
||
"data": [
|
||
[
|
||
"p50",
|
||
9.05
|
||
],
|
||
[
|
||
"p95",
|
||
19.37
|
||
]
|
||
]
|
||
},
|
||
{
|
||
"name": "S3 + Postgres (ObjectMediaStore)",
|
||
"data": [
|
||
[
|
||
"p50",
|
||
20.37
|
||
],
|
||
[
|
||
"p95",
|
||
31.89
|
||
]
|
||
]
|
||
}
|
||
]
|
||
}
|
||
]
|