I can see how it's slowing things down: glFinish make sure that every query are finished but the first query may have been finished a long time ago. This might create bubbles because of the PIL_sleep_ms.