Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use statistics aggregator for basic statistics #623

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

alexd65536
Copy link
Collaborator

No description provided.

Copy link

github-actions bot commented Dec 21, 2023

Note

This is an automated comment that will be appended during run.

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit cb802c1.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57868 48668 0 15 9133 52

🔴 linux-x86_64-release-asan: some tests FAILED for commit cb802c1.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14090 13949 0 24 87 30

Copy link
Member

@the-ancient-1 the-ancient-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ИМХО важно поправить рандом генератор

optional uint32 NodeId = 1;
optional bool HasStatistics = 2;
optional fixed64 SchemeShardId = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему тут только один? и зачем это отличается от TEvSyncNode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

// nodes -> SA
message TEvSyncNode {
optional uint32 NodeId = 1;
repeated fixed64 SchemeShardIds = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не хватает таймстемпа последней статистики - и тут и при регистрации - если она у ноды есть - ее можно не спешить ей слать

а если нет - надо послать ASAP

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил таймстемпы в протокол

void TStatisticsAggregator::Handle(TEvTabletPipe::TEvServerConnected::TPtr &ev) {
auto pipeServerId = ev->Get()->ServerId;

SA_LOG_D("[" << TabletID() << "] EvServerConnected"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все вызовы SA_LOG_D начинаются с ("[" << TabletID() << "]
как будто стоит сделать это частью макроса

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это лучше поправить отдельным коммитом


if (FastCounter > 0) {
--FastCounter;
SendStatisticsToNode(nodeId, schemeShardId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут точно не пропущен return ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переписал логику

for (const auto& [nodeId, _] : Nodes) {
nodeIds.push_back(nodeId);
}
auto device = std::random_device();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а вот это точно не перебор - каждый раз ходить в аппаратный генератор?
мне кажется это дорого и нужно только в реальной криптографии.

В целом я бы рекомендовал получить обычный быстрый и качественный генератор - mersene twister например mt19937_64, инициировать его чем-то совсем дешевым типа текущего rdtsc однажды и дальше держать в классе aggregator экземпляр rng и когда надо только использовать из него значения например как тут в shuffle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

nodeIds.push_back(nodeId);
}
auto device = std::random_device();
auto rng = std::default_random_engine(device());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и вот тут использовать уже ранее созданный генератор

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

@@ -80,6 +104,27 @@ class TStatisticsAggregator : public TActor<TStatisticsAggregator>, public NTabl

private:
TString Database;

static constexpr size_t StatsOptimizeFirstNodesCount = 3; // optimize first nodes - fast propagation
static constexpr size_t StatsSizeLimitBytes = 40 << 20; // limit for stats size in one message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы по умолчанию сделал 2 мегабайта и правило вида "пока не накопится 2 мегабайта но не менее 1 набора данных"

соображения такие: 2 мегабайта передаются по 10 гигабитной сети целых 16 миллисекунд, а 40 - уже 320. Лучше выстрелить в ноду серией запросов по 16 мс, акторная система скажет спасибо

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сделал 2 мегабайта

@@ -4509,9 +4513,8 @@ void TSchemeShard::StateWork(STFUNC_SIG) {

HFuncTraced(TEvPersQueue::TEvProposeTransactionAttachResult, Handle);

HFuncTraced(TEvPrivate::TEvProcessStatistics, Handle);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти сообщения точно не могут отсылаться/получаться в stable-23-3 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет, в 23-3 этого функционала ещё не было, и туда я не мёрджил

@alexd65536 alexd65536 force-pushed the base_stats_serverless branch from 01734c7 to cb802c1 Compare December 25, 2023 18:42
@alexd65536 alexd65536 merged commit a98ff2b into ydb-platform:main Dec 27, 2023
@jepett0 jepett0 mentioned this pull request Dec 28, 2023
@StekPerepolnen StekPerepolnen mentioned this pull request Dec 29, 2023
Closed
This was referenced Jan 3, 2024
This was referenced Jan 11, 2024
@vitstn vitstn mentioned this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants