I conducted tests where three peers were randomly picked to apply a set of 500 or 1000 changes.
Using this patch, it took:
20-30 seconds to converge on 500 changes
70-80 seconds to converge on 1000 changes
Without this patch, it took:
17 minutes to converge on 500 changes
1000 changes ran for 5 hours and then crashed from lack of memory
The original code has two issues:
Does not stop processing once an answer is found.
Does not remember which nodes have been checked.
In a DAG that has many forks and merges, such as this test, those two
conditions meant that an extreme amount of time was spent repeatedly
searching the tree for a target node that was already found.
I conducted tests where three peers were randomly picked to apply a set of 500 or 1000 changes.
Using this patch, it took:
Without this patch, it took:
The original code has two issues:
In a DAG that has many forks and merges, such as this test, those two conditions meant that an extreme amount of time was spent repeatedly searching the tree for a target node that was already found.