Skip to content

Commit c638bc7

Browse files
committed
Update MemTableSet for allocated_bytes
Signed-off-by: JaySon-Huang <[email protected]>
1 parent 0ee72d1 commit c638bc7

File tree

17 files changed

+36
-31
lines changed

17 files changed

+36
-31
lines changed

dbms/src/Common/CurrentMetrics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@
8888
M(ConnectionPoolSize) \
8989
M(MemoryTrackingQueryStorageTask) \
9090
M(MemoryTrackingFetchPages) \
91-
M(MemoryTrackingSharedColumnData)
91+
M(MemoryTrackingSharedColumnData) \
92+
M(NumSegments) \
93+
M(NumDeltaCache) \
94+
M(BytesDeltaCache)
9295

9396
namespace CurrentMetrics
9497
{

dbms/src/Common/CurrentMetrics.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <stddef.h>
1919

2020
#include <atomic>
21-
#include <cstdint>
2221
#include <utility>
2322

2423
/** Allows to count number of simultaneously happening processes or current value of some metric.

dbms/src/DataStreams/AsynchronousBlockInputStream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <Common/CurrentMetrics.h>
1817
#include <Common/MemoryTracker.h>
1918
#include <Common/wrapInvocable.h>
2019
#include <DataStreams/IProfilingBlockInputStream.h>

dbms/src/DataStreams/ParallelInputsProcessor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <Common/CurrentMetrics.h>
1817
#include <Common/Logger.h>
1918
#include <Common/MPMCQueue.h>
2019
#include <Common/MemoryTracker.h>
@@ -24,10 +23,6 @@
2423
#include <common/logger_useful.h>
2524

2625
#include <atomic>
27-
#include <list>
28-
#include <mutex>
29-
#include <queue>
30-
#include <thread>
3126

3227

3328
/** Allows to process multiple block input streams (sources) in parallel, using specified number of threads.

dbms/src/Dictionaries/CacheDictionary.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
#include <Columns/ColumnString.h>
1818
#include <Common/ArenaWithFreeLists.h>
19-
#include <Common/CurrentMetrics.h>
2019
#include <Dictionaries/DictionaryStructure.h>
2120
#include <Dictionaries/IDictionary.h>
2221
#include <Dictionaries/IDictionarySource.h>
2322

2423
#include <atomic>
2524
#include <chrono>
26-
#include <cmath>
2725
#include <ext/bit_cast.h>
2826
#include <map>
2927
#include <pcg_random.hpp>

dbms/src/Interpreters/ProcessList.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <Common/CurrentMetrics.h>
1817
#include <Common/MemoryTracker.h>
1918
#include <Common/Stopwatch.h>
2019
#include <Common/Throttler.h>

dbms/src/Interpreters/QueryPriorities.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <Common/CurrentMetrics.h>
1817
#include <Common/Stopwatch.h>
1918

2019
#include <chrono>

dbms/src/Server/TCPHandler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#pragma once
1616

1717
#include <Client/TimeoutSetter.h>
18-
#include <Common/CurrentMetrics.h>
1918
#include <Common/Stopwatch.h>
2019
#include <Common/getFQDNOrHostName.h>
2120
#include <Core/Protocol.h>

dbms/src/Storages/DeltaMerge/ColumnFile/ColumnFile.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ class ColumnFile
138138
/// been persisted in the disk and their data will be immutable.
139139
virtual bool isAppendable() const { return false; }
140140
virtual void disableAppend() {}
141-
virtual bool append(
141+
142+
struct AppendResult
143+
{
144+
bool success = false; // whether the append is successful
145+
size_t new_alloc_bytes = 0; // the new allocated bytes after append
146+
};
147+
virtual AppendResult append(
142148
const DMContext & /*dm_context*/,
143149
const Block & /*data*/,
144150
size_t /*offset*/,

dbms/src/Storages/DeltaMerge/ColumnFile/ColumnFileInMemory.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ ColumnFileReaderPtr ColumnFileInMemory::getReader(
6565
return std::make_shared<ColumnFileInMemoryReader>(*this, col_defs);
6666
}
6767

68-
bool ColumnFileInMemory::append(
68+
ColumnFile::AppendResult ColumnFileInMemory::append(
6969
const DMContext & context,
7070
const Block & data,
7171
size_t offset,
7272
size_t limit,
7373
size_t data_bytes)
7474
{
7575
if (disable_append)
76-
return false;
76+
return AppendResult{false, 0};
7777

7878
std::scoped_lock lock(cache->mutex);
7979
if (!isSameSchema(cache->block, data))
80-
return false;
80+
return AppendResult{false, 0};
8181

8282
// check whether this instance overflows
8383
if (cache->block.rows() >= context.delta_cache_limit_rows
8484
|| cache->block.bytes() >= context.delta_cache_limit_bytes)
85-
return false;
85+
return AppendResult{false, 0};
8686

8787
size_t new_alloc_block_bytes = 0;
8888
size_t max_capacity = 0;
@@ -97,8 +97,8 @@ bool ColumnFileInMemory::append(
9797
// If the column is not enough, we reserve more space by 1.5 factor
9898
mutable_cache_col->reserveWithStrategy(mutable_cache_col->size() + limit, IColumn::ReserveStrategy::ScaleFactor1_5);
9999
}
100-
max_capacity = std::max(max_capacity, mutable_cache_col->capacity());
101100
mutable_cache_col->insertRangeFrom(*col, offset, limit);
101+
max_capacity = std::max(max_capacity, mutable_cache_col->capacity());
102102
new_alloc_block_bytes += mutable_cache_col->allocatedBytes() - alloc_bytes;
103103
}
104104

@@ -113,7 +113,7 @@ bool ColumnFileInMemory::append(
113113
max_capacity,
114114
rows,
115115
bytes);
116-
return true;
116+
return AppendResult{true, new_alloc_block_bytes};
117117
}
118118

119119
Block ColumnFileInMemory::readDataForFlush() const

0 commit comments

Comments
 (0)