Skip to content

ADR-054: lean indexer processes and a polite background summarizer (B-062, B-013) - #89

Merged
ethanblauw-hub merged 9 commits into
masterfrom
feature/adr-054-process-footprint
Oct 20, 2026
Merged

ethanblauw-hub merged 9 commits into
masterfrom
feature/adr-054-process-footprint

Conversation

@ethanblauw-hub

Copy link
Copy Markdown
Collaborator

Implements ADR-054 (backlog B-062, B-013).

What changes

  • OPENBLAS_NUM_THREADS defaults to 1 in every process, before numpy or faiss load (B-062).
    • A new leaf module, src/blas_threads.py, sets it with setdefault, so an explicit value still wins.
    • It is the first import of core.py, MCPServer.py, incremental_indexer.py, hybrid_retriever.py and model_host.py. Child processes inherit it.
  • The isolated summarizer worker runs at below-normal CPU priority (B-013). It sets os.nice(10) on POSIX and BELOW_NORMAL_PRIORITY_CLASS on Windows, in the pool initializer and before torch loads. If that fails, the failure is logged and the worker runs at normal priority.
  • The model host keeps normal priority. Query embeds go through its one thread, and a user waits on every one of them.
  • Lazy transformers imports were investigated and not built (§4). On transformers 4.53.3, AutoTokenizer loads torch anyway.
  • New tools/footprint_probe.py measures memory per import and flat-search timing.

Tests

  • Full suite: 727 passed, 2 skipped (Windows, CPU). flake8 clean. Conformance, resolution and L5X teeth baselines all hold.
  • The POSIX priority tests use monkeypatch.setattr(os, "nice", ..., raising=False), so they also run on Windows, which has no os.nice.
  • No MCP tool changed. The tools/list JSON is identical to the base's.

After merging: run pip install -e . again, because src/blas_threads.py is a new module and the live servers import src/.

Still open (left in the ADR)

  • Re-measure on Windows with tools/footprint_probe.py.
  • Host priority on the GPU.
  • A token counter that doesn't need torch.
  • Pinning faiss OMP threads per thread.

🤖 Generated with Claude Code

claude and others added 9 commits October 20, 2026 20:02
Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054]
OpenBLAS sizes its per-thread buffers when the library loads, so the
faiss.omp_set_num_threads(1) call in core came too late (B-062). A new
leaf module, blas_threads, defaults the variable to 1 with setdefault,
and core and every entry module import it first. A subprocess test
checks the variable's value at the moment numpy and faiss are first
looked up, for each entry point.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054 src/MCPServer.py src/blas_threads.py src/core.py src/hybrid_retriever.py src/incremental_indexer.py src/model_host.py]
The worker's initializer now drops its CPU priority before it loads
torch: os.nice(10) on POSIX, SetPriorityClass(BELOW_NORMAL) on Windows
(B-013). The model host keeps normal priority because its one thread
also embeds search queries.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054 src/summarizer.py]
Prints PrivateUsage on Windows or VmSize/VmRSS on Linux after each
import step, per OPENBLAS_NUM_THREADS setting, and times flat FAISS
search with --search, so B-062 can be re-measured with one command.

Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054]
Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054]
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

[ADR-054]
Co-Authored-By: Claude <noreply@anthropic.com>

[ADR-054]
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

[ADR-054]
@ethanblauw-hub
ethanblauw-hub merged commit 83cc582 into master Oct 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants