optimize sync of periodic function