tools/memory/partition_allocator/trace_utils.py
def _GetAllocatorDumps(trace: dict) -> list:
  """Takes in a trace (as returned from |LoadTrace|), and returns the parts
  of it related to the allocators.

  Args:
    trace: Trace content as returned by LoadTrace.

  Returns:
    The parts of the trace related to allocator metrics. Note that these
    entries are taken as-is from the trace.

    Each entry of the return value has
    the following format. The important field here is 'args', but there are
    other unimportant ones as well (shown with ...):
    {
      'args': {
        'dumps': {
          'allocators': dict[str, dict],
          'allocator_graph': list[dict],
          'level_of_detail': 'detailed'
        }
      },
      ...
    }

    Of the fields listed above, we mainly care about 'allocators'. Each entry
    here corresponds to an allocator or a subset of the allocations for a given
    allocator. For example, we have an entry in 'allocators' with key
    'malloc/partitions/allocator/buckets/bucket_1024', which corresponds to the
    1024 byte bucket of PartitionAlloc's main malloc partition.

    Note that in the trace, we have entries for allocators besides just
    PartitionAlloc, but in these scripts, we will only be looking at entries
    for PartitionAlloc allocators.

    Each entry of 'allocators' has the
    following format:
    {
      'attrs': dict[str, dict],
      'guid': str
    }

    The contents of 'attrs' varies depending on which entry we are looking at,
    but generally contains all the relevant information we need for a
    particular allocator. The attributes we care about here are mainly:
    'allocated_objects_size', 'size', and 'slot_size'.

    Finally, each entry of 'attrs' has the following format:
    {
      'type': str,
      'units': str,
      'value': str
    }

    For example, in 'malloc/partitions/allocator/buckets/bucket_1024', 'attrs'
    has a 'allocated_objects_size' entry, which might look like so:
    {
      'type': 'scalar',
      'units': 'bytes',
      'value': 'ef8000'
    }

    The entry we care about here is 'value', which is a string representing a
    hexadecimal number.
  """
  events = trace['traceEvents']
  memory_infra_events = [
      e for e in events if e['cat'] == 'disabled-by-default-memory-infra'
  ]
  dumps = [
      e for e in memory_infra_events
      if e['name'] == 'periodic_interval' and e['args']['dumps']
      ['level_of_detail'] == 'detailed' and 'allocators' in e['args']['dumps']
  ]
  return dumps
Takes in a trace (as returned from |LoadTrace|), and returns the parts
  of it related to the allocators.

  Args:
    trace: Trace content as returned by LoadTrace.

  Returns:
    The parts of the trace related to allocator metrics. Note that these
    entries are taken as-is from the trace.

    Each entry of the return value has
    the following format. The important field here is 'args', but there are
    other unimportant ones as well (shown with ...):
    {
      'args': {
        'dumps': {
          'allocators': dict[str, dict],
          'allocator_graph': list[dict],
          'level_of_detail': 'detailed'
        }
      },
      ...
    }

    Of the fields listed above, we mainly care about 'allocators'. Each entry
    here corresponds to an allocator or a subset of the allocations for a given
    allocator. For example, we have an entry in 'allocators' with key
    'malloc/partitions/allocator/buckets/bucket_1024', which corresponds to the
    1024 byte bucket of PartitionAlloc's main malloc partition.

    Note that in the trace, we have entries for allocators besides just
    PartitionAlloc, but in these scripts, we will only be looking at entries
    for PartitionAlloc allocators.

    Each entry of 'allocators' has the
    following format:
    {
      'attrs': dict[str, dict],
      'guid': str
    }

    The contents of 'attrs' varies depending on which entry we are looking at,
    but generally contains all the relevant information we need for a
    particular allocator. The attributes we care about here are mainly:
    'allocated_objects_size', 'size', and 'slot_size'.

    Finally, each entry of 'attrs' has the following format:
    {
      'type': str,
      'units': str,
      'value': str
    }

    For example, in 'malloc/partitions/allocator/buckets/bucket_1024', 'attrs'
    has a 'allocated_objects_size' entry, which might look like so:
    {
      'type': 'scalar',
      'units': 'bytes',
      'value': 'ef8000'
    }

    The entry we care about here is 'value', which is a string representing a
    hexadecimal number.
  
Takes in a trace (as returned from |LoadTrace|), and returns the parts
of it related to the allocators.
Takes in a trace ( as returned from |LoadTrace| ) and returns the parts of it related to the allocators .
def _GetAllocatorDumps(trace: dict) -> list:
  events = trace['traceEvents']
  memory_infra_events = [
      e for e in events if e['cat'] == 'disabled-by-default-memory-infra'
  ]
  dumps = [
      e for e in memory_infra_events
      if e['name'] == 'periodic_interval' and e['args']['dumps']
      ['level_of_detail'] == 'detailed' and 'allocators' in e['args']['dumps']
  ]
  return dumps
