Run numpy's OpenBLAS on one thread, and keep it out of locate (#177) #178
Loading…
Reference in a new issue
No description provided.
Delete branch "blas-single-thread"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #177.
The fault
A few minutes after each start, the live app stops measuring where standbys are against the stream playing, for good. Every pair stays "pending", so no swap is aimed (#168). This has been on
mainsince #167. #172 only made it count, because aiming depends on the measurement.What the diagnostics of #175 and #176 showed:
sound.pylocate→numpy.linalg.norm→x.dot(x). That is a dot product in OpenBLAS (numpy 2.5.5, scipy-openblas 0.3.34). Its thread spun a core with no system call.Reproduced in the image, in a separate short Python with a 20 s limit. One thread runs that dot product in a loop while another starts child processes with
fork():OPENBLAS_NUM_THREADS=1The fix
backend/app/__init__.pysetsOPENBLAS_NUM_THREADS=1before anything imports numpy, keeping a value already set. TheDockerfilesets it for every Python in the image. The app's arrays are small, so one thread loses nothing.sound.locate: it takes the sample's norm with numpy's own sum. That was the only OpenBLAS call in the app.Checks
make test: 1,488 passed, 1 skipped. Three new tests:locatefinds its place withlinalg.normunavailable;apphasOPENBLAS_NUM_THREADS=1;latestis pushed.After the deploy
🤖 Generated with Claude Code