OSDN Git Service

[opt-viewer] Reduce memory consumption by another 20-25%
authorAdam Nemet <anemet@apple.com>
Wed, 19 Jul 2017 22:04:59 +0000 (22:04 +0000)
committerAdam Nemet <anemet@apple.com>
Wed, 19 Jul 2017 22:04:59 +0000 (22:04 +0000)
commitb2613733b11115c14da51a0cfaf50c27a59cdbd9
tree270009836824bd55a8773cb396c6100d74e251be
parent8de343050445595da224db5615d16229db8f112a
[opt-viewer] Reduce memory consumption by another 20-25%

The Args field of the remark which consists of a list of mappings in YAML is
translated into a list of (small) dicts on Python.  An empty dict is 280 bytes
on my system so we can save memory by using a tuple of tuples instead.

Making a tuple of tuples rather than a list of tuples allows Args to be shared
with the key of the remark.  This is actually an even greater saving. (Keys
are alive throughout the entire run in all_remarks.)

Here are a few opt-stats runs with different input sizes while measuring heap
usage with heapy.  Avg remark size is simply estimated as
heap-size / # of remarks:

  | # of files             |   60 |  114 |  308 |  605 | 1370 |
  | # of remarks           |  20K |  37K | 146K | 180K | 640K |
  | total file size (MB)   |   22 |   51 |  219 |  202 | 1034 |
  |------------------------+------+------+------+------+------|
  | Avg remark size before | 4339 | 4792 | 4761 | 4096 | 4607 |
  | Avg remark size after  | 3446 | 3641 | 3567 | 3146 | 3347 |
  | Rate                   | 0.79 | 0.76 | 0.75 | 0.77 | 0.73 |

Differential Revision: https://reviews.llvm.org/D35611

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308538 91177308-0d34-0410-b5e6-96231b3b80d8
tools/opt-viewer/opt-diff.py
tools/opt-viewer/opt-viewer.py
tools/opt-viewer/optrecord.py