optimize buffer lock