Skip to content
Mementropy
Lab NotesHomelab notebookField note

Hindsight recall went from 31.6 seconds to 2.4 seconds

The reranker had too many threads for its CPU limit.

By Ryan Hammang

Today I moved Hindsight, the memory service my agents use, onto the Dell K3s cluster. Then recall got slow.

First the data. I restored its pg_dump into a pgvector Postgres 18 StatefulSet and compared row counts on all 24 tables. They all matched, including 15,471 memory units and 672,823 memory links.

Then the first recall on the new cluster took 31.6 seconds.

The log broke it down:

  • query embedding: 25 ms
  • retrieval: 322 ms
  • reranking: 300 candidates scored in 31.225s

Reranking was 98.9% of the time. The cross-encoder reranker was running 8 OpenMP threads inside a 2-CPU limit, so the threads fought over too little CPU. It was also scoring 300 candidates with no batching by length.

I changed:

  • CPU limit from 2000m to 6000m
  • OMP_NUM_THREADS=6 and MKL_NUM_THREADS=6
  • bucket batching on for the reranker
  • maximum candidates to 64

Warm recall went to 2.40 seconds. That’s 13.2 times faster.

I changed four things at once, so I don’t know how much each one did. I’d like to find out. Has anyone tuned a CPU reranker in Kubernetes?

Recipes written later from this work: