Skip to content

Commit 3303390

Browse files
daverigbytrondn
authored andcommitted
Move HashTableDepthStatVisitor to it's own file
Move HashTableDepthStatVisitor from hash_table.h to its own file (hash_table_stat_visitor.h). This removes the need for hash_table.h to include utilities/hdrhistogram.h Change-Id: I7ab3f4fb0c27c360cdcb8d965ecc8fe8ccfffa53 Reviewed-on: http://review.couchbase.org/110226 Reviewed-by: Richard de Mellow <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 052ce4b commit 3303390

File tree

9 files changed

+62
-32
lines changed

9 files changed

+62
-32
lines changed

engines/ep/management/mc_bin_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,9 @@ def enable_xerror(self):
713713
def enable_collections(self):
714714
self.req_features.add(memcacheConstants.FEATURE_COLLECTIONS)
715715

716+
def enable_mutation_seqno(self):
717+
self.req_features.add(memcacheConstants.FEATURE_MUTATION_SEQNO)
718+
716719
def is_xerror_supported(self):
717720
return memcacheConstants.FEATURE_XERROR in self.features
718721

engines/ep/management/sync_repl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
client = mc_bin_client.MemcachedClient(host=host, port=port)
1717
client.enable_xerror()
18+
client.enable_mutation_seqno()
1819
client.hello("set_durable")
1920
client.sasl_auth_plain(user=sys.argv[2], password=sys.argv[3])
2021
client.bucket_select(sys.argv[4])

engines/ep/src/ep_engine.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "ext_meta_parser.h"
3636
#include "failover-table.h"
3737
#include "flusher.h"
38+
#include "hash_table_stat_visitor.h"
3839
#include "htresizer.h"
3940
#include "memory_tracker.h"
4041
#include "replicationthrottle.h"

engines/ep/src/hash_table.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "storeddockey.h"
2323

2424
#include <platform/non_negative_counter.h>
25-
#include <utilities/hdrhistogram.h>
2625

2726
#include <array>
2827
#include <functional>
@@ -1486,32 +1485,6 @@ class HashTableDepthVisitor {
14861485
virtual void visit(int bucket, int depth, size_t mem) = 0;
14871486
};
14881487

1489-
/**
1490-
* Hash table visitor that finds the min and max bucket depths.
1491-
*/
1492-
class HashTableDepthStatVisitor : public HashTableDepthVisitor {
1493-
public:
1494-
HashTableDepthStatVisitor() : size(0), memUsed(0), min(-1), max(0) {
1495-
}
1496-
1497-
void visit(int bucket, int depth, size_t mem) {
1498-
(void)bucket;
1499-
// -1 is a special case for min. If there's a value other than
1500-
// -1, we prefer that.
1501-
min = std::min(min == -1 ? depth : min, depth);
1502-
max = std::max(max, depth);
1503-
depthHisto.add(depth);
1504-
size += depth;
1505-
memUsed += mem;
1506-
}
1507-
1508-
Hdr1sfInt32Histogram depthHisto;
1509-
size_t size;
1510-
size_t memUsed;
1511-
int min;
1512-
int max;
1513-
};
1514-
15151488
/**
15161489
* Track the current number of hashtable visitors.
15171490
*
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2+
/*
3+
* Copyright 2019 Couchbase, Inc
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include "hash_table.h"
21+
#include <utilities/hdrhistogram.h>
22+
23+
/**
24+
* Hash table visitor that finds the min and max bucket depths.
25+
*/
26+
class HashTableDepthStatVisitor : public HashTableDepthVisitor {
27+
public:
28+
HashTableDepthStatVisitor() : size(0), memUsed(0), min(-1), max(0) {
29+
}
30+
31+
void visit(int bucket, int depth, size_t mem) {
32+
(void)bucket;
33+
// -1 is a special case for min. If there's a value other than
34+
// -1, we prefer that.
35+
min = std::min(min == -1 ? depth : min, depth);
36+
max = std::max(max, depth);
37+
depthHisto.add(depth);
38+
size += depth;
39+
memUsed += mem;
40+
}
41+
42+
Hdr1sfInt32Histogram depthHisto;
43+
size_t size;
44+
size_t memUsed;
45+
int min;
46+
int max;
47+
};

engines/ep/src/sizes.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "couch-kvstore/couch-kvstore.h"
2626
#include "dcp/response.h"
2727
#include "dcp/stream.h"
28+
#include "hash_table_stat_visitor.h"
2829
#include "item.h"
2930
#include "kvstore_priv.h"
3031
#include "persistence_callback.h"

engines/ep/src/vbucket.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "failover-table.h"
3333
#include "flusher.h"
3434
#include "hash_table.h"
35+
#include "hash_table_stat_visitor.h"
3536
#include "kvstore.h"
3637
#include "pre_link_document_context.h"
3738
#include "statwriter.h"
@@ -376,6 +377,12 @@ std::vector<const void*> VBucket::getCookiesForInFlightSyncWrites() {
376377
return getActiveDM().getCookiesForInFlightSyncWrites();
377378
}
378379

380+
size_t VBucket::size() {
381+
HashTableDepthStatVisitor v;
382+
ht.visitDepth(v);
383+
return v.size;
384+
}
385+
379386
VBucket::ItemsToFlush VBucket::getItemsToPersist(size_t approxLimit) {
380387
// Fetch up to approxLimit items from rejectQueue, backfill items and
381388
// checkpointManager (in that order); then check if we obtained everything

engines/ep/src/vbucket.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,7 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
528528
*/
529529
std::vector<const void*> getCookiesForInFlightSyncWrites();
530530

531-
size_t size(void) {
532-
HashTableDepthStatVisitor v;
533-
ht.visitDepth(v);
534-
return v.size;
535-
}
531+
size_t size();
536532

537533
size_t getBackfillSize() {
538534
return backfill.rlock()->items.size();

engines/ep/tests/module_tests/hash_table_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
#include "hash_table_test.h"
18+
#include "hash_table_stat_visitor.h"
1819
#include "item.h"
1920
#include "item_freq_decayer_visitor.h"
2021
#include "kv_bucket.h"

0 commit comments

Comments
 (0)