Skip to content

Main thread CPU pinning at 100%: aggressive SQLite polling in memory-tdai pipeline #155

@fdefilippo

Description

@fdefilippo

Description

When running as the context engine in OpenClaw v2026.6.1, the memory-tencentdb plugin (v0.3.6) causes the main Node.js thread to be pinned at 99.9% CPU usage permanently. Total CPU consumption across worker threads reaches ~150% on a single core.

Environment

  • OS: Oracle Linux Server 10.1
  • Node.js: v24.14.1
  • OpenClaw: 2026.6.1
  • Plugin: TencentDB-Agent-Memory v0.3.6
  • Memory: ~1.1 GB RSS consumed by the process

Symptoms

  1. Main thread is permanently at 99.9% CPU (state R - running)
  2. System load average stays above 2.0 even during idle periods
  3. Memory consumption stays at ~1.1GB RSS even when no user interaction is happening

Log Analysis

The memory-tdai pipeline performs frequent SQLite L1-queries across multiple commitment sessions. Each cycle shows:

  1. [memory-tdai][sqlite] [L1-query] — runs for each commitment session key every ~10-15 minutes
  2. [memory-tdai] [pipeline] [L2 cold-start skip] — consistently runs and skips (wasted I/O)
  3. [context-offload] [local-llm] — makes repeated calls to the configured model
  4. [memory-tdai] [recall] Strategy 'hybrid' requested but EmbeddingService not available, falling back to keyword — embedding service is not configured

Key observations

  • SQLite L1-queries run even when there are no new messages from any user
  • Multiple commitment sessions are being polled constantly (10+ different UUIDs observed)
  • The L2 pipeline cold-start runs every cycle even though it always skips because minInterval hasn't passed
  • No embedding service available causes fallback to keyword search on every recall

Expected behavior

The plugin should not consume CPU during idle periods. SQLite polling should have a configurable interval (or be event-driven rather than poll-driven). The L1 and L2 pipeline should not run when there are no new interactions to process.

Suggested investigation areas

  1. Polling interval: L1-query appears to run aggressively for each commitment session even when idle. Consider adding a configurable polling interval or switching to a trigger-based approach.
  2. Event loop blocking: Verify that all SQLite operations use async/promises and do not block the Node.js event loop.
  3. Cold-start cycles: L2 pipeline cold-start runs every cycle and always skips. Consider checking minInterval before triggering the pipeline query.
  4. Embedding service: When embedding service is unavailable, cache the strategy decision rather than falling back on every recall.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions