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

Do not hold lock unnecessarily when hashing #24815

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

brooksprumo
Copy link
Contributor

Problem

In Bank::hash_internal_state(), the call to rehash unnecessarily holds the HardForks lock longer than necessary.

Note that the hash::extend_and_hash() function is likely very fast, but we were also holding the lock while performing I/O via the info!() call, which is relatively an eternity.

This investigation was prompted by @buffalu in Discord and their comment here: #24799 (comment)

Summary of Changes

Get the hash data outside of the if let so as to not hold the lock unnecessarily.

@brooksprumo brooksprumo marked this pull request as ready for review April 29, 2022 03:06
@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #24815 (1fb8d59) into master (8ba003a) will increase coverage by 0.1%.
The diff coverage is 89.1%.

@@            Coverage Diff            @@
##           master   #24815     +/-   ##
=========================================
+ Coverage    81.8%    82.0%   +0.1%     
=========================================
  Files         632      598     -34     
  Lines      167499   165559   -1940     
  Branches      322        0    -322     
=========================================
- Hits       137169   135857   -1312     
+ Misses      30217    29702    -515     
+ Partials      113        0    -113     

@jstarry
Copy link
Member

jstarry commented Apr 29, 2022

I'd like to have all the locking fixes backported, any objections?

@t-nelson t-nelson added the automerge Merge this Pull Request automatically once CI passes label Apr 29, 2022
@mergify mergify bot merged commit a73f998 into solana-labs:master Apr 29, 2022
mergify bot pushed a commit that referenced this pull request Apr 29, 2022
mergify bot pushed a commit that referenced this pull request Apr 29, 2022
@brooksprumo brooksprumo deleted the fix-hold-lock-too-long branch April 29, 2022 10:10
mergify bot added a commit that referenced this pull request Apr 29, 2022
(cherry picked from commit a73f998)

Co-authored-by: Brooks Prumo <brooks@solana.com>
mergify bot added a commit that referenced this pull request Apr 29, 2022
(cherry picked from commit a73f998)

Co-authored-by: Brooks Prumo <brooks@solana.com>
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants