diff options
author | 2022-02-03 08:46:25 -0800 | |
---|---|---|
committer | 2022-02-03 19:17:29 +0000 | |
commit | 36db0e4b695756c948dbb45568b43a62ba5883ec (patch) | |
tree | f19029c6f2e6b7da0ad196d5c98dbaed8292dc5a /absl/strings/cord_test.cc | |
parent | 5202173ca7671ebe241cb4d9447dc4b1f2d3ec10 (diff) |
Export of internal Abseil changes
--
4409b08e103d6e7041d18a4d431290cafe3650cf by Derek Mauro <dmauro@google.com>:
Workaround NVCC compile error in StringConstant
Based on a patch in TensorFlow:
https://github.com/tensorflow/tensorflow/blob/da83132aba8d2b6a3c3a9b2e662868eb24f4dd1e/third_party/absl/com_google_absl_fix_mac_and_nvcc_build.patch#L262-L282
Fixes #1105
PiperOrigin-RevId: 426156316
--
25db16567ffc5400dfaa30b567398ede84729687 by Abseil Team <absl-team@google.com>:
Only look for Elf64_Auxinfo on 64-bit FreeBSD.
PiperOrigin-RevId: 426132251
--
2e73c3d9df59b2b769d2b8dca97f0ca5c512c72a by Abseil Team <absl-team@google.com>:
Add a problem hint to the error message when dereferencing the end() iterator.
PiperOrigin-RevId: 426120394
--
6befbf89c47963656b9e8151166ab4c8446d4785 by Martijn Vels <mvels@google.com>:
Make Cord Btree the default and remove opt out machinery
This change makes btree the default Cord format and removes the machinery to opt out. Subsequent changes will remove the 'true' constant evaluation and effectively cleanup all old code and references to CONCAT.
PiperOrigin-RevId: 426119728
--
f6a0a664029d61811d90bd484f4eefa0400b5dd4 by Abseil Team <absl-team@google.com>:
Mark Notification::HasBeenNotified as ABSL_MUST_USE_RESULT
PiperOrigin-RevId: 425927033
GitOrigin-RevId: 4409b08e103d6e7041d18a4d431290cafe3650cf
Change-Id: I86f1052c63c13c6486baf4108de2554f162f9c40
Diffstat (limited to 'absl/strings/cord_test.cc')
-rw-r--r-- | absl/strings/cord_test.cc | 73 |
1 files changed, 2 insertions, 71 deletions
diff --git a/absl/strings/cord_test.cc b/absl/strings/cord_test.cc index e499b55f..c26e506d 100644 --- a/absl/strings/cord_test.cc +++ b/absl/strings/cord_test.cc @@ -231,15 +231,7 @@ ABSL_NAMESPACE_END // and with our without expected CRCs being set on the subject Cords. class CordTest : public testing::TestWithParam<int> { public: - CordTest() : was_btree_(absl::cord_internal::cord_btree_enabled.load()) { - absl::cord_internal::cord_btree_enabled.store(UseBtree()); - } - ~CordTest() override { - absl::cord_internal::cord_btree_enabled.store(was_btree_); - } - // Returns true if test is running with btree enabled. - bool UseBtree() const { return GetParam() == 1 || GetParam() == 3; } bool UseCrc() const { return GetParam() == 2 || GetParam() == 3; } void MaybeHarden(absl::Cord& c) { if (UseCrc()) { @@ -255,27 +247,19 @@ class CordTest : public testing::TestWithParam<int> { static std::string ToString(testing::TestParamInfo<int> param) { switch (param.param) { case 0: - return "Concat"; - case 1: return "Btree"; - case 2: - return "ConcatHardened"; - case 3: + case 1: return "BtreeHardened"; default: assert(false); return "???"; } } - - private: - const bool was_btree_; }; -INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Values(0, 1, 2, 3), +INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Values(0, 1), CordTest::ToString); - TEST(CordRepFlat, AllFlatCapacities) { // Explicitly and redundantly assert built-in min/max limits static_assert(absl::cord_internal::kFlatOverhead < 32, ""); @@ -1561,8 +1545,6 @@ TEST(CordTest, CordMemoryUsageFlatHardenedAndShared) { } TEST(CordTest, CordMemoryUsageBTree) { - absl::cord_internal::enable_cord_btree(true); - absl::Cord cord1; size_t flats1_size = 0; absl::Cord flats1[4] = {MakeCord(1000, 'a'), MakeCord(1100, 'a'), @@ -1611,57 +1593,6 @@ TEST(CordTest, CordMemoryUsageBTree) { rep2_size); } -TEST(CordTest, CordMemoryUsageConcat) { - absl::cord_internal::enable_cord_btree(false); - - absl::Cord cord1; - size_t flats1_size = 0; - absl::Cord flats1[4] = {MakeCord(1000, 'a'), MakeCord(1100, 'a'), - MakeCord(1200, 'a'), MakeCord(1300, 'a')}; - for (absl::Cord flat : flats1) { - flats1_size += absl::CordTestPeer::Tree(flat)->flat()->AllocatedSize(); - cord1.Append(std::move(flat)); - } - - // Make sure the created cord is a CONCAT tree. Under some builds such as - // windows DLL, we may have ODR like effects on the flag, meaning the DLL - // code will run with the picked up default. - if (!absl::CordTestPeer::Tree(cord1)->IsConcat()) { - ABSL_RAW_LOG(WARNING, "Cord library code not respecting btree flag"); - return; - } - - size_t rep1_size = sizeof(CordRepConcat) * 3 + flats1_size; - size_t rep1_shared_size = sizeof(CordRepConcat) * 3 + flats1_size / 2; - - EXPECT_EQ(cord1.EstimatedMemoryUsage(), sizeof(absl::Cord) + rep1_size); - EXPECT_EQ(cord1.EstimatedMemoryUsage(kFairShare), - sizeof(absl::Cord) + rep1_shared_size); - - absl::Cord cord2; - size_t flats2_size = 0; - absl::Cord flats2[4] = {MakeCord(600, 'a'), MakeCord(700, 'a'), - MakeCord(800, 'a'), MakeCord(900, 'a')}; - for (absl::Cord& flat : flats2) { - flats2_size += absl::CordTestPeer::Tree(flat)->flat()->AllocatedSize(); - cord2.Append(std::move(flat)); - } - - size_t rep2_size = sizeof(CordRepConcat) * 3 + flats2_size; - - EXPECT_EQ(cord2.EstimatedMemoryUsage(), sizeof(absl::Cord) + rep2_size); - EXPECT_EQ(cord2.EstimatedMemoryUsage(kFairShare), - sizeof(absl::Cord) + rep2_size); - - absl::Cord cord(cord1); - cord.Append(std::move(cord2)); - EXPECT_EQ(cord.EstimatedMemoryUsage(), - sizeof(absl::Cord) + sizeof(CordRepConcat) + rep1_size + rep2_size); - EXPECT_EQ(cord.EstimatedMemoryUsage(kFairShare), - sizeof(absl::Cord) + sizeof(CordRepConcat) + rep1_shared_size / 2 + - rep2_size); -} - // Regtest for a change that had to be rolled back because it expanded out // of the InlineRep too soon, which was observable through MemoryUsage(). TEST_P(CordTest, CordMemoryUsageInlineRep) { |