Say, I'm going to use 30 threads(40 cores CPU) to 4K random read the same file and do some computing.
These 30 threads don't share any objects except for fd
.
I initially wanted to open
once before starting the threading staff, and then in each thread, pread
(I knew the sequence of offsets in advance, and size of the sequence is 64, so there will be 64 pread
), pread
, pread
...
But a shared fd
seems to be deficient, because it will be used across 30 threads, hence a great lock-unlock time on pread
(it's an atomic operation, so there will be lock-unlock in its implementation).
Is it better to open
in each thread?