ml-agents
ml-agents copied to clipboard
Is it better to use self.step_queue.get() than self.step_queue.get_nowait() in SubprocessEnvManager._step()?
I noticed the code in SubprocessEnvManager._step():
# Poll the step queue for completed steps from environment workers until we retrieve
# 1 or more, which we will then return as StepInfos
while len(worker_steps) < 1:
try:
while True:
step: EnvironmentResponse = self.step_queue.get_nowait()
...
How about modifying it to:
while not self.step_queue.empty() or len(worker_steps) == 0:
step: EnvironmentResponse = self.step_queue.get()
...
Why? Coz get_nowait() will not be blocked, it will always makes CPU running in a loop, 100% ocupy a CPU core even if no env_worker is ready; but get() will be blocked if no env_worker is ready, which leads less CPU usage. I think this will be more power-saving.
Am I correct? or there's something I've missed?
Thank you @Tyushang we will log this request and get back with you once we have investigated it
Any progress?