[profiler] Implement a new buffer reader/writer lock algorithm.