Minimizing page faults (and TLB faults) while “walking” a large graph

前端 未结 3 1335
情话喂你
情话喂你 2021-01-15 21:55

Problem (think of the mark phase of a GC)

  • I have a graph of “objects” that I need to walk, visiting all objects.
  • I can store in each object if it has
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-15 22:24

    These are my first thoughts about a possible solution, they are clearly not optimal. I will delete this answer if someone posts a better answer.

    The basic method:

    • Assume we have a Set nodesToVisit that contains all nodes we have not yet visited.

    • We remove one item at a time from nodesToVisit,

      • and if it has not been visited before we add all “pointers to other nodes” to nodesToVisit.

    Improvements:

    But we can clearly do better, by ordering nodesToVisit based on address, so that we are more likely to visit nodes that are contained in pages we have recently accessed. This could be as simple as having a second Set nodesToVisitLater, and putting any node that has an address a long way from the current node into it.

    Or we could skip over any node that are contained in pages that are not resident in memory, visiting these nodes after we have visited all nodes that are currently in memory.

    (The"set" could just be a stack, as visiting a node more than once is a "no-opp")


    https://patents.google.com/patent/US7653797B1/en seems to be related, but I have not read it yet. https://hosking.github.io/links/Cher+2004ASPLOS.pdf https://people.cs.umass.edu/~emery/pubs/cramm.pdf https://people.cs.umass.edu/~emery/pubs/f034-hertz.pdf https://people.cs.umass.edu/~emery/pubs/04-16.pdf

提交回复
热议问题