Skip to content

Commit 2e9532c

Browse files
Abseil Teamrogeeff
authored andcommitted
Export of internal Abseil changes
-- 5ed5dc9e17c66c298ee31cefc941a46348d8ad34 by Abseil Team <[email protected]>: Fix typo. PiperOrigin-RevId: 362040582 -- ac704b53a49becc42f77e4529d3952f8e7d18ce4 by Abseil Team <[email protected]>: Fix a typo in a comment. PiperOrigin-RevId: 361576641 -- d20ccb27b7e9b53481e9192c1aae5202c06bfcb1 by Derek Mauro <[email protected]>: Remove the inline keyword from functions that aren't defined in the header. This may fix #910. PiperOrigin-RevId: 361551300 -- aed9ae1dffa7b228dcb6ffbeb2fe06a13970c72b by Laramie Leavitt <[email protected]>: Propagate nice/strict/naggy state on absl::MockingBitGen. Allowing NiceMocks reduces the log spam for un-mocked calls, and it enables nicer setup with ON_CALL, so it is desirable to support it in absl::MockingBitGen. Internally, gmock tracks object "strictness" levels using an internal API; in order to achieve the same results we detect when the MockingBitGen is wrapped in a Nice/Naggy/Strict and wrap the internal implementation MockFunction in the same type. This is achieved by providing overloads to the Call() function, and passing the mock object type down into it's own RegisterMock call, where a compile-time check verifies the state and creates the appropriate mock function. PiperOrigin-RevId: 361233484 -- 96186023fabd13d01d32d60d9c7ac4ead1aeb989 by Abseil Team <[email protected]>: Ensure that trivial types are passed by value rather than reference PiperOrigin-RevId: 361217450 -- e1135944835d27f77e8119b8166d8fb6aa25f906 by Evan Brown <[email protected]>: Internal change. PiperOrigin-RevId: 361215882 -- 583fe6c94c1c2ef757ef6e78292a15fbe4030e35 by Evan Brown <[email protected]>: Increase the minimum number of slots per node from 3 to 4. We also rename kNodeValues (and related names) to kNodeSlots to make it clear that they are about the number of slots per node rather than the number of values per node - kMinNodeValues keeps the same name because it's actually about the number of values rather than the number of slots. Motivation: I think the expected number of values per node, assuming random insertion order, is the average of the maximum and minimum numbers of values per node (kNodeSlots and kMinNodeValues). For large and/or even kNodeSlots, this is ~75% of kNodeSlots, but for kNodeSlots=3, this is ~67% of kNodeSlots. kMinNodeValues (which corresponds to worst-case occupancy) is ~33% of kNodeSlots, when kNodeSlots=3, compared to 50% for even kNodeSlots. This results in higher memory overhead per value, and since this case (kNodeSlots=3) is used when values are large, it seems worth fixing. PiperOrigin-RevId: 361171495 GitOrigin-RevId: 5ed5dc9e17c66c298ee31cefc941a46348d8ad34 Change-Id: I8e33b5df1f987a77112093821085c410185ab51a
1 parent ab21820 commit 2e9532c

File tree

12 files changed

+171
-102
lines changed

12 files changed

+171
-102
lines changed

absl/base/thread_annotations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ namespace base_internal {
317317

318318
// Takes a reference to a guarded data member, and returns an unguarded
319319
// reference.
320-
// Do not used this function directly, use ABSL_TS_UNCHECKED_READ instead.
320+
// Do not use this function directly, use ABSL_TS_UNCHECKED_READ instead.
321321
template <typename T>
322322
inline const T& ts_unchecked_read(const T& v) ABSL_NO_THREAD_SAFETY_ANALYSIS {
323323
return v;

absl/container/btree_benchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <unordered_set>
2727
#include <vector>
2828

29+
#include "benchmark/benchmark.h"
2930
#include "absl/base/internal/raw_logging.h"
3031
#include "absl/container/btree_map.h"
3132
#include "absl/container/btree_set.h"
@@ -39,7 +40,6 @@
3940
#include "absl/strings/cord.h"
4041
#include "absl/strings/str_format.h"
4142
#include "absl/time/time.h"
42-
#include "benchmark/benchmark.h"
4343

4444
namespace absl {
4545
ABSL_NAMESPACE_BEGIN

absl/container/btree_test.cc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,13 +1193,13 @@ class BtreeNodePeer {
11931193
return btree_node<
11941194
set_params<ValueType, std::less<ValueType>, std::allocator<ValueType>,
11951195
/*TargetNodeSize=*/256, // This parameter isn't used here.
1196-
/*Multi=*/false>>::SizeWithNValues(target_values_per_node);
1196+
/*Multi=*/false>>::SizeWithNSlots(target_values_per_node);
11971197
}
11981198

1199-
// Yields the number of values in a (non-root) leaf node for this btree.
1199+
// Yields the number of slots in a (non-root) leaf node for this btree.
12001200
template <typename Btree>
1201-
constexpr static size_t GetNumValuesPerNode() {
1202-
return btree_node<typename Btree::params_type>::kNodeValues;
1201+
constexpr static size_t GetNumSlotsPerNode() {
1202+
return btree_node<typename Btree::params_type>::kNodeSlots;
12031203
}
12041204

12051205
template <typename Btree>
@@ -1458,7 +1458,7 @@ void ExpectOperationCounts(const int expected_moves,
14581458
TEST(Btree, MovesComparisonsCopiesSwapsTracking) {
14591459
InstanceTracker tracker;
14601460
// Note: this is minimum number of values per node.
1461-
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/3> set3;
1461+
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/4> set4;
14621462
// Note: this is the default number of values per node for a set of int32s
14631463
// (with 64-bit pointers).
14641464
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/61> set61;
@@ -1469,28 +1469,28 @@ TEST(Btree, MovesComparisonsCopiesSwapsTracking) {
14691469
std::vector<int> values =
14701470
GenerateValuesWithSeed<int>(10000, 1 << 22, /*seed=*/23);
14711471

1472-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set3)>(), 3);
1473-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set61)>(), 61);
1474-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set100)>(), 100);
1472+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set4)>(), 4);
1473+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set61)>(), 61);
1474+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set100)>(), 100);
14751475
if (sizeof(void *) == 8) {
1476-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<absl::btree_set<int32_t>>(),
1477-
BtreeNodePeer::GetNumValuesPerNode<decltype(set61)>());
1476+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<absl::btree_set<int32_t>>(),
1477+
BtreeNodePeer::GetNumSlotsPerNode<decltype(set61)>());
14781478
}
14791479

