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

Skip updating prewarm caches on main thread #7203

Merged
merged 3 commits into from
Jun 21, 2024
Merged

Conversation

benaadams
Copy link
Member

Changes

  • Main processing thread should only read from prewarm cache, not spend extra work updating them

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

@LukaszRozmej
Copy link
Member

Does it improve anything? Potentially very small chance of waiting on dictionary? Otherwise, it complicates the code and I don't like it.

@benaadams
Copy link
Member Author

Does it improve anything? Potentially very small chance of waiting on dictionary?

TryGet doesn't use any locks; GetOrAdd does TryGet, then if that fails TryAdd which aquires lock (potentially contending with prewarm) and allocates memory.

However the MainProcessor will never read that value from the prewam cache ever again, so why do the extra work?

_transientStorageProvider = new TransientStorageProvider(logManager);
}

public WorldState(ITrieStore trieStore, IKeyValueStore? codeDb, ILogManager? logManager, PreBlockCaches? preBlockCaches)
: this(trieStore, codeDb, logManager, null, preBlockCaches: preBlockCaches)
public WorldState(ITrieStore trieStore, IKeyValueStore? codeDb, ILogManager? logManager, PreBlockCaches? preBlockCaches, bool populatePreBlockCache = true)
Copy link
Member

Choose a reason for hiding this comment

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

wonder if it would be better to make it false as default and explicitly set true, but not sure

Copy link
Member Author

Choose a reason for hiding this comment

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

Too many locations; unless invert the meaning of the param.

Is only really really true if it also has the preBlockCaches not being null

@benaadams benaadams merged commit 7ad2a52 into master Jun 21, 2024
68 checks passed
@benaadams benaadams deleted the prewarm-main-thread branch June 21, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants