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

feat: try reading shard_cache if prefetcher blocking_get returns None #8287

Merged

Conversation

pugachAG
Copy link
Contributor

@pugachAG pugachAG commented Jan 4, 2023

This is the second part of #7723: avoid an unnecessary storage lookup from the main thread in the scenario of forks.

@pugachAG pugachAG requested a review from jakmeier January 4, 2023 12:48
self.metrics.prefetch_retry.inc();
self.read_from_db(hash)?
if let Some(value) = self.shard_cache.get(hash) {
value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakmeier do you think it is worth introducing another metric for this case, something like:

self.metrics.prefetch_shared_cache_after_pending.inc();

also suggestions for a better name are welcome :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, yeah I think we can add it. It's exactly these weird corner cases that are hard to debug, having insight with metrics might turn out useful.

For the name, do you mean shard_cache or shared_cache? I think prefetch_shard_cache_after_pending makes more sense to me.

But actually, how about prefetch_pending_conflict, or prefetch_pending_conflict_hit, or prefetch_main_thread_conflict or even just prefetch_conflict?

My thinking is: The request was pending but instead of the expected prefetch-hit afterwards, there was a conflict with "another main thread" that also lead to a hit, but the hit was unexpectedly in shard cache. You name also work though, these are just some suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it meant to be shard_cache, sorry for the typo

prefetch_conflict definitely makes to me, let's use it

@pugachAG pugachAG marked this pull request as ready for review January 4, 2023 12:53
@pugachAG pugachAG requested a review from a team as a code owner January 4, 2023 12:53
@pugachAG pugachAG changed the title feat: try reading shard_cache if prefetcher blocking_get return None feat: try reading shard_cache if prefetcher blocking_get returns None Jan 4, 2023
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, thanks for also finishing the second half of the issue

@pugachAG pugachAG linked an issue Jan 4, 2023 that may be closed by this pull request
@near-bulldozer near-bulldozer bot merged commit 8c3dca9 into near:master Jan 4, 2023
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.

trie prefetcher: cleanup blocking get
2 participants