This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Analysis::writeSnippet(): be smarter about memory allocations.
ClosedPublic

Authored by lebedev.ri on Nov 10 2018, 1:11 PM.

Details

Summary

Test data: 500kLOC of benchmark.yaml, 23Mb. (that is a subset of the actual uops benchmark i was trying to analyze!)
Old time: (D54381)

$ time ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html &> /dev/null

real    0m10.487s
user    0m9.745s
sys     0m0.740s

New time:

$ time ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html &> /dev/null

real    0m9.599s
user    0m8.824s
sys     0m0.772s

Not that much, around -9%. But that is not the good part yet, again.

Old:

  • calls to allocation functions: 3347676
  • temporary allocations: 277818
  • bytes allocated in total (ignoring deallocations): 10.52 GB

New:

  • calls to allocation functions: 2109712 (-36%)
  • temporary allocations: 33112 (-88%)
  • bytes allocated in total (ignoring deallocations): 4.43 GB (-58% *sic*)

Diff Detail

Repository
rL LLVM

Event Timeline

lebedev.ri created this revision.Nov 10 2018, 1:11 PM
MaskRay accepted this revision.Nov 11 2018, 2:00 PM

// FIXME: magic number.

The owner should give you a reasonable capacity :)

This revision is now accepted and ready to land.Nov 11 2018, 2:00 PM

// FIXME: magic number.

The owner should give you a reasonable capacity :)

I will double-check later, but i think it is sufficient to avoid allocations here
for any single instruction (including it's operands).
(i.e. InstPrinterStr shouldn't ever need to be heap-allocated.)

courbet accepted this revision.Nov 19 2018, 1:58 AM

// FIXME: magic number.

The owner should give you a reasonable capacity :)

I will double-check later, but i think it is sufficient to avoid allocations here
for any single instruction (including it's operands).
(i.e. InstPrinterStr shouldn't ever need to be heap-allocated.)

Yep, SGTM.

...

Yep, SGTM.

Thank you for the reviews!