Poor performance of SafeSampler compared to the default sequential sampler
See original GitHub issueHi, I have been playing around with nonechucks a bit. I observed, that if I use SafeDataset
together with standard DataLoader
(using default sequential sampler), my CPUs are fully loaded. However, when I use the DataLoader
with SafeSampler
, then I see usually only one process running and the others are sleeping (probably waiting for synchronization). Could it be that in SafeSampler __next__()
method the threads needs to be synchronized due to the while loop? It is a really HUGE difference in performance between using and not using SafeSampler…
However, I understand that if I use DataLoader without SafeSampler, then the sampled examples can be returned several times, which is not usable in my case.
_Originally posted by @brejchajan in https://github.com/msamogh/nonechucks/issues/5#issuecomment-461499282_
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
I can confirm experiencing this issue as well. In my case, using 16 CPUs for the (safe) dataloader, time to run an epoch is quadrupled by using Safe Dataset/Sampler/DataLoader.
I don’t think there is any particular code which is needed to reproduce. Just iterate over a big enough dataset with enough cores to notice the benefit of using non-safe loading machinery.
I have my project which I cannot provide to public right now, but I will prepare a minimal code to reproduce this. Please, give me a few days for this.