Skip to content
Mementropy
RecipesHomelab recipesReference

Tuning the Hindsight reranker's CPU and threads on K3s

Match thread counts to the CPU limit and cap the candidates.

By Ryan Hammang

Slow recall in Hindsight when its local cross-encoder reranker runs under a Kubernetes CPU limit.

  1. Find where the time goes in the recall log. In this case:
[4] Reranking [cross-encoder]: 300 candidates scored in 31.225s
  1. Set the CPU limit and thread counts to match:
resources:
limits:
cpu: 6000m
env:
- {name: OMP_NUM_THREADS, value: "6"}
- {name: MKL_NUM_THREADS, value: "6"}
- {name: HINDSIGHT_API_RERANKER_LOCAL_BUCKET_BATCHING, value: "true"}
- {name: HINDSIGHT_API_RERANKER_MAX_CANDIDATES, value: "64"}
  1. Roll it out and repeat the same recall.

Warm recall went from 31.61 s to 2.40 s here.

  • More threads than the CPU limit allows means the threads fight over too little CPU.
  • These four changes were made together. Their separate effects weren’t measured.
  • Fewer candidates can change recall quality. Check results, not just speed.