fix race condition in bench2 and performance issue in bench2