You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(kb): an idle backend sweeps every Redis fact about every 3 s (SCAN + HGETALL ×3,742 per 30 s) — keyword fallback with an unidentified caller #19726
While the system is idle, the backend sweeps every knowledge fact in Redis roughly every 3 seconds. This is a constant load that nobody asked for.
A 30 s Redis MONITOR sample on 2026-10-26 recorded 10 full sweeps of db 1, about one every 3 s:
137 × SCAN MATCH fact:* COUNT 100
138 × MULTI/EXEC
3,742 × HGETALL fact:<id>
That is all 514 facts, roughly 7 times per sweep. Everything came from a single backend connection. There were no writes, and no knowledge HTTP requests at the same time.
What is known
The pattern matches knowledge/search_components/keyword_search.py:212 → process_keyword_batch (:171-174): a SCAN with COUNT 100, then one pipelined HGETALL per page.
The caller that repeats every ~3 s has not been identified. The background vectorizer runs every 300 s (background_vectorization.py:42), so it does not fit. Candidates to rule in or out: a UI poll, a chat or agent loop issuing searches, and a health or metrics probe.
Acceptance criteria
The ~3 s caller is identified, with file:line, and recorded here.
An idle backend issues no fact:* sweep. A test or probe pins this.
Keyword fallback is bounded (an index or a cap) rather than a full HGETALL scan per query. The bound comes from config.
Host: a 30 s MONITOR sample on an idle node shows no HGETALL fact:* stream.
Measured on 2026-11-02 on the dev host, read-only.
The stream is live and heavier than filed: over 30 s, HGETALL rose by 39,572, about 1,300 a second, with 3,113 keys in db 1.
Where it came from now: the connections belong to the man-page indexer (index_all_man_pages.py, started by the tasks.refresh_system_knowledge Celery task), not the backend. It had run for over 8 hours at about 93% CPU, and 20 stack samples of the backend process showed no KB code. Stack samples of the indexer show recompute_corpus_stats (keyword_search.py:124).
Mechanism:_schedule_bm25_refresh (knowledge/facts.py:384) starts a new full recompute for each stored fact, without waiting for earlier ones.
Not established: whether the 2026-10-26 sample had this same cause. That sample recorded no writes and one connection; this one has several connections, and I didn't count writes. So the first criterion stays open until a sample with no indexer running is clean.
I didn't stop the running job. The fix is in the linked PR.
Re-measured the same day, after the indexer had ended: HGETALL rose by 0 over 20 s, with the backend still running and 3,113 keys in db 1. So today's stream was the indexer, and the backend alone produces none of it right now.
That is one 20 s sample, not the criterion's 30 s MONITOR, and it was taken before the fix is on any host. A sample after the next update still has to show the same. Whether the 2026-10-26 sample had this cause is still not established.
Verified against main at the merge train (PR #20707), merge 1416e3d202. Only boxes with code evidence are ticked.
AC
Evidence
The ~3 s caller is identified, with file:line, and recorded here.
NOT delivered. Not ticked. Comments on the issue trace a 2026-11-02 stream to the man-page indexer via _schedule_bm25_refresh (knowledge/facts.py, ~384) into recompute_corpus_stats (keyword_search.py:124), but the issue states it is not established that the 2026-10-26 ~3 s sample had that cause.
An idle backend issues no fact:* sweep. A test or probe pins this.
delivered. KeywordSearcher.request_refresh/_run_refreshes (keyword_search.py:163-185) recompute only when a write asked; test test_no_write_means_no_sweep in keyword_refresh_19726_test.py:46. Scope: the recompute path, not a search by a user.
Keyword fallback is bounded (an index or a cap) rather than a full HGETALL scan per query. The bound comes from config.
delivered. KEYWORD_SEARCH_MAX_SCAN = env_int_clamped("AUTOBOT_KB_KEYWORD_SEARCH_MAX_SCAN", 10000, ...) (keyword_search.py:32), applied at search (:255); test test_keyword_search_stops_at_the_configured_cap; env registered in autobot_shared/env_registry_knowledge.py. Note the default 10,000 exceeds the reported fact count.
Host: a 30 s MONITOR sample on an idle node shows no HGETALL fact:* stream.
NOT delivered. Not ticked: a host criterion, needs a 30 s MONITOR sample on an idle node after an update; a merge is not host evidence.
Host check on 2026-11-03 at 08:08 Riga, read-only, on the local node at 1416e3d202, which includes #20672. The deployed keyword_search.py and facts.py are byte-identical to that commit, the backend restarted at 07:36, and no man-page indexer is running.
A 30 s MONITOR sample: 686 commands, 0 HGETALL fact:* and 0 SCAN over fact:*. The rest is SCAN over other keys (412), PING, queue pops and GET, and the backend log shows only health and metrics requests in that time. The host criterion is ticked.
Still open: the first criterion. Today's caller was the indexer (recompute_corpus_stats, started per stored fact from knowledge/facts.py_schedule_bm25_refresh), but whether the 2026-10-26 sample had the same cause is still not established.
Activity
mrveiss commentedon Nov 2, 2026
Measured on 2026-11-02 on the dev host, read-only.
The stream is live and heavier than filed: over 30 s,
HGETALLrose by 39,572, about 1,300 a second, with 3,113 keys in db 1.Where it came from now: the connections belong to the man-page indexer (
index_all_man_pages.py, started by thetasks.refresh_system_knowledgeCelery task), not the backend. It had run for over 8 hours at about 93% CPU, and 20 stack samples of the backend process showed no KB code. Stack samples of the indexer showrecompute_corpus_stats(keyword_search.py:124).Mechanism:
_schedule_bm25_refresh(knowledge/facts.py:384) starts a new full recompute for each stored fact, without waiting for earlier ones.Not established: whether the 2026-10-26 sample had this same cause. That sample recorded no writes and one connection; this one has several connections, and I didn't count writes. So the first criterion stays open until a sample with no indexer running is clean.
I didn't stop the running job. The fix is in the linked PR.
mrveiss commentedon Nov 2, 2026
The fix is in #20672.
fix(kb): a failed recompute retries and a flush never cuts one off (#…
mrveiss commentedon Nov 2, 2026
Re-measured the same day, after the indexer had ended:
HGETALLrose by 0 over 20 s, with the backend still running and 3,113 keys in db 1. So today's stream was the indexer, and the backend alone produces none of it right now.That is one 20 s sample, not the criterion's 30 s
MONITOR, and it was taken before the fix is on any host. A sample after the next update still has to show the same. Whether the 2026-10-26 sample had this cause is still not established.mrveiss commentedon Nov 2, 2026
Verified against main at the merge train (PR #20707), merge
1416e3d202. Only boxes with code evidence are ticked._schedule_bm25_refresh(knowledge/facts.py, ~384) intorecompute_corpus_stats(keyword_search.py:124), but the issue states it is not established that the 2026-10-26 ~3 s sample had that cause.fact:*sweep. A test or probe pins this.KeywordSearcher.request_refresh/_run_refreshes(keyword_search.py:163-185) recompute only when a write asked; testtest_no_write_means_no_sweepinkeyword_refresh_19726_test.py:46. Scope: the recompute path, not a search by a user.KEYWORD_SEARCH_MAX_SCAN = env_int_clamped("AUTOBOT_KB_KEYWORD_SEARCH_MAX_SCAN", 10000, ...)(keyword_search.py:32), applied atsearch(:255); testtest_keyword_search_stops_at_the_configured_cap; env registered inautobot_shared/env_registry_knowledge.py. Note the default 10,000 exceeds the reported fact count.HGETALL fact:*stream.fix(kb): writes share one corpus-stats recompute instead of one each (m…
mrveiss commentedon Nov 3, 2026
Host check on 2026-11-03 at 08:08 Riga, read-only, on the local node at
1416e3d202, which includes #20672. The deployedkeyword_search.pyandfacts.pyare byte-identical to that commit, the backend restarted at 07:36, and no man-page indexer is running.A 30 s
MONITORsample: 686 commands, 0HGETALL fact:*and 0SCANoverfact:*. The rest isSCANover other keys (412),PING, queue pops andGET, and the backend log shows only health and metrics requests in that time. The host criterion is ticked.Still open: the first criterion. Today's caller was the indexer (
recompute_corpus_stats, started per stored fact fromknowledge/facts.py_schedule_bm25_refresh), but whether the 2026-10-26 sample had the same cause is still not established.