Skip to content

Commit 1981e75

Browse files
authored
Merge 971eba6 into f672e57
2 parents f672e57 + 971eba6 commit 1981e75

File tree

7 files changed

+246
-280
lines changed

7 files changed

+246
-280
lines changed

ydb/core/tablet_flat/benchmark/b_charge.cpp

Lines changed: 0 additions & 153 deletions
This file was deleted.

ydb/core/tablet_flat/benchmark/b_part_index.cpp renamed to ydb/core/tablet_flat/benchmark/b_part.cpp

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace {
4141
return conf;
4242
}
4343

44-
struct TPartIndexSeekFixture : public benchmark::Fixture {
44+
struct TPartEggsFixture : public benchmark::Fixture {
4545
using TGroupId = NPage::TGroupId;
4646

4747
void SetUp(const ::benchmark::State& state)
@@ -84,7 +84,7 @@ namespace {
8484
TGroupId GroupId;
8585
};
8686

87-
struct TPartIndexIteratorFixture : public benchmark::Fixture {
87+
struct TPartSubsetFixture : public benchmark::Fixture {
8888
using TGroupId = NPage::TGroupId;
8989

9090
void SetUp(const ::benchmark::State& state)
@@ -96,6 +96,14 @@ namespace {
9696
Mass = new NTest::TMass(new NTest::TModelStd(groups), history ? 1000000 : 300000);
9797
Subset = TMake(*Mass, PageConf(Mass->Model->Scheme->Families.size(), useBTree)).Mixed(0, 1, TMixerOne{ }, history ? 0.7 : 0);
9898

99+
for (const auto& part : Subset->Flatten) {
100+
Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl;
101+
Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[groups ? 1 : 0], {}) << " BTreeIndexBytes = " << (useBTree ? part->IndexPages.BTreeGroups[groups ? 1 : 0].IndexSize : 0) << Endl;
102+
if (useBTree) {
103+
Cerr << "Levels = " << part->IndexPages.BTreeGroups[groups ? 1 : 0].LevelCount << Endl;
104+
}
105+
}
106+
99107
if (history) {
100108
Checker = new TCheckIt(*Subset, {new TTestEnv()}, TRowVersion(0, 8));
101109
CheckerReverse = new TCheckReverseIt(*Subset, {new TTestEnv()}, TRowVersion(0, 8));
@@ -110,10 +118,11 @@ namespace {
110118
TAutoPtr<TSubset> Subset;
111119
TAutoPtr<TCheckIt> Checker;
112120
TAutoPtr<TCheckReverseIt> CheckerReverse;
121+
TTestEnv Env;
113122
};
114123
}
115124

116-
BENCHMARK_DEFINE_F(TPartIndexSeekFixture, SeekRowId)(benchmark::State& state) {
125+
BENCHMARK_DEFINE_F(TPartEggsFixture, SeekRowId)(benchmark::State& state) {
117126
const bool useBTree = state.range(0);
118127

119128
for (auto _ : state) {
@@ -129,7 +138,7 @@ BENCHMARK_DEFINE_F(TPartIndexSeekFixture, SeekRowId)(benchmark::State& state) {
129138
}
130139
}
131140

132-
BENCHMARK_DEFINE_F(TPartIndexSeekFixture, Next)(benchmark::State& state) {
141+
BENCHMARK_DEFINE_F(TPartEggsFixture, Next)(benchmark::State& state) {
133142
const bool useBTree = state.range(0);
134143

135144
THolder<IIndexIter> iter;
@@ -150,7 +159,7 @@ BENCHMARK_DEFINE_F(TPartIndexSeekFixture, Next)(benchmark::State& state) {
150159
}
151160
}
152161

153-
BENCHMARK_DEFINE_F(TPartIndexSeekFixture, Prev)(benchmark::State& state) {
162+
BENCHMARK_DEFINE_F(TPartEggsFixture, Prev)(benchmark::State& state) {
154163
const bool useBTree = state.range(0);
155164

156165
THolder<IIndexIter> iter;
@@ -171,7 +180,7 @@ BENCHMARK_DEFINE_F(TPartIndexSeekFixture, Prev)(benchmark::State& state) {
171180
}
172181
}
173182

174-
BENCHMARK_DEFINE_F(TPartIndexSeekFixture, SeekKey)(benchmark::State& state) {
183+
BENCHMARK_DEFINE_F(TPartEggsFixture, SeekKey)(benchmark::State& state) {
175184
const bool useBTree = state.range(0);
176185
const ESeek seek = ESeek(state.range(2));
177186

@@ -190,7 +199,7 @@ BENCHMARK_DEFINE_F(TPartIndexSeekFixture, SeekKey)(benchmark::State& state) {
190199
}
191200
}
192201

193-
BENCHMARK_DEFINE_F(TPartIndexIteratorFixture, DoReads)(benchmark::State& state) {
202+
BENCHMARK_DEFINE_F(TPartSubsetFixture, DoReads)(benchmark::State& state) {
194203
const bool reverse = state.range(3);
195204
const ESeek seek = static_cast<ESeek>(state.range(4));
196205
const ui32 items = state.range(5);
@@ -212,39 +221,72 @@ BENCHMARK_DEFINE_F(TPartIndexIteratorFixture, DoReads)(benchmark::State& state)
212221
}
213222
}
214223

215-
BENCHMARK_REGISTER_F(TPartIndexSeekFixture, SeekRowId)
224+
BENCHMARK_DEFINE_F(TPartSubsetFixture, DoCharge)(benchmark::State& state) {
225+
const bool reverse = state.range(3);
226+
const ui32 items = state.range(4);
227+
228+
auto tags = TVector<TTag>();
229+
for (auto c : Subset->Scheme->Cols) {
230+
tags.push_back(c.Tag);
231+
}
232+
TRun run(*Subset->Scheme->Keys);
233+
NTest::TRowTool tool(*Subset->Scheme);
234+
235+
for (auto _ : state) {
236+
auto row1 = Rnd.Uniform(Mass->Saved.Size());
237+
auto row2 = Min(row1 + items, Mass->Saved.Size() - 1);
238+
auto key1 = tool.KeyCells(Mass->Saved[row1]);
239+
auto key2 = tool.KeyCells(Mass->Saved[row2]);
240+
if (reverse) {
241+
ChargeRangeReverse(&Env, key1, key2, run, *Subset->Scheme->Keys, tags, items, 0);
242+
} else {
243+
ChargeRange(&Env, key1, key2, run, *Subset->Scheme->Keys, tags, items, 0);
244+
}
245+
}
246+
}
247+
248+
BENCHMARK_REGISTER_F(TPartEggsFixture, SeekRowId)
216249
->ArgsProduct({
217250
/* b-tree */ {0, 1},
218251
/* groups: */ {0, 1}})
219252
->Unit(benchmark::kMicrosecond);
220253

221-
BENCHMARK_REGISTER_F(TPartIndexSeekFixture, Next)
254+
BENCHMARK_REGISTER_F(TPartEggsFixture, Next)
222255
->ArgsProduct({
223256
/* b-tree */ {0, 1},
224257
/* groups: */ {0, 1}})
225258
->Unit(benchmark::kMicrosecond);
226259

227-
BENCHMARK_REGISTER_F(TPartIndexSeekFixture, Prev)
260+
BENCHMARK_REGISTER_F(TPartEggsFixture, Prev)
228261
->ArgsProduct({
229262
/* b-tree */ {0, 1},
230263
/* groups: */ {0, 1}})
231264
->Unit(benchmark::kMicrosecond);
232265

233-
BENCHMARK_REGISTER_F(TPartIndexSeekFixture, SeekKey)
266+
BENCHMARK_REGISTER_F(TPartEggsFixture, SeekKey)
234267
->ArgsProduct({
235268
/* b-tree */ {0, 1},
236269
/* groups: */ {0, 1},
237-
/* ESeek: */ {0, 1, 2}})
270+
/* ESeek: */ {1}})
238271
->Unit(benchmark::kMicrosecond);
239272

240-
BENCHMARK_REGISTER_F(TPartIndexIteratorFixture, DoReads)
273+
BENCHMARK_REGISTER_F(TPartSubsetFixture, DoReads)
241274
->ArgsProduct({
242275
/* b-tree */ {0, 1},
243276
/* groups: */ {1},
244277
/* history: */ {1},
245278
/* reverse: */ {0},
246279
/* ESeek: */ {1},
247-
/* items */ {1, 10, 100}})
280+
/* items */ {1, 50, 1000}})
281+
->Unit(benchmark::kMicrosecond);
282+
283+
BENCHMARK_REGISTER_F(TPartSubsetFixture, DoCharge)
284+
->ArgsProduct({
285+
/* b-tree */ {0, 1},
286+
/* groups: */ {1},
287+
/* history: */ {1},
288+
/* reverse: */ {0},
289+
/* items */ {1, 50, 1000}})
248290
->Unit(benchmark::kMicrosecond);
249291

250292
}

ydb/core/tablet_flat/benchmark/ya.make

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ SIZE(LARGE)
55
TIMEOUT(1200)
66

77
SRCS(
8-
b_charge.cpp
9-
b_part_index.cpp
8+
b_part.cpp
109
)
1110

1211
PEERDIR(

ydb/core/tablet_flat/flat_part_charge_range.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool ChargeRange(IPages *env, const TCells key1, const TCells key2,
4040
if (r.Overshot && ++pos != run.end()) {
4141
// Unfortunately first key > key2 might be at the start of the next slice
4242
TRowId firstRow = pos->Slice.BeginRowId();
43-
// Precharge the first row on the next slice
44-
ready &= CreateCharge(env, *pos->Part, tags, includeHistory)->Do(firstRow, firstRow, keyDefaults, items, bytes);
43+
// Precharge the first row main key on the next slice
44+
ready &= CreateCharge(env, *pos->Part, { }, false)->Do(firstRow, firstRow, keyDefaults, items, bytes);
4545
}
4646

4747
break;
@@ -98,8 +98,8 @@ bool ChargeRangeReverse(IPages *env, const TCells key1, const TCells key2,
9898
--pos;
9999
// Unfortunately first key <= key2 might be at the end of the previous slice
100100
TRowId lastRow = pos->Slice.EndRowId() - 1;
101-
// Precharge the last row on the previous slice
102-
ready &= CreateCharge(env, *pos->Part, tags, includeHistory)->DoReverse(lastRow, lastRow, keyDefaults, items, bytes);
101+
// Precharge the last row main key on the previous slice
102+
ready &= CreateCharge(env, *pos->Part, { }, false)->DoReverse(lastRow, lastRow, keyDefaults, items, bytes);
103103
}
104104

105105
break;

ydb/core/tablet_flat/test/libs/table/test_part.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace NTest {
148148
namespace IndexTools {
149149
using TGroupId = NPage::TGroupId;
150150

151-
inline size_t CountMainPages(const TPartStore& part) {
151+
inline size_t CountMainPages(const TPart& part) {
152152
size_t result = 0;
153153

154154
TTestEnv env;
@@ -165,20 +165,20 @@ namespace NTest {
165165
return result;
166166
}
167167

168-
inline TRowId GetEndRowId(const TPartStore& part) {
168+
inline TRowId GetEndRowId(const TPart& part) {
169169
TTestEnv env;
170170
TPartIndexIt index(&part, &env, { });
171171
return index.GetEndRowId();
172172
}
173173

174-
inline const TPartIndexIt::TRecord * GetLastRecord(const TPartStore& part) {
174+
inline const TPartIndexIt::TRecord * GetLastRecord(const TPart& part) {
175175
TTestEnv env;
176176
TPartIndexIt index(&part, &env, { });
177177
Y_ABORT_UNLESS(index.SeekLast() == EReady::Data);
178178
return index.GetLastRecord();
179179
}
180180

181-
inline const TPartIndexIt::TRecord * GetRecord(const TPartStore& part, ui32 pageIndex) {
181+
inline const TPartIndexIt::TRecord * GetRecord(const TPart& part, ui32 pageIndex) {
182182
TTestEnv env;
183183
TPartIndexIt index(&part, &env, { });
184184

@@ -190,14 +190,14 @@ namespace NTest {
190190
return index.GetRecord();
191191
}
192192

193-
inline TPageId GetFirstPageId(const TPartStore& part, TGroupId groupId) {
193+
inline TPageId GetFirstPageId(const TPart& part, TGroupId groupId) {
194194
TTestEnv env;
195195
TPartIndexIt index(&part, &env, groupId);
196196
index.Seek(0);
197197
return index.GetPageId();
198198
}
199199

200-
inline TPageId GetLastPageId(const TPartStore& part, TGroupId groupId) {
200+
inline TPageId GetLastPageId(const TPart& part, TGroupId groupId) {
201201
TTestEnv env;
202202
TPartIndexIt index(&part, &env, groupId);
203203
index.Seek(index.GetEndRowId() - 1);

0 commit comments

Comments
 (0)