When i call gldrawarrays with a large set of data will the function return only after drawing all the vertices or will it happen asynchronously b/w cpu and gpu?
Also how does vsync work. Aren't they related?
By calling glDrawArrays you queue that action in the GPU. It will get executed the next time you call glFlush which is also executed by the platform dependent SwapBuffers function.
VSync is a completely different thing. It synchronizes SwapBuffers with your monitors refresh rate to avoid 'tearing' artifacts. Tearing is when half of the screen was displayed with one frame and half of the screen with the next frame. This is perceived by the eye and can become ugly and annoying.
When you give any draw command. The function returns its value immediately in next tick. You give "gldrawarrays" it tells gpu to draw all stuff. Cpu goes to the next command, while gpu is still drawing. note that cpu doesn't pause for the gpu to complete the drawing process.
That's one of the reason why we use delay function at end of code. We tell cpu to wait until gpu completes drawing ( I don't know which language you you are using so i cannot tell you exactly which command delays.)