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

[Runtime Epoch Split] (4/n) Make ShardTracker accessible from RuntimeWithEpochManagerAdapter. #8769

Merged
merged 3 commits into from
Mar 22, 2023

Conversation

robin-near
Copy link
Contributor

As a reminder of the overall goal, we want to split RuntimeWithEpochManagerAdapter, so that any code that needs the runtime will use an Arc<RuntimeAdapter>, and any code that uses the epoch manager will use the EpochManagerHandle.

We're doing this refactoring bottom-up, i.e. propagating RuntimeWithEpochManagerAdapter around at the top-level, but making some lower-level components use Arc<RuntimeAdapter> and/or EpochManagerHandle.

Now, it turns out that ShardsManager, one of the lower-level components, would need not only EpochManagerHandle, but also an additional ShardTracker built on top of EpochManagerHandle, whose functionality was previously covered by RuntimeWithEpochManagerAdapter interface. ShardTracker is not technically part of EpochManager either, because it isn't inherent to the epoch part of the protocol, but is controlled by the node operator's config options.

ShardTracker is a field of NightshadeRuntime, but is not available in the KeyValueRuntime; instead, the KeyValueRuntime implements all the ShardTracker functionalities via the RuntimeWithEpochManagerAdapter interface. This would not work.

This PR moves ShardTracker to the near-epoch-manager crate, adds an additional shard_tracker() function to RuntimeWithEpochManagerAdapter to allow passing it down from a higher-level component to a lower-level component, and performs a refactoring to make KeyValueRuntime provide the ShardTracker functionality via its EpochManagerAdapter implementation. This also required changing ShardTracker to use EpochManagerAdapter, as opposed to the concrete EpochManagerHandle.

@robin-near robin-near requested a review from a team March 21, 2023 18:14
@robin-near robin-near requested a review from a team as a code owner March 21, 2023 18:14
@robin-near robin-near requested review from akhi3030 and removed request for a team March 21, 2023 18:14
@robin-near robin-near force-pushed the robin-epoch4 branch 3 times, most recently from d28ac14 to 5132a16 Compare March 21, 2023 18:18
@akhi3030
Copy link
Collaborator

@robin-near: do you know if someone from core team will review this or do you want me to find a reviewer for you?

@robin-near
Copy link
Contributor Author

@robin-near: do you know if someone from core team will review this or do you want me to find a reviewer for you?

Hmm, I was expecting the core-team alias to resolve to an engineer. Let me try again.

Base automatically changed from robin-epoch3 to master March 22, 2023 17:02
@robin-near robin-near removed the request for review from akhi3030 March 22, 2023 17:03
Copy link
Contributor

@jakmeier jakmeier left a comment

Choose a reason for hiding this comment

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

LGTM

pub fn new(tracked_config: TrackedConfig, epoch_manager: Arc<dyn EpochManagerAdapter>) -> Self {
ShardTracker {
tracked_config,
tracking_shards_cache: Arc::new(SyncLruCache::new(1024)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you describe in the code why 1024? The number makes sense to me but writing down the basic thought process why 1024 is large enough but also not too small would be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed that - thanks!

@near-bulldozer near-bulldozer bot merged commit 06f3c5f into master Mar 22, 2023
@near-bulldozer near-bulldozer bot deleted the robin-epoch4 branch March 22, 2023 19:42
@robin-near robin-near linked an issue Jul 19, 2023 that may be closed by this pull request
2 tasks
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.

Separate EpochManager from Runtime
3 participants