MemoryUsageTokenWith utility has problems

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The memory usage tracking provides a few utilities to make memory tracking easier:

      • a token class that increments memory in the constructor and decrements in the destructor
      • a "token with" helper class that bundles a type instance with a token for use in containers.

      The idea here is that for values that need to be inserted into a container like a map or set can have their memory count increased on insertion and then decremented when it's removed.

      There are a few issues with this approach:

      • For each element in containers that use the "token with" helper, there is an overhead of 16-bytes: a pointer to the memory usage tracker, and the size of the value to decrement when the destructor fires. This overhead is not itself counted in the memory tracker, so it makes the tracked memory metrics less accurate.
      • There is a performance penalty in using these, since it makes the containers bigger. When investigating a perf BF I was able to measure an improvement in a HVW when switching away from "token with" in a container.

      We use the "token with" utility class in several different places:

      • densify
      • accumulators:
        • bucketAuto
        • AccumulatorMinMaxN, AccumulatorFirstLastN
      • SpillableMap, SpillableDeque
      • Window functions
        • addToSet, concatArrays, etc

            Assignee:
            Unassigned
            Reporter:
            Chris Wolff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: