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

Add SnapshotArchiveInfo and refactor functions in snapshot_utils #18232

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Jun 25, 2021

While working on Incremental Snapshots (#17088), I put up an initial PR (#17875) to get ISS working. However, there was a lot of code in that PR, so I'm pulling out smaller chunks to make it easier to review and merge.

This PR adds SnapshotArchiveInfo, refactors functions, and adds tests to snapshot_utils.

@brooksprumo brooksprumo requested a review from lijunwangs June 25, 2021 18:16
@brooksprumo brooksprumo force-pushed the snapshot-utils branch 5 times, most recently from d5402f9 to 1f87a2d Compare June 25, 2021 21:47
@codecov
Copy link

codecov bot commented Jun 27, 2021

Codecov Report

Merging #18232 (e10bfd3) into master (89a3e4f) will increase coverage by 0.2%.
The diff coverage is 92.4%.

@@            Coverage Diff            @@
##           master   #18232     +/-   ##
=========================================
+ Coverage    82.3%    82.6%   +0.2%     
=========================================
  Files         435      435             
  Lines      121424   121554    +130     
=========================================
+ Hits       100020   100408    +388     
+ Misses      21404    21146    -258     

archive_slot: Slot,
archive_hash: Hash,
archive_format: ArchiveFormat,
snapshot_archive_info: SnapshotArchiveInfo,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use reference?

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'm basically just replacing the (destructured) tuple up above at line 56 with this struct. The original version was borrowed/moved, so I just kept it the same. I was under the impression that Rust would optimize away any copies and just perform a move; do you know if there's a performance benefit here for references?

Copy link
Contributor

Choose a reason for hiding this comment

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

I did some experiments and examine the assembly code generated in a site Jeff W. pointed me to -- it does not appear the compiler is doing the move. I still see for each fields pushing to the stack instead of pushing one pointer and referencing the fields by offset later. But I agree you did not make it worse compared with before. And let's just see if you need copy the struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK thanks for checking. I've changed the code to use a reference now.

error!(
"Snapshot has mismatch:\narchive: {:?}\ndeserialized: {:?}",
archive_hash, deserialized_bank_slot_and_hash
snapshot_archive_info.hash, deserialized_bank_slot_and_hash
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe logging (snapshot_archive_info.slot, snapshot_archive_info.hash) makes more sense. 1. it is checked. 2. making the two entries logged symmetric. But I know it exists before your changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, and I agree. I like slot first, then hash second. I'll make this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

}
None
})
.collect(),
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens to the sorting? No longer needed or handled by caller?

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've moved the sorting into its own function (see get_sorted_snapshot_archives() below). This way when a caller doesn't need sorted archives they don't have to pay for the sorting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it's been replaced with get_sorted_snapshot_archives

Copy link
Contributor

Choose a reason for hiding this comment

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

got it

@brooksprumo brooksprumo marked this pull request as ready for review June 29, 2021 00:50
lijunwangs
lijunwangs previously approved these changes Jun 30, 2021
Copy link
Contributor

@lijunwangs lijunwangs left a comment

Choose a reason for hiding this comment

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

Looks good to me

}
None
})
.collect(),
Copy link
Contributor

Choose a reason for hiding this comment

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

got it

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