[PATCH] D35611: [opt-viewer] Reduce memory consumption by another 20-25%

Adam Nemet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 23:25:02 PDT 2017


anemet created this revision.
Herald added a subscriber: fhahn.

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 |


https://reviews.llvm.org/D35611

Files:
  tools/opt-viewer/opt-viewer.py
  tools/opt-viewer/optrecord.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35611.107255.patch
Type: text/x-patch
Size: 4622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/77099c77/attachment.bin>


More information about the llvm-commits mailing list