diff options
author | David Blaikie <dblaikie@gmail.com> | 2017-07-06 19:00:12 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2017-07-06 19:00:12 +0000 |
commit | 450ef2ab9dc4f1297838f400d104408ffa2c02ba (patch) | |
tree | 4c1d128bf5840ffa0fae2d2c40be900f5be21f85 /unittests/ProfileData | |
parent | 812570f6d4a40e73aec77b295b5230280b465954 (diff) |
Prototype: Reduce llvm-profdata merge memory usage further
The InstrProfWriter already stores the name and hash of the record in
the nested maps it uses for lookup while merging - this data is
duplicated in the value within the maps.
Refactor the InstrProfRecord to use a nested struct for the counters
themselves so that InstrProfWriter can use this nested struct alone
without the name or hash duplicated there.
This work is incomplete, but enough to demonstrate the value (around a
50% decrease in memory usage for a large test case (10GB -> 5GB)).
Though most of that decrease is probably from removing the
SoftInstrProfError as well, but I haven't implemented a replacement for
it yet. (it needs to go with the counters, because the operations on the
counters - merging, etc, are where the failures are - unlike the
name/hash which are totally unused by those counter-related operations
and thus easy to split out)
Ongoing discussion about removing SoftInstrProfError as a field of the
InstrProfRecord is happening on the thread that added it - including
the possibility of moving back towards an earlier version of that
proposed patch that passed SoftInstrProfError through the various APIs,
rather than as a member of InstrProfRecord.
Reviewers: davidxl
Differential Revision: https://reviews.llvm.org/D34838
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ProfileData')
-rw-r--r-- | unittests/ProfileData/InstrProfTest.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/unittests/ProfileData/InstrProfTest.cpp b/unittests/ProfileData/InstrProfTest.cpp index 76f172a21b0..a5c9a828d52 100644 --- a/unittests/ProfileData/InstrProfTest.cpp +++ b/unittests/ProfileData/InstrProfTest.cpp @@ -225,7 +225,7 @@ static const char callee5[] = "callee5"; static const char callee6[] = "callee6"; TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write) { - InstrProfRecord Record1("caller", 0x1234, {1, 2}); + NamedInstrProfRecord Record1("caller", 0x1234, {1, 2}); // 4 value sites. Record1.reserveSites(IPVK_IndirectCallTarget, 4); @@ -269,7 +269,7 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write) { } TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) { - InstrProfRecord Record("caller", 0x1234, {1, 2}); + NamedInstrProfRecord Record("caller", 0x1234, {1, 2}); Record.reserveSites(IPVK_IndirectCallTarget, 1); InstrProfValueData VD0[] = {{1000, 1}, {2000, 2}, {3000, 3}, {5000, 5}, {4000, 4}, {6000, 6}}; @@ -365,7 +365,7 @@ TEST_P(MaybeSparseInstrProfTest, annotate_vp_data) { } TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_with_weight) { - InstrProfRecord Record1("caller", 0x1234, {1, 2}); + NamedInstrProfRecord Record1("caller", 0x1234, {1, 2}); // 4 value sites. Record1.reserveSites(IPVK_IndirectCallTarget, 4); @@ -408,7 +408,7 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_with_weight) { } TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_big_endian) { - InstrProfRecord Record1("caller", 0x1234, {1, 2}); + NamedInstrProfRecord Record1("caller", 0x1234, {1, 2}); // 4 value sites. Record1.reserveSites(IPVK_IndirectCallTarget, 4); @@ -456,8 +456,8 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_big_endian) { TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge1) { static const char caller[] = "caller"; - InstrProfRecord Record11(caller, 0x1234, {1, 2}); - InstrProfRecord Record12(caller, 0x1234, {1, 2}); + NamedInstrProfRecord Record11(caller, 0x1234, {1, 2}); + NamedInstrProfRecord Record12(caller, 0x1234, {1, 2}); // 5 value sites. Record11.reserveSites(IPVK_IndirectCallTarget, 5); @@ -577,7 +577,7 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge1_saturation) { ASSERT_EQ(InstrProfError::take(std::move(Result3)), instrprof_error::success); - InstrProfRecord Record4("baz", 0x5678, {3, 4}); + NamedInstrProfRecord Record4("baz", 0x5678, {3, 4}); Record4.reserveSites(IPVK_IndirectCallTarget, 1); InstrProfValueData VD4[] = {{uint64_t(bar), 1}}; Record4.addValueData(IPVK_IndirectCallTarget, 0, VD4, 1, nullptr); @@ -586,7 +586,7 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge1_saturation) { instrprof_error::success); // Verify value data counter overflow. - InstrProfRecord Record5("baz", 0x5678, {5, 6}); + NamedInstrProfRecord Record5("baz", 0x5678, {5, 6}); Record5.reserveSites(IPVK_IndirectCallTarget, 1); InstrProfValueData VD5[] = {{uint64_t(bar), Max}}; Record5.addValueData(IPVK_IndirectCallTarget, 0, VD5, 1, nullptr); @@ -619,8 +619,8 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge1_saturation) { TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge_site_trunc) { static const char caller[] = "caller"; - InstrProfRecord Record11(caller, 0x1234, {1, 2}); - InstrProfRecord Record12(caller, 0x1234, {1, 2}); + NamedInstrProfRecord Record11(caller, 0x1234, {1, 2}); + NamedInstrProfRecord Record12(caller, 0x1234, {1, 2}); // 2 value sites. Record11.reserveSites(IPVK_IndirectCallTarget, 2); @@ -686,12 +686,12 @@ static void addValueProfData(InstrProfRecord &Record) { } TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) { - InstrProfRecord SrcRecord("caller", 0x1234, {1ULL << 31, 2}); + InstrProfRecord SrcRecord({1ULL << 31, 2}); addValueProfData(SrcRecord); std::unique_ptr<ValueProfData> VPData = ValueProfData::serializeFrom(SrcRecord); - InstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2}); + InstrProfRecord Record({1ULL << 31, 2}); VPData->deserializeTo(Record, nullptr); // Now read data from Record and sanity check the data @@ -752,12 +752,12 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) { TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write_mapping) { - InstrProfRecord SrcRecord("caller", 0x1234, {1ULL << 31, 2}); + NamedInstrProfRecord SrcRecord("caller", 0x1234, {1ULL << 31, 2}); addValueProfData(SrcRecord); std::unique_ptr<ValueProfData> VPData = ValueProfData::serializeFrom(SrcRecord); - InstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2}); + NamedInstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2}); InstrProfSymtab Symtab; Symtab.mapAddress(uint64_t(callee1), 0x1000ULL); Symtab.mapAddress(uint64_t(callee2), 0x2000ULL); |