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

Refactor: thread pool using #1986

Merged
merged 64 commits into from
Feb 28, 2024
Merged

Refactor: thread pool using #1986

merged 64 commits into from
Feb 28, 2024

Conversation

xDimon
Copy link
Member

@xDimon xDimon commented Feb 14, 2024

Referenced issues

Description of the Change

Benefits

Possible Drawbacks

Usage Examples or Tests

Alternate Designs

@xDimon xDimon requested review from turuslan and iceseer February 14, 2024 13:21
outcome::result<WarpSyncProof> getProof(
const primitives::BlockHash &after_hash) const;

void warp(const primitives::BlockInfo &block);

private:
outcome::result<void> cacheMore(primitives::BlockNumber finalized);
outcome::result<void> start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
outcome::result<void> start();
outcome::result<void> startOutcome();

Copy link
Member Author

Choose a reason for hiding this comment

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

Why?

Comment on lines 253 to 254
main_pool_handler,
worker_pool_handler);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

It wont work 'cause arguments have a strict type, and TestThreadPool is not derived of them

Copy link
Contributor

Choose a reason for hiding this comment

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

It works in that branch (also strong type, with constructor(TestThreadPool))

Comment on lines +33 to +34
: is_active_{false}, ioc_{std::move(io_context)} {}
~PoolHandler() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Must be constructed as "active",
or will lose callbacks before AppStateManager calls start()

Suggested change
: is_active_{false}, ioc_{std::move(io_context)} {}
~PoolHandler() = default;
: is_active_{true}, ioc_{std::move(io_context)} {}

Copy link
Member Author

Choose a reason for hiding this comment

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

Making it active is responsibility of using class. To avoid callback loosing, class-owner should start pool handler at 'prepare' phase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fix PoolHandler { is_active_ = true } constructor,
or each class constructor Foo(PoolHandler pool_handler) { pool_handler.start() }?

app_state_manager_->takeControl(*statement_fetching_protocol_.get());

app_state_manager_->takeControl(*send_dispute_protocol_.get());
main_pool_handler_->execute([wp = weak_from_this()] {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing setProtocolHandler

Suggested change
main_pool_handler_->execute([wp = weak_from_this()] {
REINVOKE(main_pool_handler_)

if (enabled_) {
message_pool_ = std::make_shared<MessagePool>(
kTelemetryMessageMaxLengthBytes, kTelemetryMessagePoolSize);
app_state_manager_->takeControl(*this);
} else {
SL_INFO(log_, "Telemetry disabled");
}
}

bool TelemetryServiceImpl::prepare() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool TelemetryServiceImpl::prepare() {
bool TelemetryServiceImpl::prepare() {
REINVOKE(io_context_)

Comment on lines 100 to 103
return true;
}

bool TelemetryServiceImpl::start() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return true;
}
bool TelemetryServiceImpl::start() {

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
…hread pool)

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
@xDimon xDimon force-pushed the refactor/thread_pool_using branch from a1dd273 to 629e7b3 Compare February 20, 2024 14:50
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
@xDimon xDimon enabled auto-merge (squash) February 28, 2024 12:55
@xDimon xDimon merged commit 69e08b4 into master Feb 28, 2024
8 of 10 checks passed
@xDimon xDimon deleted the refactor/thread_pool_using branch February 28, 2024 13:05
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.

3 participants