Generally logging to console takes "a lot" of resources since the process function is executed (depending on your chosen sample rate) every ~2,67ms (48kHz). The render quantum is 128 samples. Then also try not to use set(), instead opt for a for loop. Doesn't make much difference in regular code but the extra bit of overhead from a function call like that might slow things down just enough to lose some samples. I found that at times the process function execution can take longer than the time frame given by the sample rate so that loss of samples occurs.