Repository navigation
perf(daemon): bound SQLite cache pressure (#2172) - #2173
Conversation
Problem: live daemon evidence after the pytest harness fix showed service-level memory dominated by cgroup file cache, not retained Python heap. Several small daemon/ops paths still used the batch-ingest SQLite write profile, and heartbeat counts opened write-profile connections for read-only probes.\n\nWhat changed: add a smaller daemon write profile, move small ops and maintenance writes onto it, move recurring read-only daemon probes to read-only connections, and document the profile split. Focused tests cover real pragma application and heartbeat read-only behavior.\n\nCloses #2172
|
Warning Review limit reached
More reviews will be available in 44 minutes and 11 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Bound daemon-side SQLite cache pressure by separating long-running daemon/ops writes from the batch-ingest write profile, and by moving recurring daemon read probes onto the read-only profile.
Problem
The live memory snapshot after #2171 showed a different pressure shape from the pytest harness issue:
polylogued.servicewas near 950 MiB current cgroup memory with a 2.9 GiB peak, but the daemon process itself was only about 235 MiB PSS.memory.statattributed most current usage to file cache rather than anonymous heap. Several daemon loops still opened the full write profile for small ops/maintenance work, and heartbeat counts opened a write-profile connection for read-only counts.Solution
Added an explicit daemon write profile in
polylogue/storage/sqlite/connection_profile.pywith a 16 MiB SQLite cache and 64 MiB mmap allowance, leaving the existing 128 MiB / 1 GiB batch-ingest write profile untouched. Moved small daemon/ops writes (daemon_events, cursor-lag samples, embedding catch-up rows, OTLP telemetry, daily optimize) toopen_daemon_connection, and moved heartbeat plus two ops health probes toopen_readonly_connection.The existing status/metrics memory reporting already distinguishes RSS, cgroup current/peak, cgroup file, and inactive file, so this change relies on that live observability rather than adding another reporting layer.
Verification
devtools test tests/unit/storage/test_wal_journal_size_limit.py::test_daemon_write_profile_uses_bounded_cache_and_mmap tests/unit/storage/test_wal_journal_size_limit.py::test_open_daemon_connection_applies_bounded_cache_and_mmap tests/unit/daemon/test_daemon_cli.py::test_daemon_cli_heartbeat_counts_uses_read_only_probe tests/unit/daemon/test_daemon_cli.py::test_daemon_cli_heartbeat_counts_archive tests/unit/daemon/test_cursor_lag_baseline.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_otlp_receiver.py tests/unit/daemon/test_metrics_endpoint.py::TestFormatMetricsReadsArchiveState::test_fts_freshness_and_memory_state— 46 passed.devtools verify --quick— exit 0.devtools verify— run20260619T163716Z-testmon-1662720-33dfc22a; 505 passed in 256.73s, selected_count=1247, peak_tree_pss=2813.7 MiB, diagnosis=pytest_passed.Closes #2172