reenable perf optimization, fix race condition (#6405)
### Description
fixes a race condition with task dependencies
This was the problem:
There is a method that marks a task a dirty (e. g. when something has
changed).
This method changes the task state to dirty/scheduled and clears all
dependencies.
In detail it:
* gets a state lock
* changes the state
* pops dependencies from the state
* releases the state lock
* iterates over all dependencies and clears them
* That need to be outside of the lock, since we need to acquire locks of
other tasks.
The problem was that this introduces a race condition. After the state
lock has released, the scheduler might pick up the task for execution.
If it executes fast enough, the task might start reading from cells and
adds new dependencies. When this happens faster than clearing, it will
clear the new dependencies. This leads to missing dependency edges
between tasks and cause changes to not bubble correctly through the
graph.
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->
Closes TURBO-1919