Skip to content

Commit

Permalink
stats: Remove field from GaugeImpl that was not used, by moving it to…
Browse files Browse the repository at this point in the history
… the counter-specific section. (#7477)

* Remove field from GaugeImpl that was not used, by moving it to the counter-specific section. (#7477)
Signed-off-by: Joshua Marantz <jmarantz@google.com>
  • Loading branch information
jmarantz authored Jul 9, 2019
1 parent 18e47ec commit 5e0130f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions source/common/stats/heap_stat_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ template <class BaseClass> class StatsSharedImpl : public MetricImpl<BaseClass>
protected:
HeapStatDataAllocator& alloc_;

// Holds backing store for both CounterImpl and GaugeImpl. This provides a level
// of indirection needed to enable stats created with the same name from
// different scopes to share the same value.
// Holds backing store shared by both CounterImpl and GaugeImpl. CounterImpl
// adds another field, pending_increment_, that is not used in Gauge.
std::atomic<uint64_t> value_{0};
std::atomic<uint64_t> pending_increment_{0};
std::atomic<uint16_t> flags_{0};
std::atomic<uint16_t> ref_count_{0};
};
Expand All @@ -113,8 +111,10 @@ class CounterImpl : public StatsSharedImpl<Counter> {
void inc() override { add(1); }
uint64_t latch() override { return pending_increment_.exchange(0); }
void reset() override { value_ = 0; }
bool used() const override { return flags_ & Flags::Used; }
uint64_t value() const override { return value_; }

private:
std::atomic<uint64_t> pending_increment_{0};
};

class GaugeImpl : public StatsSharedImpl<Gauge> {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/stats_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithStats) {
// 2019/06/17 7243 49412 49700 macros for exact/upper-bound memory checks
// 2019/06/29 7364 45685 46000 combine 2 levels of stat ref-counting into 1
// 2019/06/30 7428 42742 43000 remove stats multiple inheritance, inline HeapStatData
// 2019/07/06 7477 42742 43000 fork gauge representation to drop pending_increment_

// Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI
// 'release' builds, where we control the platform and tool-chain. So you
Expand All @@ -218,7 +219,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithStats) {
// On a local clang8/libstdc++/linux flow, the memory usage was observed in
// June 2019 to be 64 bytes higher than it is in CI/release. Your mileage may
// vary.
EXPECT_MEMORY_EQ(m_per_cluster, 42742);
EXPECT_MEMORY_EQ(m_per_cluster, 42742); // 104 bytes higher than a debug build.
EXPECT_MEMORY_LE(m_per_cluster, 43000);
}

Expand Down

0 comments on commit 5e0130f

Please sign in to comment.