@bastani/atomic 0.10.14-alpha.1 → 0.10.15-alpha.1
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 +29 -0
- 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 +3 -3
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
- package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
- package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
- package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
- package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
- package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
- package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- 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/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/auth-cli.code.js +1 -1
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.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.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- 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 +1 -1
- 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 +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/compaction/compactor.d.ts +0 -8
- 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 +2 -2
- 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.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- 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 +2 -2
- 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.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/sdk.code.js +1 -1
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +3 -3
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- 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/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- 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 +2 -2
- 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-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 +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-window.code.js +2 -2
- 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-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 +2 -2
- 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 +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/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 +2 -2
- 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.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/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- 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 +2 -2
- 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 +2 -2
- 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.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- 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.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +1 -1
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- 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.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +1 -1
- 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 +21 -1
- package/dist/index.js +2 -2
- 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/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/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +2 -2
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/utils/startup-database-spare.code.js +1 -1
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks/reference.md +182 -0
- package/docs/background-tasks.md +98 -405
- package/docs/build.md +67 -27
- package/docs/changelog.mdx +9 -0
- package/docs/codemode.md +108 -39
- package/docs/compaction/branch-summaries.md +54 -0
- package/docs/compaction/custom-compactors.md +161 -0
- package/docs/compaction/memory-compaction.md +77 -0
- package/docs/compaction/reference.md +86 -38
- package/docs/compaction.md +51 -252
- package/docs/computer-use.md +169 -321
- package/docs/containerization.md +71 -57
- package/docs/custom-provider/api-reference.md +119 -25
- package/docs/custom-provider/oauth.md +114 -132
- package/docs/custom-provider/override.md +37 -27
- package/docs/custom-provider/registration.md +107 -83
- package/docs/custom-provider/streaming.md +85 -71
- package/docs/custom-provider.md +85 -52
- package/docs/development.md +39 -29
- package/docs/docs.json +76 -63
- package/docs/environment-variables.md +94 -44
- package/docs/extensions/api-reference.md +86 -43
- package/docs/extensions/authoring.md +162 -154
- package/docs/extensions/events.md +80 -25
- package/docs/extensions/examples.md +90 -85
- package/docs/extensions/ui.md +206 -82
- package/docs/extensions.md +79 -108
- package/docs/getting-started/authentication.md +67 -36
- package/docs/getting-started/first-session.md +53 -43
- package/docs/getting-started/installation.md +116 -89
- package/docs/getting-started/project-instructions.md +48 -34
- package/docs/guides/configuration.md +82 -20
- package/docs/guides/non-interactive.md +66 -24
- package/docs/guides/resume-on-any-machine.md +135 -82
- package/docs/guides/team-setup.md +114 -105
- package/docs/guides.md +76 -32
- package/docs/herdr.md +15 -16
- package/docs/how-atomic-works.md +140 -0
- package/docs/index.md +58 -44
- package/docs/intercom/operations.md +141 -151
- package/docs/intercom/reference.md +85 -108
- package/docs/intercom.md +84 -145
- package/docs/json.md +120 -67
- package/docs/keybindings.md +85 -49
- package/docs/libraries/agent-core.md +137 -275
- package/docs/libraries/ai.md +100 -84
- package/docs/libraries/codemode.md +210 -300
- package/docs/libraries/schema.md +59 -53
- package/docs/libraries/storage-postgres.md +49 -35
- package/docs/libraries/telemetry.md +153 -354
- package/docs/libraries/tui.md +265 -393
- package/docs/libraries.md +42 -26
- package/docs/llama-cpp.md +171 -161
- package/docs/mcp-servers.md +90 -51
- package/docs/models/choose-a-model.md +188 -0
- package/docs/models/reference.md +74 -30
- package/docs/models.md +153 -88
- package/docs/orchestration/migrating-workflows.md +23 -16
- package/docs/orchestration/patterns.md +39 -44
- package/docs/orchestration.md +65 -26
- package/docs/packages/authoring.md +51 -29
- package/docs/packages/reference.md +42 -21
- package/docs/packages.md +69 -58
- package/docs/programmatic.md +118 -24
- package/docs/prompt-templates.md +84 -83
- package/docs/providers/reference.md +43 -48
- package/docs/providers.md +219 -451
- package/docs/quickstart.md +140 -120
- package/docs/reference/cli.md +135 -97
- package/docs/reference.md +20 -18
- package/docs/rpc/examples.md +76 -20
- package/docs/rpc/extension-ui.md +64 -38
- package/docs/rpc/protocol.md +361 -110
- package/docs/rpc.md +57 -17
- package/docs/sdk/reference.md +409 -534
- package/docs/sdk/storage.md +53 -13
- package/docs/sdk/structured-decisions.md +82 -56
- package/docs/sdk/web-server.md +57 -43
- package/docs/sdk.md +106 -84
- package/docs/security.md +42 -64
- package/docs/session-format.md +62 -38
- package/docs/sessions.md +99 -214
- package/docs/settings.md +165 -195
- package/docs/shell-aliases.md +9 -6
- package/docs/skills/authoring.md +69 -48
- package/docs/skills/reference.md +51 -20
- package/docs/skills.md +99 -148
- package/docs/slash-commands.md +129 -0
- package/docs/storage/custom-adapters.md +160 -85
- package/docs/storage/jsonl.md +81 -66
- package/docs/storage/postgres/pgbouncer.md +120 -126
- package/docs/storage/postgres/tuning.md +120 -143
- package/docs/storage/postgres.md +314 -330
- package/docs/storage/sqlite.md +71 -42
- package/docs/storage.md +298 -302
- package/docs/subagents/authoring.md +55 -38
- package/docs/subagents/reference.md +73 -33
- package/docs/subagents.md +119 -187
- package/docs/terminal-setup.md +50 -38
- package/docs/termux.md +67 -41
- package/docs/themes/reference.md +23 -19
- package/docs/themes.md +142 -127
- package/docs/tmux.md +47 -55
- package/docs/tools.md +147 -109
- package/docs/tui/reference.md +166 -214
- package/docs/tui.md +196 -341
- package/docs/usage.md +118 -138
- package/docs/verification.md +79 -51
- package/docs/web-access.md +121 -101
- package/docs/windows.md +26 -27
- package/docs/worktree-snapshots/reference.md +245 -0
- package/docs/worktree-snapshots.md +71 -259
- package/package.json +8 -8
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
- package/docs/guides/intercom.md +0 -32
- package/docs/guides/orchestration.md +0 -28
- package/docs/guides/subagents.md +0 -37
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Tune PostgreSQL for many agents"
|
|
3
3
|
sidebarTitle: "Server tuning"
|
|
4
|
-
description: "Server-side tuning for a PostgreSQL database shared by many Atomic agents:
|
|
4
|
+
description: "Server-side tuning for a PostgreSQL database shared by many Atomic agents: network distance, connections, memory and huge pages, query profiling, busy tables, compression, and upgrades."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
This guide
|
|
7
|
+
This guide covers server-side tuning for the PostgreSQL instance behind your Atomic fleet. Complete [PostgreSQL setup](/storage/postgres) first.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Table names below assume the default schema (`atomic`) and no `prefix`. When a `prefix` is configured, every table name starts with it (for example, `prefix: "team_"` maps `atomic.session_sessions` to `atomic.team_session_sessions`).
|
|
10
10
|
|
|
11
11
|
## Where the time goes
|
|
12
12
|
|
|
13
|
-
Three
|
|
13
|
+
Three bottlenecks typically limit multi-agent throughput on PostgreSQL:
|
|
14
14
|
|
|
15
|
-
- **Round trips
|
|
16
|
-
- **Connections
|
|
17
|
-
- **Locks
|
|
15
|
+
- **Round trips:** Every save waits for the server to acknowledge it; higher network latency adds directly to every save and lock hold time.
|
|
16
|
+
- **Connections:** Exceeding `max_connections` rejects new work with errors.
|
|
17
|
+
- **Locks:** Agents writing to the same session wait in line for each other.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Run these diagnostic queries as an administrator (replace `atomic` with your database name):
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Connections by state (`active` = executing a query; `idle` = open and waiting):
|
|
22
22
|
|
|
23
23
|
```sql
|
|
24
24
|
SELECT state, count(*)
|
|
@@ -28,7 +28,7 @@ GROUP BY state
|
|
|
28
28
|
ORDER BY 2 DESC;
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
What
|
|
31
|
+
What non-idle connections are waiting on (`Lock` indicates contention; `Client` / `ClientRead` typically reflects network round-trip latency):
|
|
32
32
|
|
|
33
33
|
```sql
|
|
34
34
|
SELECT wait_event_type, wait_event, count(*)
|
|
@@ -38,7 +38,7 @@ GROUP BY 1, 2
|
|
|
38
38
|
ORDER BY 3 DESC;
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Current client connections vs. `max_connections`:
|
|
42
42
|
|
|
43
43
|
```sql
|
|
44
44
|
SELECT count(*) AS used, current_setting('max_connections')::int AS max
|
|
@@ -46,33 +46,29 @@ FROM pg_stat_activity
|
|
|
46
46
|
WHERE backend_type = 'client backend';
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
On the
|
|
49
|
+
On the database host itself, check `uptime`: if load average sits well below CPU core count while agents feel slow, the workload is waiting on network latency or locks rather than CPU.
|
|
50
50
|
|
|
51
51
|
## Put the database close to the agents
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Every save waits for at least one network round trip, and transactions hold their locks across those round trips:
|
|
54
54
|
|
|
55
|
-
| Distance to
|
|
55
|
+
| Distance to PostgreSQL | Typical round trip (minimum per save) |
|
|
56
56
|
| --- | --- |
|
|
57
|
-
| Same data center |
|
|
58
|
-
| Same region, different zone |
|
|
59
|
-
|
|
|
57
|
+
| Same data center | ~1 ms |
|
|
58
|
+
| Same region, different availability zone | ~2 ms |
|
|
59
|
+
| Cross-continent | ~80 ms |
|
|
60
60
|
|
|
61
|
-
|
|
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.
|
|
61
|
+
Run PostgreSQL in the same region—and ideally the same availability zone—as your agents. No server parameter compensates for network distance. Also run `atomic storage migrate` after upgrades so session appends use the single-round-trip path instead of two round trips (see [After you upgrade Atomic](#after-you-upgrade-atomic)).
|
|
66
62
|
|
|
67
63
|
## Connections
|
|
68
64
|
|
|
69
|
-
Each Atomic process opens up to `maxConnections
|
|
65
|
+
Each Atomic process opens up to `maxConnections + readerMaxConnections` connections (10 by default), plus 1 wake-up connection per Intercom broker. See [Count the connections Atomic needs](/storage/postgres#count-the-connections-atomic-needs) and [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents) for sizing.
|
|
70
66
|
|
|
71
67
|
On the server:
|
|
72
68
|
|
|
73
|
-
- **`max_connections`**
|
|
74
|
-
- **Per-role
|
|
75
|
-
- **
|
|
69
|
+
- **`max_connections`** (requires restart): set high enough for Atomic's connections (or PgBouncer's server pool), one wake-up connection per broker, and admin/monitoring overhead.
|
|
70
|
+
- **Per-role cap:** cap `atomic_runtime` to PgBouncer's pool plus broker wake-ups plus a safety margin so a fleet surge cannot starve administrators (see [Connection limits](/storage/postgres/pgbouncer#connection-limits)).
|
|
71
|
+
- **Connection pooler:** deploy [PgBouncer](/storage/postgres/pgbouncer) when fleet demand exceeds `max_connections`.
|
|
76
72
|
|
|
77
73
|
```sql
|
|
78
74
|
SHOW max_connections;
|
|
@@ -83,69 +79,75 @@ ALTER ROLE atomic_runtime CONNECTION LIMIT 300;
|
|
|
83
79
|
|
|
84
80
|
### Shared buffers
|
|
85
81
|
|
|
86
|
-
`shared_buffers`
|
|
82
|
+
`shared_buffers` controls PostgreSQL's shared page cache (requires restart). A good starting point is 25% of host RAM (for example `shared_buffers = 8GB` on a 32 GB host). Atomic's working set usually fits comfortably inside this cache, so allocating much more rarely helps.
|
|
87
83
|
|
|
88
84
|
### Huge pages
|
|
89
85
|
|
|
90
|
-
|
|
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`.
|
|
86
|
+
Linux normally tracks memory in 4 KB pages, and every PostgreSQL backend keeps its own page-table entries for shared memory. With large `shared_buffers` and hundreds of connections, page tables alone can consume gigabytes. Linux 2 MB huge pages shrink those page tables by 512×.
|
|
101
87
|
|
|
102
|
-
|
|
88
|
+
PostgreSQL uses huge pages automatically when `huge_pages` is `try` (default) or `on` and enough huge pages are reserved at the OS level. Managed services configure huge pages for you; on self-hosted Linux:
|
|
103
89
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
grep HugePages_Total /proc/meminfo
|
|
108
|
-
```
|
|
90
|
+
<Steps>
|
|
91
|
+
<Step title="Ask PostgreSQL how many huge pages it needs">
|
|
92
|
+
Stop PostgreSQL first (`-C` reads this only while stopped), then run `postgres` as the `postgres` user (on Debian/Ubuntu, adjust `18` for your PostgreSQL version):
|
|
109
93
|
|
|
110
|
-
|
|
94
|
+
```bash
|
|
95
|
+
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
|
|
96
|
+
```
|
|
111
97
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
Elsewhere, `postgres -D <data-dir> -C shared_memory_size_in_huge_pages` is usually enough. Note the printed count (for example `4259`).
|
|
99
|
+
</Step>
|
|
100
|
+
<Step title="Reserve slightly more pages persistently">
|
|
101
|
+
Round up with headroom (for example `4350` for `4259` needed):
|
|
115
102
|
|
|
116
|
-
|
|
103
|
+
```bash
|
|
104
|
+
echo 'vm.nr_hugepages = 4350' | sudo tee /etc/sysctl.d/60-postgresql-hugepages.conf
|
|
105
|
+
sudo sysctl -p /etc/sysctl.d/60-postgresql-hugepages.conf
|
|
106
|
+
grep HugePages_Total /proc/meminfo
|
|
107
|
+
```
|
|
108
|
+
</Step>
|
|
109
|
+
<Step title="Start PostgreSQL and verify">
|
|
110
|
+
```sql
|
|
111
|
+
SHOW huge_pages_status;
|
|
112
|
+
```
|
|
117
113
|
|
|
118
|
-
|
|
114
|
+
Expect `on` (PostgreSQL 17+; on PostgreSQL 16, verify `HugePages_Rsvd` in `/proc/meminfo` matches the expected count).
|
|
115
|
+
</Step>
|
|
116
|
+
</Steps>
|
|
119
117
|
|
|
120
|
-
|
|
118
|
+
<Note>
|
|
119
|
+
Reserved huge pages remain unavailable to other host processes even when PostgreSQL is stopped. To release them, stop PostgreSQL and set `vm.nr_hugepages = 0`.
|
|
120
|
+
</Note>
|
|
121
121
|
|
|
122
122
|
## See what is slow
|
|
123
123
|
|
|
124
|
-
`pg_stat_statements`
|
|
124
|
+
Use `pg_stat_statements` to measure total and per-call execution time across all agent queries:
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
<Steps>
|
|
127
|
+
<Step title="Preload pg_stat_statements and restart PostgreSQL">
|
|
128
|
+
Add to `postgresql.conf` (or append to an existing comma-separated list):
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
```ini
|
|
131
|
+
shared_preload_libraries = 'pg_stat_statements'
|
|
132
|
+
```
|
|
133
|
+
</Step>
|
|
134
|
+
<Step title="Create the extension as a superuser or managed-service admin">
|
|
135
|
+
```sql
|
|
136
|
+
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
|
137
|
+
```
|
|
138
|
+
</Step>
|
|
139
|
+
<Step title="Grant stats visibility to your monitoring role">
|
|
140
|
+
Without `pg_read_all_stats`, a role can inspect only its own query text:
|
|
131
141
|
|
|
132
|
-
|
|
142
|
+
```sql
|
|
143
|
+
GRANT pg_read_all_stats TO atomic_owner;
|
|
144
|
+
```
|
|
145
|
+
</Step>
|
|
146
|
+
</Steps>
|
|
133
147
|
|
|
134
|
-
|
|
148
|
+
Run these queries in the `atomic` database:
|
|
135
149
|
|
|
136
|
-
|
|
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:
|
|
150
|
+
Top queries by total execution time (start here):
|
|
149
151
|
|
|
150
152
|
```sql
|
|
151
153
|
SELECT calls, round(total_exec_time) AS total_ms, round(mean_exec_time::numeric, 2) AS mean_ms,
|
|
@@ -155,7 +157,7 @@ ORDER BY total_exec_time DESC
|
|
|
155
157
|
LIMIT 10;
|
|
156
158
|
```
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
Slowest frequent queries on average:
|
|
159
161
|
|
|
160
162
|
```sql
|
|
161
163
|
SELECT calls, round(mean_exec_time::numeric, 2) AS mean_ms, round(max_exec_time::numeric, 2) AS max_ms,
|
|
@@ -166,7 +168,7 @@ ORDER BY mean_exec_time DESC
|
|
|
166
168
|
LIMIT 10;
|
|
167
169
|
```
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
Share of total execution time spent waiting on Atomic's advisory locks (`pg_advisory_xact_lock`—a high percentage means agents are contending on the same data rather than waiting on PostgreSQL):
|
|
170
172
|
|
|
171
173
|
```sql
|
|
172
174
|
SELECT round((100 * sum(total_exec_time) FILTER (WHERE query LIKE '%pg_advisory%')
|
|
@@ -174,7 +176,7 @@ SELECT round((100 * sum(total_exec_time) FILTER (WHERE query LIKE '%pg_advisory%
|
|
|
174
176
|
FROM pg_stat_statements;
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
Reset counters before starting a fresh measurement window:
|
|
178
180
|
|
|
179
181
|
```sql
|
|
180
182
|
SELECT pg_stat_statements_reset();
|
|
@@ -182,27 +184,25 @@ SELECT pg_stat_statements_reset();
|
|
|
182
184
|
|
|
183
185
|
## Busy small tables
|
|
184
186
|
|
|
185
|
-
|
|
187
|
+
Three small tables receive frequent updates:
|
|
186
188
|
|
|
187
|
-
| Table |
|
|
189
|
+
| Table | Update pattern |
|
|
188
190
|
| --- | --- |
|
|
189
191
|
| `atomic.session_sessions` | One row per session, updated on every save |
|
|
190
|
-
| `atomic.intercom_leases` |
|
|
191
|
-
| `atomic.snapshot_session_links` |
|
|
192
|
+
| `atomic.intercom_leases` | Broker membership and presence leases renewed every 10 seconds |
|
|
193
|
+
| `atomic.snapshot_session_links` | Parent/child worktree snapshot links updated as sessions append entries |
|
|
192
194
|
|
|
193
195
|
### Clean them up sooner
|
|
194
196
|
|
|
195
|
-
PostgreSQL
|
|
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.
|
|
197
|
+
Because PostgreSQL uses MVCC, every update leaves a dead tuple until autovacuum reclaims it. PostgreSQL's default 20% dead-tuple ratio can let thousands of dead versions accumulate on small, hot tables.
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
`atomic storage migrate` (run as the owner role) automatically configures fixed dead-tuple autovacuum thresholds: `500` for `session_sessions` and `intercom_leases`, and `1000` for `snapshot_session_links`. No restart is needed, and `migrate` preserves any custom threshold you have set manually:
|
|
200
200
|
|
|
201
201
|
```sql
|
|
202
202
|
ALTER TABLE atomic.session_sessions SET (autovacuum_vacuum_threshold = 2000);
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
Inspect live vs. dead tuples and last cleanup time:
|
|
206
206
|
|
|
207
207
|
```sql
|
|
208
208
|
SELECT relname, n_live_tup, n_dead_tup, last_autovacuum
|
|
@@ -210,19 +210,18 @@ FROM pg_stat_user_tables
|
|
|
210
210
|
WHERE relname IN ('session_sessions', 'intercom_leases', 'snapshot_session_links');
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
Append-only tables like `session_entries` keep PostgreSQL's default autovacuum settings.
|
|
214
214
|
|
|
215
215
|
### Updates that stay on their page
|
|
216
216
|
|
|
217
|
-
When
|
|
217
|
+
When an updated row version fits on the same 8 KB page and modifies no indexed column, PostgreSQL performs a **HOT (Heap-Only Tuple)** update—skipping index writes and reducing bloat.
|
|
218
218
|
|
|
219
|
-
`
|
|
219
|
+
`atomic storage migrate` configures this automatically:
|
|
220
220
|
|
|
221
|
-
`fillfactor`
|
|
221
|
+
- Sets `fillfactor = 80` on `session_sessions` and `intercom_leases`, and `fillfactor = 85` on `intercom_outbox`, leaving free space on new pages for in-place HOT updates. (Rewriting pre-existing pages via `VACUUM FULL`—which locks the table—or `pg_repack` is optional.)
|
|
222
|
+
- Replaces the legacy `snapshot_session_links_leaves` partial index (which filtered on `children = 0`) with `snapshot_session_links_anchored` (`WHERE anchor_seq IS NOT NULL`), built concurrently without blocking writes. Because no index references `children` anymore, parent-link `children` increments on session appends stay HOT updates whenever the page has free space. Combined with the autovacuum threshold (`1000`), this keeps `snapshot_session_links` compact and fast.
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
Check the share of HOT updates per table with:
|
|
224
|
+
Check HOT update ratios per table:
|
|
226
225
|
|
|
227
226
|
```sql
|
|
228
227
|
SELECT relname, n_tup_upd, n_tup_hot_upd,
|
|
@@ -233,21 +232,15 @@ WHERE relname IN ('session_sessions', 'intercom_leases', 'intercom_outbox', 'sna
|
|
|
233
232
|
|
|
234
233
|
### The search index
|
|
235
234
|
|
|
236
|
-
Atomic indexes session
|
|
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.
|
|
235
|
+
Atomic indexes session history text with a GIN trigram index (`atomic.session_search_trgm` on `atomic.session_search_entries`). New writes land in the GIN pending list (immediately searchable) and merge in bulk.
|
|
243
236
|
|
|
244
|
-
`atomic storage migrate
|
|
237
|
+
`atomic storage migrate` sets `gin_pending_list_limit` to **64 MB** (replacing PostgreSQL's 4 MB default or any previous 1 MB limit) so foreground writes rarely trigger an inline merge, and configures autovacuum on `atomic.session_search_entries` to run after every **1,000** inserted rows so pending entries flush regularly. Agents connecting as the index owner also clean the pending list asynchronously in the background; agents connecting as the least-privilege `atomic_runtime` role rely on autovacuum to perform those merges—so **keep autovacuum enabled**. Search indexing does not hold session write locks.
|
|
245
238
|
|
|
246
|
-
|
|
239
|
+
<Warning>
|
|
240
|
+
Leave `fastupdate = on` on `atomic.session_search_trgm`. Turning `fastupdate` off forces every write straight into the GIN tree and slows search indexing dramatically.
|
|
241
|
+
</Warning>
|
|
247
242
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Check the settings with:
|
|
243
|
+
Verify the index and table storage parameters:
|
|
251
244
|
|
|
252
245
|
```sql
|
|
253
246
|
SELECT relname, reloptions
|
|
@@ -255,83 +248,67 @@ FROM pg_class
|
|
|
255
248
|
WHERE relname IN ('session_search_trgm', 'session_search_entries');
|
|
256
249
|
```
|
|
257
250
|
|
|
258
|
-
|
|
251
|
+
Inspect pending-list size (each page is 8 KB; creating `pgstattuple` requires a superuser or managed-service admin):
|
|
259
252
|
|
|
260
253
|
```sql
|
|
261
254
|
CREATE EXTENSION IF NOT EXISTS pgstattuple;
|
|
262
255
|
SELECT pending_pages, pending_tuples FROM pgstatginindex('atomic.session_search_trgm');
|
|
263
256
|
```
|
|
264
257
|
|
|
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
258
|
### Intercom's wake-up notices
|
|
268
259
|
|
|
269
|
-
When
|
|
260
|
+
When a broker sends a cross-host message, it writes a short wake-up hint to `atomic.intercom_wakeups` alongside the durable message in `atomic.intercom_outbox`. Atomic marks `intercom_wakeups` as `UNLOGGED` (either on creation or during `atomic storage migrate`) to eliminate WAL writes and disk flushes for ephemeral hints.
|
|
270
261
|
|
|
271
|
-
|
|
262
|
+
Normally, brokers receive `LISTEN/NOTIFY` notifications immediately and poll `intercom_wakeups` every **5 seconds** (or every **0.5 seconds** if `LISTEN/NOTIFY` is unavailable; see [Wake-ups](/storage/postgres#wake-ups)). If PostgreSQL crashes or fails over to a standby, the unlogged `intercom_wakeups` table empties—losing only hints while messages remain safely in `intercom_outbox`. Independently of wake-up hints, every broker scans `intercom_outbox` directly every **30 seconds** as a backup safety net, so every message still arrives within at most 30 seconds.
|
|
272
263
|
|
|
273
264
|
## Compression of large values
|
|
274
265
|
|
|
275
|
-
|
|
266
|
+
`atomic storage migrate` automatically switches large text, JSON, and binary columns (`session_entries`, chunk tables, snapshot blobs, chat records, and `intercom_outbox`) from PostgreSQL's default `pglz` compression to **`lz4`** whenever the server supports it (standard in most PostgreSQL 14+ builds).
|
|
276
267
|
|
|
277
|
-
`lz4` compresses and decompresses faster than `pglz
|
|
268
|
+
`lz4` compresses and decompresses roughly 2–4× faster than `pglz`—especially on already-compressed content like images and archives—for only a few percent more disk space on plain text, while avoiding the ~2× storage overhead of disabling compression (`SET STORAGE EXTERNAL`). Existing rows remain readable as-is; new writes use `lz4`. If your server was compiled without `lz4`, `migrate` reports this and leaves columns unchanged.
|
|
278
269
|
|
|
279
|
-
|
|
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:
|
|
270
|
+
Check active compression methods on `session_entries` (`NULL` means a value was small enough to store inline uncompressed):
|
|
290
271
|
|
|
291
272
|
```sql
|
|
292
273
|
SELECT pg_column_compression(entry_json) AS method, count(*)
|
|
293
274
|
FROM atomic.session_entries GROUP BY 1;
|
|
294
275
|
```
|
|
295
276
|
|
|
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
277
|
## Settings you can usually leave alone
|
|
299
278
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
- **`
|
|
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.
|
|
279
|
+
- **`synchronous_commit`:** Keep `on` server-wide so crashes cannot drop committed session entries or messages. Atomic already sets `synchronous_commit = off` per transaction for repeatable broker lease heartbeats (every 10 seconds), where losing one write is harmless.
|
|
280
|
+
- **`wal_compression`:** Keep your server default.
|
|
281
|
+
- **`deadlock_timeout`:** Leave at default; Atomic's expected lock waits use its own timeouts. Keeping `log_lock_waits = on` is helpful for diagnosing long waits.
|
|
305
282
|
|
|
306
283
|
## After you upgrade Atomic
|
|
307
284
|
|
|
308
|
-
|
|
285
|
+
Run `atomic storage migrate` once as the owner role after every Atomic upgrade, before launching your agent fleet:
|
|
309
286
|
|
|
310
287
|
```bash
|
|
311
288
|
atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password
|
|
312
289
|
```
|
|
313
290
|
|
|
314
|
-
|
|
291
|
+
Running `migrate` as the owner role ensures:
|
|
315
292
|
|
|
316
|
-
- **Fast
|
|
317
|
-
- **
|
|
293
|
+
- **Fast startup:** Agents open an up-to-date database in a couple of round trips with no schema-init contention.
|
|
294
|
+
- **Owner-only optimizations and lazy objects:** Applies `fillfactor`, autovacuum thresholds, `lz4` compression, search index tuning, unlogged `intercom_wakeups`, the concurrent `snapshot_session_links_anchored` index rebuild (up to a 6-hour statement timeout for large tables without blocking writes), the single-round-trip session append function, and lazily initialized tables (fork staging, chat records, Intercom ended-child queue). Each table tuning `ALTER TABLE` uses a 2-second `lock_timeout` and gracefully skips busy tables without failing the migration—re-run later if any table was skipped.
|
|
318
295
|
|
|
319
296
|
## Checklist
|
|
320
297
|
|
|
321
|
-
| Step | Restart
|
|
298
|
+
| Step | Restart required |
|
|
322
299
|
| --- | --- |
|
|
323
|
-
| Run
|
|
324
|
-
| Size `max_connections` and
|
|
325
|
-
| Set `shared_buffers` to
|
|
326
|
-
| Reserve huge pages
|
|
327
|
-
| Preload
|
|
328
|
-
| Run `atomic storage migrate` after
|
|
329
|
-
| Keep autovacuum
|
|
300
|
+
| Run PostgreSQL in the same region (ideally same zone) as your agents | No |
|
|
301
|
+
| Size `max_connections` and `atomic_runtime` `CONNECTION LIMIT`, or deploy PgBouncer | `max_connections` only |
|
|
302
|
+
| Set `shared_buffers` to ~25% of host RAM | Yes |
|
|
303
|
+
| Reserve Linux huge pages (`vm.nr_hugepages`) and verify `huge_pages_status` | Yes |
|
|
304
|
+
| Preload and create `pg_stat_statements`; grant `pg_read_all_stats` | Yes |
|
|
305
|
+
| Run `atomic storage migrate` as owner after every Atomic upgrade | No |
|
|
306
|
+
| Keep autovacuum enabled so search pending lists merge under runtime roles | No |
|
|
330
307
|
|
|
331
|
-
On
|
|
308
|
+
On managed services (Amazon RDS, Azure Database for PostgreSQL, Google Cloud SQL), adjust server settings through parameter groups or console controls; SQL statements work identically (creating extensions requires the managed admin role).
|
|
332
309
|
|
|
333
310
|
## Related pages
|
|
334
311
|
|
|
335
|
-
- [PostgreSQL setup](/storage/postgres):
|
|
336
|
-
- [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents):
|
|
337
|
-
- [
|
|
312
|
+
- [PostgreSQL setup](/storage/postgres): database roles, TLS, proxies, and troubleshooting.
|
|
313
|
+
- [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents): client pool arithmetic and `maxConnections`.
|
|
314
|
+
- [Use PgBouncer with PostgreSQL](/storage/postgres/pgbouncer): transaction pooling configuration and health checks.
|