You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a Graph of type graph.Graph[Resource, Resource] with a hash function that returns the original pointer to build a directed, acylic resource graph. Due to the nature of current implementation, each graph node contains exactly one edge to its parent resource, all the way to a root node.
With 4043 total resources (so v=4043, e=4042 as the root node does not connect to any parent), running inside a Docker on a M2 Pro mac, a Topological Sort using graph.TopologicalSort takes >1.5s (1.876445292s as a typical value), with a significant memory usage of >200M. Upon profiling the heap with pprof, the following is yield:
Memory snapshot for a single request that requires Topological Sorting:
I thought the excessive memory usage might have been caused by the fact that I'm using a struct and basically no hashing (which is, of course, more memory intensive); so I changed to graph.Graph[*Resource, *Resource]. While the below snapshot did not capture the exact memory usage at the moment, the memory allocation from the start of the program after a few request is:
Meanwhile, a naive implementation by keeping track of inEdgesCount for each vertex (using adjacentMap provided by graph) takes <20ms, with negligible memory footprint.
Using graph (as "github.com/dominikbraun/graph") v0.23.0.
The text was updated successfully, but these errors were encountered:
I'm using a Graph of type
graph.Graph[Resource, Resource]
with a hash function that returns the original pointer to build a directed, acylic resource graph. Due to the nature of current implementation, each graph node contains exactly one edge to its parent resource, all the way to aroot
node.With 4043 total resources (so v=4043, e=4042 as the root node does not connect to any parent), running inside a Docker on a M2 Pro mac, a Topological Sort using
graph.TopologicalSort
takes >1.5s (1.876445292s as a typical value), with a significant memory usage of >200M. Upon profiling the heap withpprof
, the following is yield:Memory snapshot for a single request that requires Topological Sorting:
I thought the excessive memory usage might have been caused by the fact that I'm using a struct and basically no hashing (which is, of course, more memory intensive); so I changed to
graph.Graph[*Resource, *Resource]
. While the below snapshot did not capture the exact memory usage at the moment, the memory allocation from the start of the program after a few request is:...well exceeding 300GB.
Meanwhile, a naive implementation by keeping track of inEdgesCount for each vertex (using adjacentMap provided by graph) takes <20ms, with negligible memory footprint.
Using graph (as "github.com/dominikbraun/graph") v0.23.0.
The text was updated successfully, but these errors were encountered: