Skip to content

Commit 0c58e28

Browse files
authored
Merge pull request #747 from evoskuil/master
Hack in point search diagnostics (temporary).
2 parents fc5d81e + 4bc74f3 commit 0c58e28

File tree

4 files changed

+40
-29
lines changed

4 files changed

+40
-29
lines changed

console/executor_scans.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,6 @@ void executor::scan_collisions() const
241241
return map;
242242
};
243243

244-
constexpr auto hash = [](const auto& key)
245-
{
246-
constexpr auto length = array_count<decltype(key)>;
247-
constexpr auto size = std::min(length, sizeof(size_t));
248-
size_t value{};
249-
std::copy_n(key.begin(), size, system::byte_cast(value).begin());
250-
return value;
251-
};
252-
253244
logger(BN_OPERATION_INTERRUPT);
254245

255246
// header & txs (txs is a proxy for validated_bk)
@@ -264,8 +255,11 @@ void executor::scan_collisions() const
264255
while (!cancel_ && (++index < header_records))
265256
{
266257
const header_link link{ possible_narrow_cast<hint>(index) };
267-
++header.at(hash(query_.get_header_key(link.value)) % header_buckets);
268-
++txs.at(hash((header_link::bytes)link) % header_buckets);
258+
const auto key = query_.get_header_key(link.value);
259+
++header.at(database::keys::hash(key) % header_buckets);
260+
++txs.at(database::keys::hash(
261+
link.operator data_array<header_link::size>()) %
262+
header_buckets);
269263

270264
if (is_zero(index % block_frequency))
271265
logger(format("header/txs" BN_READ_ROW) % index %
@@ -317,8 +311,10 @@ void executor::scan_collisions() const
317311
while (!cancel_ && (++index < tx_records))
318312
{
319313
const tx_link link{ possible_narrow_cast<tx_link::integer>(index) };
320-
++tx.at(hash(query_.get_tx_key(link.value)) % tx_buckets);
321-
++strong_tx.at(hash((tx_link::bytes)link) % tx_buckets);
314+
const auto key = query_.get_tx_key(link.value);
315+
++tx.at(database::keys::hash(key) % tx_buckets);
316+
++strong_tx.at(database::keys::hash(
317+
link.operator data_array<tx_link::size>()) % tx_buckets);
322318

323319
if (is_zero(index % tx_frequency))
324320
logger(format("tx & strong_tx" BN_READ_ROW) % index %
@@ -364,8 +360,8 @@ void executor::scan_collisions() const
364360
auto total = zero;
365361
index = max_size_t;
366362
start = logger::now();
367-
const auto spend_buckets = query_.point_buckets();
368-
std_vector<size_t> spend(spend_buckets, empty);
363+
const auto point_buckets = query_.point_buckets();
364+
std_vector<size_t> spend(point_buckets, empty);
369365
while (!cancel_ && (++index < query_.header_records()))
370366
{
371367
const header_link link{ possible_narrow_cast<hint>(index) };
@@ -375,11 +371,12 @@ void executor::scan_collisions() const
375371
const auto points = query_.to_points(transaction);
376372
for (const auto& point: points)
377373
{
374+
const auto key = query_.get_point(point);
375+
++spend.at(database::keys::hash(key) % point_buckets);
378376
++total;
379-
++spend.at(hash(query_.get_point_key(point)) % spend_buckets);
380377

381-
if (is_zero(index % put_frequency))
382-
logger(format("spend" BN_READ_ROW) % total %
378+
if (is_zero(total % put_frequency))
379+
logger(format("point" BN_READ_ROW) % total %
383380
duration_cast<seconds>(logger::now() - start).count());
384381
}
385382
}
@@ -390,18 +387,18 @@ void executor::scan_collisions() const
390387

391388
// ........................................................................
392389

393-
const auto spend_count = count(spend);
390+
const auto point_count = count(spend);
394391
span = duration_cast<seconds>(logger::now() - start);
395-
logger(format("spend: %1% in %2%s buckets %3% filled %4% rate %5%") %
396-
total % span.count() % spend_buckets % spend_count %
397-
(to_double(spend_count) / spend_buckets));
392+
logger(format("point: %1% in %2%s buckets %3% filled %4% rate %5%") %
393+
total % span.count() % point_buckets % point_count %
394+
(to_double(point_count) / point_buckets));
398395

399396
for (const auto& entry: dump(spend))
400-
logger(format("spend: %1% frequency: %2%") %
397+
logger(format("point: %1% frequency: %2%") %
401398
entry.first % entry.second);
402399

403-
spend.clear();
404-
spend.shrink_to_fit();
400+
////point.clear();
401+
////point.shrink_to_fit();
405402
}
406403

407404
} // namespace node

console/executor_test_reader.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ using namespace std::chrono;
4040
using namespace std::placeholders;
4141

4242
// arbitrary testing (const).
43+
void executor::read_test(bool) const
44+
{
45+
logger(format("Point table body searches: %1% / (%2% + %1%)") %
46+
store_.point.positive_search_count() %
47+
store_.point.negative_search_count());
48+
}
49+
50+
#if defined(UNDEFINED)
4351

4452
void executor::read_test(bool dump) const
4553
{
@@ -272,8 +280,6 @@ void executor::read_test(bool dump) const
272280
}
273281
}
274282

275-
#if defined(UNDEFINED)
276-
277283
void executor::read_test(bool) const
278284
{
279285
database::header_link link{ 350'017_u32 };

src/parser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ parser::parser(system::chain::selection context) NOEXCEPT
7171
service::node_witness;
7272

7373
// database (archive)
74+
// Bits cannot be set to the word boundary (32 or 64) as this
75+
// consumes the sentinel into the value domain. The bucket must
76+
// be able to hold a sentinel that is larger than the bucket count.
77+
// This presents a waste problem in the case of 32, since it will
78+
// cause an overflow into 5 byte links and 8 byte buckets. In this
79+
// case modulo bucketization will become more efficient.
7480

7581
configured.database.header_bits = 20;
7682
configured.database.header_size = 21'000'000;

src/protocols/protocol_block_in_31800.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
295295
return true;
296296
}
297297

298-
const auto& link = it->link;
298+
const auto link = it->link;
299299
const auto height = it->context.height;
300300

301301
// Check block.
@@ -366,7 +366,9 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
366366
<< "] from [" << authority() << "].");
367367

368368
notify(ec, chase::checked, height);
369-
fire(events::block_archived, height);
369+
////fire(events::block_archived, height);
370+
fire(events::block_archived, archive().positive_search_count());
371+
fire(events::block_buffered, archive().negative_search_count());
370372
count(block->serialized_size(true));
371373
map_->erase(it);
372374
if (is_idle())

0 commit comments

Comments
 (0)