Skip to content

Embedding pegs all CPU cores on low-spec machines — make MEMEX_EMBED_THREADS default-capped (post-v0.1.2) #45

@sgwannabe

Description

@sgwannabe

Summary

On low-spec machines (e.g. an 8 GB M1 Air), embedding pegs every CPU core during indexing / watcher warm-up, causing UI lag. We have the knob to cap it, but it is opt-in and the released app does not ship it at all. This issue tracks turning it into a sane default in a future release.

Current state (verified)

  • fastembed defaults ONNX intra-op threads to available_parallelism() (all cores).
  • Our teammate contributed with_intra_threads upstream — feat: configurable ONNX Runtime intra-op thread count (with_intra_threads) Anush008/fastembed-rs#255, merged, shipped in fastembed 5.15.
  • main wires it as MEMEX_EMBED_THREADS (commit a0e7453, indexer::embed_intra_threads()), but it is opt-in: unset → fastembed's all-core default is left unchanged. So the default behavior still pegs all cores.
  • The released v0.1.2 binary pins fastembed 5.14 and predates a0e7453, so it has no cap at all — low-spec users have no workaround.
thread-cap code fastembed low-spec default
v0.1.2 (released) ❌ absent 5.14 pegs all cores, no escape
main / source ✅ present (opt-in) 5.15 pegs all cores unless MEMEX_EMBED_THREADS set

Proposal

When MEMEX_EMBED_THREADS is unset, default to a sane cap instead of all cores — e.g. max(1, available_parallelism() - 1) (or a lower cap on small core counts) — while keeping the explicit env override. Validate the indexing-throughput trade-off before changing the default.

Decision / scope

  • No release before the 2026-06-01 hackathon deadline. v0.1.2 is signed + notarized + on Homebrew and works; the release path has notarization flakiness (a v0.1.2 attempt failed before succeeding) and a manual Homebrew-cask sha bump, so re-cutting at the buzzer is not worth it.
  • The lag is a temporary CPU spike during indexing/warm-up (BGE-small is light), not a permanent freeze.
  • Address post-submission and ship the default-cap in the next release (v0.1.3).

References

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