@bastani/atomic 0.10.11-alpha.2 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +307 -0
- package/README.md +5 -8
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +36 -8
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -0
- package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +1218 -657
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-XJJDOIEC.js} +50 -48
- package/dist/_shared/startup-0-0-XJJDOIEC.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-M6OWAYHH.js} +540 -136
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +47 -48
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +2144 -249
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +98 -1184
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +188 -37
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +88 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1917 -381
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +324 -68
- package/dist/builtin/intercom/broker/multinode-router.ts +256 -39
- package/dist/builtin/intercom/broker/multinode-state-store.ts +71 -5
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +50 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +473 -121
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +821 -79
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +256 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +150 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +175 -24
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +14 -4
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +8 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +4 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +12 -3
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +25 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +18 -6
- package/dist/core/storage/fenced-paths.js +18 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +215 -30
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +484 -72
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +76 -15
- package/dist/core/storage/schema-catalog.js +359 -68
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-detach.d.ts +11 -1
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +4 -7
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +31 -7
- package/dist/core/storage/session/fork-sweep.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-lock.d.ts +100 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +46 -24
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +9 -9
- package/dist/core/storage/session/released-history-files.code.js.map +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +52 -5
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +99 -18
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +12 -1
- package/dist/core/storage/sqlite-facade.js +310 -33
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/sqlite-open-batch.js +10 -0
- package/dist/core/storage/sqlite-open-batch.js.map +1 -0
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +44 -5
- package/dist/core/worktree-snapshot/blob-store.js +553 -30
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +208 -50
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1498 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +0 -1
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Tune PostgreSQL for many agents"
|
|
3
|
+
sidebarTitle: "Server tuning"
|
|
4
|
+
description: "Server-side tuning for a PostgreSQL database shared by many Atomic agents: where the time goes, distance, connections, memory, monitoring, busy tables, and what to leave alone."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This guide is for the person who runs the PostgreSQL server that Atomic's agents share. Use it after you set up the database as in [PostgreSQL setup](/storage/postgres).
|
|
8
|
+
|
|
9
|
+
The table names below assume Atomic's default schema, `atomic`, and no `prefix`, which is the default. With a prefix, each table name starts with it. For example, with `prefix: "team_"`, `atomic.session_sessions` becomes `atomic.team_session_sessions`.
|
|
10
|
+
|
|
11
|
+
## Where the time goes
|
|
12
|
+
|
|
13
|
+
Three things usually limit how fast Atomic's agents work with the server:
|
|
14
|
+
|
|
15
|
+
- **Round trips.** Each save waits for answers from the server. The farther away the server, the longer each wait.
|
|
16
|
+
- **Connections.** Each server has a fixed number. When agents need more than it has, they get errors.
|
|
17
|
+
- **Locks.** Agents that write the same data wait for each other.
|
|
18
|
+
|
|
19
|
+
To tell which one you are hitting, run these as an administrator. Replace `atomic` with your database's name.
|
|
20
|
+
|
|
21
|
+
How many connections are in use, and what they are doing. `active` means running a query, and `idle` means open but unused:
|
|
22
|
+
|
|
23
|
+
```sql
|
|
24
|
+
SELECT state, count(*)
|
|
25
|
+
FROM pg_stat_activity
|
|
26
|
+
WHERE datname = 'atomic'
|
|
27
|
+
GROUP BY state
|
|
28
|
+
ORDER BY 2 DESC;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
What the busy connections are waiting for. A large count with `wait_event_type` `Lock` means lock waits. `Client` with `ClientRead` means the server waits for the agent, which usually means distance:
|
|
32
|
+
|
|
33
|
+
```sql
|
|
34
|
+
SELECT wait_event_type, wait_event, count(*)
|
|
35
|
+
FROM pg_stat_activity
|
|
36
|
+
WHERE datname = 'atomic' AND state <> 'idle'
|
|
37
|
+
GROUP BY 1, 2
|
|
38
|
+
ORDER BY 3 DESC;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
How close the server is to its connection limit:
|
|
42
|
+
|
|
43
|
+
```sql
|
|
44
|
+
SELECT count(*) AS used, current_setting('max_connections')::int AS max
|
|
45
|
+
FROM pg_stat_activity
|
|
46
|
+
WHERE backend_type = 'client backend';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
On the machine itself, `uptime` shows the load average. If it stays well below the number of CPU cores while agents are slow, the server is waiting, not working.
|
|
50
|
+
|
|
51
|
+
## Put the database close to the agents
|
|
52
|
+
|
|
53
|
+
Each save waits for at least one round trip: the time a message takes to reach the server and come back, which `ping` shows. So every save takes at least that long:
|
|
54
|
+
|
|
55
|
+
| Distance to the server | One round trip, and each save at least |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| Same data center | about 1 ms |
|
|
58
|
+
| Same region, different zone | about 2 ms |
|
|
59
|
+
| Across a continent | about 80 ms |
|
|
60
|
+
|
|
61
|
+
Saves wait twice as long until the owner has run `atomic storage migrate` after an upgrade. See [After you upgrade Atomic](#after-you-upgrade-atomic).
|
|
62
|
+
|
|
63
|
+
Distance also makes every lock wait longer, because a transaction holds its locks for its round trips.
|
|
64
|
+
|
|
65
|
+
Run the server in the same region as the agents, and ideally the same zone. No server setting makes up for distance.
|
|
66
|
+
|
|
67
|
+
## Connections
|
|
68
|
+
|
|
69
|
+
Each Atomic process opens up to `maxConnections` plus `readerMaxConnections` connections to the server, 10 by default. An Intercom broker process opens one more, for wake-ups. [Count the connections Atomic needs](/storage/postgres#count-the-connections-atomic-needs) explains the arithmetic, and [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents) shows how to size `maxConnections`.
|
|
70
|
+
|
|
71
|
+
On the server:
|
|
72
|
+
|
|
73
|
+
- **`max_connections`** is the total the server accepts. Each connection uses memory for its own work, so the server cannot accept unlimited connections. Set it high enough for Atomic's connections, or PgBouncer's pool, plus one wake-up connection per broker and room for administrators. Changing it needs a restart.
|
|
74
|
+
- **Per-role limits.** `ALTER ROLE atomic_runtime CONNECTION LIMIT <n>;` caps one role, so a runaway fleet cannot take every slot. Set `<n>` to the connections Atomic needs, or PgBouncer's pool, plus one wake-up connection per broker, plus a margin. The example below uses 300. [Connection limits](/storage/postgres/pgbouncer#connection-limits) works one out.
|
|
75
|
+
- **PgBouncer.** When agents need more connections than the server can give, put [PgBouncer](/storage/postgres/pgbouncer) in front.
|
|
76
|
+
|
|
77
|
+
```sql
|
|
78
|
+
SHOW max_connections;
|
|
79
|
+
ALTER ROLE atomic_runtime CONNECTION LIMIT 300;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Memory
|
|
83
|
+
|
|
84
|
+
### Shared buffers
|
|
85
|
+
|
|
86
|
+
`shared_buffers` is the memory PostgreSQL keeps for table and index pages. A common starting point is a quarter of the machine's memory, for example `shared_buffers = 8GB` on a machine with 32 GB. Atomic's data is usually small enough to fit, so a larger value rarely helps. Changing it needs a restart.
|
|
87
|
+
|
|
88
|
+
### Huge pages
|
|
89
|
+
|
|
90
|
+
The operating system tracks memory in pages, usually 4 KB each. Every server process that touches shared memory keeps its own table of those pages. With 8 GB of shared buffers and hundreds of connections, those tables alone can take gigabytes. Huge pages are 2 MB each on Linux, so the tables are 512 times smaller.
|
|
91
|
+
|
|
92
|
+
PostgreSQL uses huge pages when `huge_pages` is `try` (the default) or `on`, and the operating system has enough of them reserved. With `huge_pages = try` and none reserved, `huge_pages_status` is `off`. To reserve them on Linux:
|
|
93
|
+
|
|
94
|
+
1. **Find out how many pages PostgreSQL needs.** Stop the server first, because PostgreSQL answers this only while it is not running. Then run the server program as the `postgres` user, with your data directory and configuration file. On Debian and Ubuntu, with PostgreSQL 18, replace 18 with your version:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
sudo -u postgres /usr/lib/postgresql/18/bin/postgres -D /var/lib/postgresql/18/main -C shared_memory_size_in_huge_pages -c config_file=/etc/postgresql/18/main/postgresql.conf
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Elsewhere, `postgres` is usually on the `postgres` user's `PATH`, and the configuration file is in the data directory, so `-D <data directory>` is enough. It prints a number of pages, for example `4259`.
|
|
101
|
+
|
|
102
|
+
2. **Reserve a little more than that**, rounded up, and keep it across reboots. For example, for 4259 pages, reserve 4350:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
echo 'vm.nr_hugepages = 4350' | sudo tee /etc/sysctl.d/60-postgresql-hugepages.conf
|
|
106
|
+
sudo sysctl -p /etc/sysctl.d/60-postgresql-hugepages.conf
|
|
107
|
+
grep HugePages_Total /proc/meminfo
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
3. **Start the server and check** that it uses them:
|
|
111
|
+
|
|
112
|
+
```sql
|
|
113
|
+
SHOW huge_pages_status;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
It should say `on`. `huge_pages_status` exists in PostgreSQL 17 and later. On any version, `HugePages_Rsvd` in `/proc/meminfo` should be close to the number PostgreSQL needed.
|
|
117
|
+
|
|
118
|
+
Reserved huge pages are taken out of the memory other programs can use, even while PostgreSQL is stopped. To undo the reservation, stop the server and set `vm.nr_hugepages` back to `0`.
|
|
119
|
+
|
|
120
|
+
Managed services decide huge pages for you.
|
|
121
|
+
|
|
122
|
+
## See what is slow
|
|
123
|
+
|
|
124
|
+
`pg_stat_statements` is an extension that records how often each query runs and how long it takes in total. It shows which of the agents' queries take the server's time.
|
|
125
|
+
|
|
126
|
+
1. **Load it at server start.** Add this line to `postgresql.conf`, or to a file in its `conf.d` directory, and restart:
|
|
127
|
+
|
|
128
|
+
```ini
|
|
129
|
+
shared_preload_libraries = 'pg_stat_statements'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
If the line already lists other libraries, add it to the list, separated by a comma.
|
|
133
|
+
|
|
134
|
+
2. **Create the extension** in Atomic's database, as a superuser or your managed service's administrator role. The owner role is not enough.
|
|
135
|
+
|
|
136
|
+
```sql
|
|
137
|
+
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. **Let the role you monitor with see every query.** Without this, a role sees the text only of its own queries. This example grants it to the owner role:
|
|
141
|
+
|
|
142
|
+
```sql
|
|
143
|
+
GRANT pg_read_all_stats TO atomic_owner;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Run these queries in the `atomic` database.
|
|
147
|
+
|
|
148
|
+
The queries that take the most total time. Look here first:
|
|
149
|
+
|
|
150
|
+
```sql
|
|
151
|
+
SELECT calls, round(total_exec_time) AS total_ms, round(mean_exec_time::numeric, 2) AS mean_ms,
|
|
152
|
+
left(query, 100) AS query
|
|
153
|
+
FROM pg_stat_statements
|
|
154
|
+
ORDER BY total_exec_time DESC
|
|
155
|
+
LIMIT 10;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The slowest queries on average:
|
|
159
|
+
|
|
160
|
+
```sql
|
|
161
|
+
SELECT calls, round(mean_exec_time::numeric, 2) AS mean_ms, round(max_exec_time::numeric, 2) AS max_ms,
|
|
162
|
+
left(query, 100) AS query
|
|
163
|
+
FROM pg_stat_statements
|
|
164
|
+
WHERE calls > 50
|
|
165
|
+
ORDER BY mean_exec_time DESC
|
|
166
|
+
LIMIT 10;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
How much of the time is lock waits. Atomic takes its locks with `pg_advisory_xact_lock`, so a large share here means agents wait for each other, not for the server:
|
|
170
|
+
|
|
171
|
+
```sql
|
|
172
|
+
SELECT round((100 * sum(total_exec_time) FILTER (WHERE query LIKE '%pg_advisory%')
|
|
173
|
+
/ nullif(sum(total_exec_time), 0))::numeric, 1) AS lock_share_percent
|
|
174
|
+
FROM pg_stat_statements;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
To start a new measurement, clear the counters:
|
|
178
|
+
|
|
179
|
+
```sql
|
|
180
|
+
SELECT pg_stat_statements_reset();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Busy small tables
|
|
184
|
+
|
|
185
|
+
A few of Atomic's tables are small but change constantly:
|
|
186
|
+
|
|
187
|
+
| Table | What changes it |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| `atomic.session_sessions` | One row per session, updated on every save |
|
|
190
|
+
| `atomic.intercom_leases` | Leases that Intercom brokers renew every few seconds |
|
|
191
|
+
| `atomic.snapshot_session_links` | Links between sessions and worktree snapshots, updated when sessions change |
|
|
192
|
+
|
|
193
|
+
### Clean them up sooner
|
|
194
|
+
|
|
195
|
+
PostgreSQL never changes a row in place. An update writes a new version of the row and leaves the old one behind as a dead row. A background process, autovacuum, later frees the dead rows. By default it waits until a fifth of a table is dead. On a small table that changes constantly, that can mean many dead rows between cleanups, and queries that read past them.
|
|
196
|
+
|
|
197
|
+
`atomic storage migrate`, run as the owner role, tells autovacuum to clean these tables after a fixed number of dead rows instead: 500 for `session_sessions` and `intercom_leases`, and 1000 for `snapshot_session_links`. You do not set it yourself.
|
|
198
|
+
|
|
199
|
+
The settings take effect at once, with no restart. Migrate keeps any value you have set on these tables yourself. To use a different threshold, set it and migrate leaves it alone:
|
|
200
|
+
|
|
201
|
+
```sql
|
|
202
|
+
ALTER TABLE atomic.session_sessions SET (autovacuum_vacuum_threshold = 2000);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Check dead rows and the last cleanup with:
|
|
206
|
+
|
|
207
|
+
```sql
|
|
208
|
+
SELECT relname, n_live_tup, n_dead_tup, last_autovacuum
|
|
209
|
+
FROM pg_stat_user_tables
|
|
210
|
+
WHERE relname IN ('session_sessions', 'intercom_leases', 'snapshot_session_links');
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Tables that only grow, such as `session_entries`, keep PostgreSQL's defaults. Since PostgreSQL 13, autovacuum also visits a table after enough inserts, and Atomic reads those tables by key, so it gains nothing from cleaning them more often.
|
|
214
|
+
|
|
215
|
+
### Updates that stay on their page
|
|
216
|
+
|
|
217
|
+
When PostgreSQL writes a row's new version on the same page as the old one, and the update changes no indexed column, it can skip updating the table's indexes. This is called a HOT update, for heap-only tuple. It is faster and leaves less to clean up. It only works when the page has free space.
|
|
218
|
+
|
|
219
|
+
`fillfactor` leaves part of every page free for this. Atomic sets `fillfactor = 80` on `session_sessions` and `intercom_leases`, leaving a fifth of each page free, and `fillfactor = 85` on `intercom_outbox`, whose messages Intercom brokers update while they deliver them, when you run `atomic storage migrate`. You do not set it yourself.
|
|
220
|
+
|
|
221
|
+
`fillfactor` applies to pages written after the change. To rewrite existing pages, run `VACUUM FULL` on the table, which locks it while it runs, or use `pg_repack`. This is optional.
|
|
222
|
+
|
|
223
|
+
`snapshot_session_links` gets few or no HOT updates. Its updates change a column that one of its indexes depends on, so free space does not help. The autovacuum settings above keep it small.
|
|
224
|
+
|
|
225
|
+
Check the share of HOT updates per table with:
|
|
226
|
+
|
|
227
|
+
```sql
|
|
228
|
+
SELECT relname, n_tup_upd, n_tup_hot_upd,
|
|
229
|
+
round(100.0 * n_tup_hot_upd / nullif(n_tup_upd, 0), 1) AS hot_percent
|
|
230
|
+
FROM pg_stat_user_tables
|
|
231
|
+
WHERE relname IN ('session_sessions', 'intercom_leases', 'intercom_outbox', 'snapshot_session_links');
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### The search index
|
|
235
|
+
|
|
236
|
+
Atomic indexes session text for history search with a trigram index, `atomic.session_search_trgm`. This kind of index (GIN) does not add new text to the index right away. It first puts it in a holding area, the pending list, and later moves the whole list into the index in one go. That move is called a merge. Searches read the pending list as well as the index, so new text is found as soon as it is written, merged or not.
|
|
237
|
+
|
|
238
|
+
PostgreSQL merges the list when it grows past the index's `gin_pending_list_limit`, and the write that pushes it past the limit does the whole merge itself, so that write is slow now and then. Atomic keeps such merges rare:
|
|
239
|
+
|
|
240
|
+
- **A large limit.** Atomic gives the index a limit of 64 MB, instead of PostgreSQL's default of 4 MB, so a write almost never reaches it.
|
|
241
|
+
- **Merges in the background.** Each agent process, after it has written about 128,000 characters of search text, merges the list on a connection of its own with PostgreSQL's `gin_clean_pending_list`. Nothing waits for it. Only one merge runs at a time across all agents, so the list stays at about 1 MB however many agents write.
|
|
242
|
+
- **Autovacuum merges too.** A vacuum of the table also merges the list. Atomic has the table behind the index, `atomic.session_search_entries`, vacuumed after every 1,000 new rows.
|
|
243
|
+
|
|
244
|
+
`atomic storage migrate`, run as the owner role, sets the limit and the autovacuum settings. You do not set them yourself. If you set a 1 MB limit, as an earlier version of this guide suggested, `atomic storage migrate` replaces it with 64 MB.
|
|
245
|
+
|
|
246
|
+
Only the index's owner may run `gin_clean_pending_list`. Agents that connect as the runtime role leave the merges to autovacuum, so keep autovacuum on. Without either, the list grows to 64 MB, and the write that crosses that limit merges all of it.
|
|
247
|
+
|
|
248
|
+
Writes to the search index don't hold the lock of the session they index, so an agent keeps saving to a session while a history search indexes it.
|
|
249
|
+
|
|
250
|
+
Check the settings with:
|
|
251
|
+
|
|
252
|
+
```sql
|
|
253
|
+
SELECT relname, reloptions
|
|
254
|
+
FROM pg_class
|
|
255
|
+
WHERE relname IN ('session_search_trgm', 'session_search_entries');
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
To see how much text waits in the pending list, use the `pgstattuple` extension. Creating it needs a superuser, or the administrator role on a managed service. Each page is 8 kB:
|
|
259
|
+
|
|
260
|
+
```sql
|
|
261
|
+
CREATE EXTENSION IF NOT EXISTS pgstattuple;
|
|
262
|
+
SELECT pending_pages, pending_tuples FROM pgstatginindex('atomic.session_search_trgm');
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Leave the index's `fastupdate` on. Turning it off skips the pending list and adds every entry to the index as it is written, which makes writing search text many times slower.
|
|
266
|
+
|
|
267
|
+
### Intercom's wake-up notices
|
|
268
|
+
|
|
269
|
+
When one Intercom broker sends a message to another, it also writes a short notice to `atomic.intercom_wakeups` so the other broker checks for the message at once. Atomic makes this table unlogged: PostgreSQL does not write its rows to the write-ahead log, so a notice writes less and needs no disk flush when it commits.
|
|
270
|
+
|
|
271
|
+
An unlogged table is emptied when the server crashes, and it is not copied to standby servers, so it is empty after a failover. Only notices are lost. Brokers also check for messages every 30 seconds, so every message still arrives, at worst that much later. Tables created by `atomic storage migrate` or by a broker start out unlogged. A table an earlier version created becomes unlogged the next time `atomic storage migrate` runs as the owner role.
|
|
272
|
+
|
|
273
|
+
## Compression of large values
|
|
274
|
+
|
|
275
|
+
PostgreSQL compresses large values, such as long session entries, stored files and Intercom messages, before it stores them. Its default method, `pglz`, is slow. `atomic storage migrate` switches those columns to `lz4` when the server supports it. Most PostgreSQL 14 and later servers do, including the PostgreSQL project's packages and Docker images.
|
|
276
|
+
|
|
277
|
+
`lz4` compresses and decompresses faster than `pglz`, and stores session entries in a little less space.
|
|
278
|
+
|
|
279
|
+
Stored files and large tool outputs also use `lz4`, even though they take a little more space than with `pglz`. In tests with real data:
|
|
280
|
+
|
|
281
|
+
| Data | Space with `lz4` | Time to store | Time to read |
|
|
282
|
+
| --- | --- | --- | --- |
|
|
283
|
+
| Large tool outputs from real sessions, 24 MB | 4% more than `pglz` | about a third of `pglz`'s | about 40% of `pglz`'s |
|
|
284
|
+
| Tracked files of six real repositories, images included, 150 MB | 7% more than `pglz` | about 40% of `pglz`'s | about half of `pglz`'s |
|
|
285
|
+
| Images and gzip archives, 37 MB | 3% less than `pglz` | about a quarter of `pglz`'s | the same |
|
|
286
|
+
|
|
287
|
+
The extra space comes from text, which `pglz` packs slightly tighter. Data that is already compressed, such as images and archives, is where `lz4` saves the most time: `pglz` spends that time trying to compress it and failing. Storing these columns without compression (`SET STORAGE EXTERNAL`) saves no time over `lz4` and takes about twice the space on a typical mix of files.
|
|
288
|
+
|
|
289
|
+
Only values written after the change use `lz4`. Values already stored stay readable as they are. To see how a table's values are compressed, run:
|
|
290
|
+
|
|
291
|
+
```sql
|
|
292
|
+
SELECT pg_column_compression(entry_json) AS method, count(*)
|
|
293
|
+
FROM atomic.session_entries GROUP BY 1;
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
`NULL` is a value too small to compress. If your server was built without `lz4`, migrate says so and leaves the columns as they are.
|
|
297
|
+
|
|
298
|
+
## Settings you can usually leave alone
|
|
299
|
+
|
|
300
|
+
These settings come up in tuning advice, but rarely help Atomic:
|
|
301
|
+
|
|
302
|
+
- **`synchronous_commit`.** Keep it `on`. Turning it off for the whole server can lose the last commits in a crash, and on a fast disk a commit's write takes far less time than a network round trip. Atomic already turns it off for its own heartbeat writes, the lease renewals Intercom brokers send every 10 seconds, because losing one in a crash does no harm: the next renewal repeats it. Session entries, messages and every other write still wait for the disk.
|
|
303
|
+
- **`wal_compression`.** Keep the current value. It trades a little CPU for a smaller write-ahead log.
|
|
304
|
+
- **`deadlock_timeout`.** Atomic's lock waits are expected and end at its own lock timeout, so lowering it only adds work. Keep `log_lock_waits = on` to see long waits in the log.
|
|
305
|
+
|
|
306
|
+
## After you upgrade Atomic
|
|
307
|
+
|
|
308
|
+
After every Atomic upgrade, run `atomic storage migrate` once, as the owner role, before you start many agents:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Why it matters for performance:
|
|
315
|
+
|
|
316
|
+
- **Fast starts.** An agent opens an up-to-date database in a few round trips, without taking locks. On a database that is behind, each agent starts by checking and updating it, and many agents starting at once queue behind each other.
|
|
317
|
+
- **Changes only the owner can make.** The runtime role cannot change the schema, so `atomic storage migrate` applies the rest: `fillfactor` and autovacuum settings on the busy tables, `lz4` compression for large values, the search index settings, an unlogged table for Intercom's wake-up notices, and saving entries to a session with one wait for the server instead of two. Until it runs, agents keep working without those gains. Running agents pick them up the next time they start.
|
|
318
|
+
|
|
319
|
+
## Checklist
|
|
320
|
+
|
|
321
|
+
| Step | Restart needed |
|
|
322
|
+
| --- | --- |
|
|
323
|
+
| Run the database in the same region as the agents | No |
|
|
324
|
+
| Size `max_connections` and per-role limits from the connection count, or put PgBouncer in front | `max_connections` only |
|
|
325
|
+
| Set `shared_buffers` to about a quarter of memory | Yes |
|
|
326
|
+
| Reserve huge pages with `vm.nr_hugepages` and check `huge_pages_status` | Yes |
|
|
327
|
+
| Preload `pg_stat_statements`, create it as a superuser, grant `pg_read_all_stats` | Yes |
|
|
328
|
+
| Run `atomic storage migrate` after each Atomic upgrade | No |
|
|
329
|
+
| Keep autovacuum on, so it merges the search index's pending list for agents that use a runtime role | No |
|
|
330
|
+
|
|
331
|
+
On a managed service, such as Amazon RDS, Azure Database for PostgreSQL or Google Cloud SQL, the server settings above may be fixed or set through the service's own parameters. The SQL statements work the same way there, except that creating `pg_stat_statements` needs the service's administrator role.
|
|
332
|
+
|
|
333
|
+
## Related pages
|
|
334
|
+
|
|
335
|
+
- [PostgreSQL setup](/storage/postgres): set up the database and roles.
|
|
336
|
+
- [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents): size Atomic's connection settings.
|
|
337
|
+
- [Run many agents on PostgreSQL with PgBouncer](/storage/postgres/pgbouncer).
|