The attachment compactor: janitor tasks that shrink stored payloads LOSSLESSLY.
A step stores each payload as it arrived, with compaction_pending set, so that
no step waits for an optimiser. A pass reads each waiting row and makes it
smaller in two steps: image-convert/compact gives a PNG the same picture in
fewer bytes, then codec/pack stores any payload as a zstd frame when that
saves enough. Every read gives the same bytes back as before the pass, except
for a compacted PNG, which shows the same pixels and metadata.
The work runs on the janitor ([[janitor/submit!]]), so it never runs at the same time as a vacuum or a sweep of the same store. A pass stops after [[slice-ms]] and asks for the next pass at once, so a long backlog never holds the other chores for more than one slice.
A pass takes a row ([[persistance/db-claim-next-attachment-compaction!]]) before
it reads the bytes with the optimiser. A payload that stops the process stays
raw and is never taken again, so it cannot stop each next start too.
watch! names a store to the janitor; wake! asks for a pass soon after a
write. A pass also runs every [[poll-ms]], so a wake that came before the write
committed loses nothing.
The attachment compactor: janitor tasks that shrink stored payloads LOSSLESSLY. A step stores each payload as it arrived, with `compaction_pending` set, so that no step waits for an optimiser. A pass reads each waiting row and makes it smaller in two steps: [[image-convert/compact]] gives a PNG the same picture in fewer bytes, then [[codec/pack]] stores any payload as a zstd frame when that saves enough. Every read gives the same bytes back as before the pass, except for a compacted PNG, which shows the same pixels and metadata. The work runs on the janitor ([[janitor/submit!]]), so it never runs at the same time as a vacuum or a sweep of the same store. A pass stops after [[slice-ms]] and asks for the next pass at once, so a long backlog never holds the other chores for more than one slice. A pass takes a row ([[persistance/db-claim-next-attachment-compaction!]]) before it reads the bytes with the optimiser. A payload that stops the process stays `raw` and is never taken again, so it cannot stop each next start too. [[watch!]] names a store to the janitor; [[wake!]] asks for a pass soon after a write. A pass also runs every [[poll-ms]], so a wake that came before the write committed loses nothing.
(drain! db)(drain! db budget-ms)Compact the waiting rows of db, one at a time, until none waits or
budget-ms has passed (nil: no limit). The time is checked before each row,
so one row can take longer than the budget: a large PNG takes seconds. Answer
{:rows n :more? bool}: how many rows it took, and whether rows can still wait.
A pass that stops at the budget answers :more? true without a look, so the
next pass can find none.
Compact the waiting rows of `db`, one at a time, until none waits or
`budget-ms` has passed (nil: no limit). The time is checked before each row,
so one row can take longer than the budget: a large PNG takes seconds. Answer
`{:rows n :more? bool}`: how many rows it took, and whether rows can still wait.
A pass that stops at the budget answers `:more? true` without a look, so the
next pass can find none.(wake!)Ask for a pass of each watched store soon. Many wakes before the pass start make one pass.
Ask for a pass of each watched store soon. Many wakes before the pass start make one pass.
(watch! db)Give the store db to the janitor and drain its waiting rows soon. A store that
the janitor already drains changes nothing.
Give the store `db` to the janitor and drain its waiting rows soon. A store that the janitor already drains changes nothing.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |