The periodic slowdown is most likely caused, if your data loading pipeline is too slow for the training loop.
In fact it doesn’t seem as if you are profiling the DataLoader in a real use case (with model training), but as a standalone application.
If you are using multiple workers, each process will load a batch and add it to the queue.
Once a batch is ready to be consumed, the DataLoader loop moves forward and the model training can be performed. In the background all workers will load the next batch (the number of prefetched batches is defined by the prefetch_factor and is set to 2*num_workers by default).
If all workers are able to load a batch in approx. the same amount of time, the DataLoader loop would have num_workers batches to consume.
Since you don’t have any workload in this loop (again, no model training), the script just executes the loop and has to wait until the next batch is ready, i.e. until one of the workers has loaded a complete batch, and the slowdown is visible.