A per-file directory lookup from many threads on Lustre can block one run for about 100 s
Symptom#
A 16-thread index build over 14,117 files usually took 14 to 16 s. Some runs took 122 s (2 of about 12). A stack trace taken during a slow run showed all 16 workers inside the same lookup.
Cause#
The code looked for an optional folder next to the output once for every input file. That is 14,117 lookups from 16 threads at the same time. On Lustre, one of these lookups sometimes blocked for about 100 s. The lookup was cheap on a local disk, so the cost did not show there.
Fix#
Do the lookup once per output root, before the file loop, and pass the result in. Add a test that counts the lookups: for 24 files it counted 26 before the fix and 2 after.
Evidence#
After the fix, 20 of 20 runs at 16 threads took 14 to 16 s on the same data. Commit subject: fix(index): look for the schemas folder once per build, not once per file.
Also found by searching
- a parallel run on Lustre sometimes takes 120 s instead of 15 s
- all worker threads block in one filesystem lookup
- an existence check or stat repeated for every input file is slow on a shared filesystem
- why does one run in ten stall on Lustre