Closed totaloutput closed 5 years ago
In looking at this, the main reason for the slow-down is that the mutation bug between phantom.OrderDAG
and phantom.Graph.getVirtual
when using an order-cache has been fixed; Sync is slower now because OrderDAG
is doing work instead of skipping it.
Previously what would happen is:
OrderDAG
called
Graph.getVirtual
called on the dag's graph
getVirtual
would return a copy of the graph, with a new node, VIRTUAL, added at the tip. So if you had:
GENESIS <- A <- B
it would now be:
GENESIS <- A <- B <- VIRTUAL
Graph entries are pointers to nodes, so this new node entry would persist after OrderDAG
returned, even though getVirtual
was meant to be a temporary data structure.
If the height of the dag was tall enough, the node order and tips would be cached.
If the height of the dag is tall enough in subsequent calls to OrderDAG
, a previous cached entry would be returned. The tips of the cache-entry would be processed first, so if it was our previous entry tip B
would process in order: B
, VIRTUAL
.
The loop in OrderDAG
works bottom-up (from GENESIS if there's no cache hit) and stops sorting when it sees VIRTUAL
, so dag ordering would stop soon after it started and return. The returned order would be incomplete when using the order cache.
So no matter how many performance improvements we make, it'll never be quite as fast as it was before because the ordering work is being done now ^^.
phantom.Node
types, use map[*Node]struct{}
for parents
and children
fields instead of *nodeSet
.
nodeSet
, but it makes getAnticone
less deterministic, because the order that the dag is processed when colouring is not going to be as consistent. This means that between runs of OrderDAG
(like if soterd restarts) or between nodes, they may come up with slightly different orders.Graph.getPast
and Graph.getFuture
, define our own nodeList
type with push
, shift
, size
methods, instead of using collections/list
List
types.
collections/list
List
type, because we can have nodeList
methods not trigger as much garbage-collection.Node.id
comparison code from nodeSet
, orderedNodeSet
types.
calculateBlueSet
would cache each new VIRTUAL node that was created due to the getVirtual
call in OrderDAG
VIRTUAL
nodes aren't ever cached in blueSet
), this isn't useful anymore.nodeSet.contains()
callsminOrderCacheDistance
intervals, with a sliding-window for expiring old entries.The remaining perf improvement that I could try is:
getPast
and getFuture
in an LRU cacheImplemented optimizations in 33933489942c9211b9b02de17b4f05bb57229d7c.
The increased cache usage increases memory consumption, up to ~2GiB. We can use disk to store results instead of memory, if we want to drop soterd memory requirements down from this point.
with the latest changes at :https://github.com/soteria-dag/soterd/commit/2625c407441979b8d7c0045db75aff1e58cb96f6
the current bootstrap speed is slower than the previous version.. It use to be around couple thousand blocks for 5 minutes, now it's at about 500 blocks around the same time..