Skip to content

Memory Usage #5

@sebogh

Description

@sebogh

another stuff that over allocate memory (i'm run benchmark for 100000 count)

can we lower the memory usage?

ROUTINE ======================== github.com/heimdalr/dag.(*DAG).AddEdge in /home/vtolstov/.cache/go-path/pkg/mod/github.com/heimdalr/dag
@v0.9.11/dag.go
  252.53MB   596.07MB (flat, cum) 23.62% of Total
         .          .    179:   if d.isEdge(src, dst) {
         .          .    180:           return EdgeDuplicateError{src, dst}
         .          .    181:   }
         .          .    182:
         .          .    183:   // get descendents and ancestors as they are now
         .   149.02MB    184:   descendants, _ := d.GetDescendants(dst)
         .   194.52MB    185:   ancestors, _ := d.GetAncestors(src)
         .          .    186:
         .          .    187:   // check for circles, iff desired
         .          .    188:   if src == dst || descendants[src] {
         .          .    189:           return EdgeLoopError{src, dst}
         .          .    190:   }
         .          .    191:
         .          .    192:   d.muDAG.Lock()
         .          .    193:
         .          .    194:   // prepare d.outbound[src], iff needed
         .          .    195:   if _, exists := d.outboundEdge[src]; !exists {
   52.01MB    52.01MB    196:           d.outboundEdge[src] = make(map[Vertex]bool)
         .          .    197:   }
         .          .    198:
         .          .    199:   // dst is a child of src
   97.51MB    97.51MB    200:   d.outboundEdge[src][dst] = true
         .          .    201:
         .          .    202:   // prepare d.inboundEdge[dst], iff needed
         .          .    203:   if _, exists := d.inboundEdge[dst]; !exists {
   40.50MB    40.50MB    204:           d.inboundEdge[dst] = make(map[Vertex]bool)
         .          .    205:   }
         .          .    206:
         .          .    207:   // src is a parent of dst
   62.51MB    62.51MB    208:   d.inboundEdge[dst][src] = true
         .          .    209:
         .          .    210:   // for dst and all its descendants delete cached ancestors
         .          .    211:   for descendant := range descendants {
         .          .    212:           if _, exists := d.ancestorsCache[descendant]; exists {
         .          .    213:                   delete(d.ancestorsCache, descendant)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions