buffer: tune write loop