14801480
// Test key insertion/deletion in random order.
1481-
ExpectOperationCounts(45281, 132551, values, &tracker, &set3);
1481+
ExpectOperationCounts(56540, 134212, values, &tracker, &set4);
14821482
ExpectOperationCounts(386718, 129807, values, &tracker, &set61);
14831483
ExpectOperationCounts(586761, 130310, values, &tracker, &set100);
14841484

14851485
// Test key insertion/deletion in sorted order.
14861486
std::sort(values.begin(), values.end());
1487-
ExpectOperationCounts(26638, 92134, values, &tracker, &set3);
1487+
ExpectOperationCounts(24972, 85563, values, &tracker, &set4);
14881488
ExpectOperationCounts(20208, 87757, values, &tracker, &set61);
14891489
ExpectOperationCounts(20124, 96583, values, &tracker, &set100);
14901490

14911491
// Test key insertion/deletion in reverse sorted order.
14921492
std::reverse(values.begin(), values.end());
1493-
ExpectOperationCounts(49951, 119325, values, &tracker, &set3);
1493+
ExpectOperationCounts(54949, 127531, values, &tracker, &set4);
14941494
ExpectOperationCounts(338813, 118266, values, &tracker, &set61);
14951495
ExpectOperationCounts(534529, 125279, values, &tracker, &set100);
14961496
}
@@ -1507,9 +1507,9 @@ struct MovableOnlyInstanceThreeWayCompare {
15071507
TEST(Btree, MovesComparisonsCopiesSwapsTrackingThreeWayCompare) {
15081508
InstanceTracker tracker;
15091509
// Note: this is minimum number of values per node.
1510-
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/3,
1510+
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/4,
15111511
MovableOnlyInstanceThreeWayCompare>
1512-
set3;
1512+
set4;
15131513
// Note: this is the default number of values per node for a set of int32s
15141514
// (with 64-bit pointers).
15151515
SizedBtreeSet<MovableOnlyInstance, /*TargetValuesPerNode=*/61,
@@ -1524,28 +1524,28 @@ TEST(Btree, MovesComparisonsCopiesSwapsTrackingThreeWayCompare) {
15241524
std::vector<int> values =
15251525
GenerateValuesWithSeed<int>(10000, 1 << 22, /*seed=*/23);
15261526

1527-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set3)>(), 3);
1528-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set61)>(), 61);
1529-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<decltype(set100)>(), 100);
1527+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set4)>(), 4);
1528+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set61)>(), 61);
1529+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<decltype(set100)>(), 100);
15301530
if (sizeof(void *) == 8) {
1531-
EXPECT_EQ(BtreeNodePeer::GetNumValuesPerNode<absl::btree_set<int32_t>>(),
1532-
BtreeNodePeer::GetNumValuesPerNode<decltype(set61)>());
1531+
EXPECT_EQ(BtreeNodePeer::GetNumSlotsPerNode<absl::btree_set<int32_t>>(),
1532+
BtreeNodePeer::GetNumSlotsPerNode<decltype(set61)>());
15331533
}
15341534

15351535
// Test key insertion/deletion in random order.
1536-
ExpectOperationCounts(45281, 122560, values, &tracker, &set3);
1536+
ExpectOperationCounts(56540, 124221, values, &tracker, &set4);
15371537
ExpectOperationCounts(386718, 119816, values, &tracker, &set61);
15381538
ExpectOperationCounts(586761, 120319, values, &tracker, &set100);
15391539

15401540
// Test key insertion/deletion in sorted order.
15411541
std::sort(values.begin(), values.end());
1542-
ExpectOperationCounts(26638, 92134, values, &tracker, &set3);
1542+
ExpectOperationCounts(24972, 85563, values, &tracker, &set4);
15431543
ExpectOperationCounts(20208, 87757, values, &tracker, &set61);
15441544
ExpectOperationCounts(20124, 96583, values, &tracker, &set100);
15451545

15461546
// Test key insertion/deletion in reverse sorted order.
15471547
std::reverse(values.begin(), values.end());
1548-
ExpectOperationCounts(49951, 109326, values, &tracker, &set3);
1548+
ExpectOperationCounts(54949, 117532, values, &tracker, &set4);
15491549
ExpectOperationCounts(338813, 108267, values, &tracker, &set61);
15501550
ExpectOperationCounts(534529, 115280, values, &tracker, &set100);
15511551
}

0 commit comments

Comments
 (0)