def _GetAllocatorDumps ( trace : dict ) -> list : events = trace [ 'traceEvents' ] memory_infra_events = [ e for e in events if e [ 'cat' ] == 'disabled-by-default-memory-infra' ] dumps = [ e for e in memory_infra_events if e [ 'name' ] == 'periodic_interval' and e [ 'args' ] [ 'dumps' ] [ 'level_of_detail' ] == 'detailed' and 'allocators' in e [ 'args' ] [ 'dumps' ] ] return dumps
Takes in a trace (as returned from |LoadTrace|), and returns the parts
of it related to the allocators.
Takes in a trace ( as returned from |LoadTrace| ) and returns the parts of it related to the allocators .
"""Takes in a trace (as returned from |LoadTrace|), and returns the parts
  of it related to the allocators.

  Args:
    trace: Trace content as returned by LoadTrace.

  Returns:
    The parts of the trace related to allocator metrics. Note that these
    entries are taken as-is from the trace.

    Each entry of the return value has
    the following format. The important field here is 'args', but there are
    other unimportant ones as well (shown with ...):
    {
      'args': {
        'dumps': {
          'allocators': dict[str, dict],
          'allocator_graph': list[dict],
          'level_of_detail': 'detailed'
        }
      },
      ...
    }

    Of the fields listed above, we mainly care about 'allocators'. Each entry
    here corresponds to an allocator or a subset of the allocations for a given
    allocator. For example, we have an entry in 'allocators' with key
    'malloc/partitions/allocator/buckets/bucket_1024', which corresponds to the
    1024 byte bucket of PartitionAlloc's main malloc partition.

    Note that in the trace, we have entries for allocators besides just
    PartitionAlloc, but in these scripts, we will only be looking at entries
    for PartitionAlloc allocators.

    Each entry of 'allocators' has the
    following format:
    {
      'attrs': dict[str, dict],
      'guid': str
    }

    The contents of 'attrs' varies depending on which entry we are looking at,
    but generally contains all the relevant information we need for a
    particular allocator. The attributes we care about here are mainly:
    'allocated_objects_size', 'size', and 'slot_size'.

    Finally, each entry of 'attrs' has the following format:
    {
      'type': str,
      'units': str,
      'value': str
    }

    For example, in 'malloc/partitions/allocator/buckets/bucket_1024', 'attrs'
    has a 'allocated_objects_size' entry, which might look like so:
    {
      'type': 'scalar',
      'units': 'bytes',
      'value': 'ef8000'
    }

    The entry we care about here is 'value', which is a string representing a
    hexadecimal number.
  """
The parts of the trace related to allocator metrics. Note that these
entries are taken as-is from the trace.

Each entry of the return value has
the following format. The important field here is 'args', but there are
other unimportant ones as well (shown with ...):
{
'args': {
'dumps': {
'allocators': dict[str, dict],
'allocator_graph': list[dict],
'level_of_detail': 'detailed'
}
},

}

Of the fields listed above, we mainly care about 'allocators'. Each entry
here corresponds to an allocator or a subset of the allocations for a given
allocator. For example, we have an entry in 'allocators' with key
'malloc/partitions/allocator/buckets/bucket_1024', which corresponds to the
1024 byte bucket of PartitionAlloc's main malloc partition.

Note that in the trace, we have entries for allocators besides just
PartitionAlloc, but in these scripts, we will only be looking at entries
for PartitionAlloc allocators.

Each entry of 'allocators' has the
following format:
{
'attrs': dict[str, dict],
'guid': str
}

The contents of 'attrs' varies depending on which entry we are looking at,
but generally contains all the relevant information we need for a
particular allocator. The attributes we care about here are mainly:
'allocated_objects_size', 'size', and 'slot_size'.

Finally, each entry of 'attrs' has the following format:
{
'type': str,
'units': str,
'value': str
}

For example, in 'malloc/partitions/allocator/buckets/bucket_1024', 'attrs'
has a 'allocated_objects_size' entry, which might look like so:
{
'type': 'scalar',
'units': 'bytes',
'value': 'ef8000'
}

The entry we care about here is 'value', which is a string representing a
hexadecimal number.
The parts of the trace related to allocator metrics . Note that these entries are taken as - is from the trace . Each entry of the return value has the following format . The important field here is ' args ' but there are other unimportant ones as well ( shown with ... ) : { ' args ' : { ' dumps ' : { ' allocators ' : dict [ str dict ] ' allocator_graph ' : list [ dict ] ' level_of_detail ' : ' detailed ' } } } Of the fields listed above we mainly care about ' allocators ' . Each entry here corresponds to an allocator or a subset of the allocations for a given allocator . For example we have an entry in ' allocators ' with key ' malloc / partitions / allocator / buckets / bucket_1024 ' which corresponds to the 1024 byte bucket of PartitionAlloc ' s main malloc partition . Note that in the trace we have entries for allocators besides just PartitionAlloc but in these scripts we will only be looking at entries for PartitionAlloc allocators . Each entry of ' allocators ' has the following format : { ' attrs ' : dict [ str dict ] ' guid ' : str } The contents of ' attrs ' varies depending on which entry we are looking at but generally contains all the relevant information we need for a particular allocator . The attributes we care about here are mainly : ' allocated_objects_size ' ' size ' and ' slot_size ' . Finally each entry of ' attrs ' has the following format : { ' type ' : str ' units ' : str ' value ' : str } For example in ' malloc / partitions / allocator / buckets / bucket_1024 ' ' attrs ' has a ' allocated_objects_size ' entry which might look like so : { ' type ' : ' scalar ' ' units ' : ' bytes ' ' value ' : ' ef8000 ' } The entry we care about here is ' value ' which is a string representing a hexadecimal number .
trace
dict
Trace content as returned by LoadTrace.
Trace content as returned by LoadTrace .