Skip to content

Commit 9e79dd2

Browse files
authored
improvement(background): right-size the two knowledge task machines (#7212)
Both knowledge tasks reserved machine presets well above their measured ceilings. Sized each from production telemetry on both memory and CPU: - knowledge-connector-sync: large-2x -> large-1x. Peak sampled RSS 2.6 GB and peak 1.4 vCPU, so 8 GB/4 vCPU keeps ~3x memory and ~2.8x CPU headroom against a preset that reserved 16 GB. - knowledge-process-document: large-1x -> medium-2x. Peak sampled RSS 902 MB and peak 1.2 vCPU, with no document exceeding 2 GB, so 4 GB/2 vCPU keeps ~4x memory and ~1.7x CPU headroom. CPU figures are core-normalized (OTel process.cpu.utilization divides by cores available), so neither task loses headroom it was actually using and neither can be throttled by the smaller preset. No retry or concurrency semantics change.
1 parent f775fe0 commit 9e79dd2

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

apps/sim/background/knowledge-connector-sync.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ export async function executeConnectorSyncJob(payload: unknown) {
9898
export const knowledgeConnectorSync = task({
9999
id: 'knowledge-connector-sync',
100100
maxDuration: CONNECTOR_SYNC_MAX_DURATION_SECONDS,
101-
machine: 'large-2x',
101+
/**
102+
* Sized from production telemetry: peak sampled RSS 2.6 GB and peak 1.4 vCPU,
103+
* so `large-1x` holds ~3x memory and ~2.8x CPU headroom. No `outOfMemory`
104+
* escalation: an OOM is a SIGKILL, so the run never reaches the terminal
105+
* write that clears `syncLockToken`, and the escalated attempt would find the
106+
* row still `syncing` and skip. The stale-lock reaper owns that recovery.
107+
*/
108+
machine: 'large-1x',
102109
retry: {
103110
maxAttempts: 3,
104111
factor: 2,

apps/sim/background/knowledge-processing.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ export async function runDocumentProcessing(
135135
export const processDocument = task({
136136
id: 'knowledge-process-document',
137137
maxDuration: envNumber(env.KB_CONFIG_MAX_DURATION, 600),
138-
machine: 'large-1x', // 4 vCPU, 8GB RAM - needed for large PDF processing
138+
/**
139+
* Sized from production telemetry: peak sampled RSS 902 MB and peak 1.2 vCPU
140+
* across a corpus where no document exceeded 2 GB, so `medium-2x` holds ~4x
141+
* memory and ~1.7x CPU headroom over the observed worst case. The prior
142+
* `large-1x` reserved 8 GB against a worst case using an eighth of it.
143+
*/
144+
machine: 'medium-2x',
139145
retry: {
140146
maxAttempts: envNumber(env.KB_CONFIG_MAX_ATTEMPTS, 3),
141147
factor: envNumber(env.KB_CONFIG_RETRY_FACTOR, 2),

0 commit comments

Comments
 (0)