# My prioritised replay buffer slows down my code massively

**URL:** <https://discuss.ray.io/t/my-prioritised-replay-buffer-slows-down-my-code-massively/8741>\
**Category:** RLlib\
**Created:** [December 21, 2022, 9:52am UTC](https://discuss.ray.io/t/my-prioritised-replay-buffer-slows-down-my-code-massively/8741 "2022-12-21T09:52:18Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [January 5, 2023, 4:59am UTC](https://discuss.ray.io/t/my-prioritised-replay-buffer-slows-down-my-code-massively/8741/3 "2023-01-05T04:59:15Z")

</div>

@kourosh,

He resolved his issue in the thread linked below.

I think the issue ended up being race conditions due to remote calls in a loop. The fix was to use ray.get as a synchronization barrier.

I have a feeling there might be something more fundamental going on for the core team to investigate but I cannot point to something more specific unfortunately.

> [@Code slows down when using prioritised replay buffer vs. vanilla replay buffer](https://discuss.ray.io/t/code-slows-down-when-using-prioritised-replay-buffer-vs-vanilla-replay-buffer/8757):
>
> I am using a distributed setup to train a DQN. When I used the following replay buffer, the code works perfectly fine: @ray.remote class ReplayBuffer: def \_\_init\_\_(self, capacity, batch\_size=128): self.capacity = capacity self.buffer = [] self.batch\_size = batch\_size def push(self, data): for experience in data: self.buffer.append(experience) def sample(self): return random.sample(self.buffer, self.batch\_size) def \_\_len\_\_(se…

---

_[View the full topic](https://discuss.ray.io/t/my-prioritised-replay-buffer-slows-down-my-code-massively/8741)._
