def _fill_world(dump, bucket_set, sorters, world):
    root = OrderedDict()

    root['name'] = world
    if world == 'vm':
      root['unit_fields'] = ['size', 'reserved']
    elif world == 'malloc':
      root['unit_fields'] = ['size', 'alloc_count', 'free_count']

    # Make { vm | malloc } units with their sizes.
    root['units'] = OrderedDict()
    unit_set = UnitSet(world)
    if world == 'vm':
      for unit in CatCommand._iterate_vm_unit(dump, None, bucket_set):
        unit_set.append(unit)
      for unit in unit_set:
        root['units'][unit.unit_id] = [unit.committed, unit.reserved]
    elif world == 'malloc':
      for unit in CatCommand._iterate_malloc_unit(dump, bucket_set):
        unit_set.append(unit)
      for unit in unit_set:
        root['units'][unit.unit_id] = [
            unit.size, unit.alloc_count, unit.free_count]

    # Iterate for { vm | malloc } sorters.
    root['breakdown'] = OrderedDict()
    for sorter in sorters.iter_world(world):
      breakdown = OrderedDict()
      for unit in unit_set:
        found = sorter.find(unit)
        if found.name not in breakdown:
          category = OrderedDict()
          category['name'] = found.name
          category['color'] = 'random'
          subs = []
          for sub_world, sub_breakdown in found.iter_subs():
            subs.append([sub_world, sub_breakdown])
          if subs:
            category['subs'] = subs
          if found.hidden:
            category['hidden'] = True
          category['units'] = []
          breakdown[found.name] = category
        breakdown[found.name]['units'].append(unit.unit_id)
      root['breakdown'][sorter.name] = breakdown

    return root
Example #2
0
  def _fill_world(dump, bucket_set, sorters, world):
    root = OrderedDict()

    root['name'] = world
    if world == 'vm':
      root['unit_fields'] = ['size', 'reserved']
    elif world == 'malloc':
      root['unit_fields'] = ['size', 'alloc_count', 'free_count']

    # Make { vm | malloc } units with their sizes.
    root['units'] = OrderedDict()
    unit_set = UnitSet(world)
    if world == 'vm':
      for unit in CatCommand._iterate_vm_unit(dump, None, bucket_set):
        unit_set.append(unit)
      for unit in unit_set:
        root['units'][unit.unit_id] = [unit.committed, unit.reserved]
    elif world == 'malloc':
      for unit in CatCommand._iterate_malloc_unit(dump, bucket_set):
        unit_set.append(unit)
      for unit in unit_set:
        root['units'][unit.unit_id] = [
            unit.size, unit.alloc_count, unit.free_count]

    # Iterate for { vm | malloc } sorters.
    root['breakdown'] = OrderedDict()
    for sorter in sorters.iter_world(world):
      LOGGER.info('  Sorting with %s:%s.' % (sorter.world, sorter.name))
      breakdown = OrderedDict()
      for rule in sorter.iter_rule():
        category = OrderedDict()
        category['name'] = rule.name
        subs = []
        for sub_world, sub_breakdown in rule.iter_subs():
          subs.append([sub_world, sub_breakdown])
        if subs:
          category['subs'] = subs
        if rule.hidden:
          category['hidden'] = True
        category['units'] = []
        breakdown[rule.name] = category
      for unit in unit_set:
        found = sorter.find(unit)
        if found:
          # Note that a bucket which doesn't match any rule is just dropped.
          breakdown[found.name]['units'].append(unit.unit_id)
      root['breakdown'][sorter.name] = breakdown

    return root
Example #3
0
    def _fill_world(dump, bucket_set, sorters, world):
        root = OrderedDict()

        root['name'] = world
        if world == 'vm':
            root['unit_fields'] = ['size', 'reserved']
        elif world == 'malloc':
            root['unit_fields'] = ['size', 'alloc_count', 'free_count']

        # Make { vm | malloc } units with their sizes.
        root['units'] = OrderedDict()
        unit_set = UnitSet(world)
        if world == 'vm':
            for unit in CatCommand._iterate_vm_unit(dump, None, bucket_set):
                unit_set.append(unit)
            for unit in unit_set:
                root['units'][unit.unit_id] = [unit.committed, unit.reserved]
        elif world == 'malloc':
            for unit in CatCommand._iterate_malloc_unit(dump, bucket_set):
                unit_set.append(unit)
            for unit in unit_set:
                root['units'][unit.unit_id] = [
                    unit.size, unit.alloc_count, unit.free_count
                ]

        # Iterate for { vm | malloc } sorters.
        root['breakdown'] = OrderedDict()
        for sorter in sorters.iter_world(world):
            breakdown = OrderedDict()
            for unit in unit_set:
                found = sorter.find(unit)
                if found.name not in breakdown:
                    category = OrderedDict()
                    category['name'] = found.name
                    category['color'] = 'random'
                    subs = []
                    for sub_world, sub_breakdown in found.iter_subs():
                        subs.append([sub_world, sub_breakdown])
                    if subs:
                        category['subs'] = subs
                    if found.hidden:
                        category['hidden'] = True
                    category['units'] = []
                    breakdown[found.name] = category
                breakdown[found.name]['units'].append(unit.unit_id)
            root['breakdown'][sorter.name] = breakdown

        return root