]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/memory/memory_util.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
8 #include "rocksdb/utilities/memory_util.h"
10 #include "db/db_impl.h"
14 Status
MemoryUtil::GetApproximateMemoryUsageByType(
15 const std::vector
<DB
*>& dbs
,
16 const std::unordered_set
<const Cache
*> cache_set
,
17 std::map
<MemoryUtil::UsageType
, uint64_t>* usage_by_type
) {
18 usage_by_type
->clear();
21 for (auto* db
: dbs
) {
23 if (db
->GetAggregatedIntProperty(DB::Properties::kSizeAllMemTables
,
25 (*usage_by_type
)[MemoryUtil::kMemTableTotal
] += usage
;
27 if (db
->GetAggregatedIntProperty(DB::Properties::kCurSizeAllMemTables
,
29 (*usage_by_type
)[MemoryUtil::kMemTableUnFlushed
] += usage
;
34 for (auto* db
: dbs
) {
36 if (db
->GetAggregatedIntProperty(DB::Properties::kEstimateTableReadersMem
,
38 (*usage_by_type
)[MemoryUtil::kTableReadersTotal
] += usage
;
43 for (const auto* cache
: cache_set
) {
44 if (cache
!= nullptr) {
45 (*usage_by_type
)[MemoryUtil::kCacheTotal
] += cache
->GetUsage();
51 } // namespace rocksdb
52 #endif // !ROCKSDB_LITE