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

Trim extra shred bytes in blockstore #16602

Merged
merged 8 commits into from
Apr 27, 2021

Conversation

steviez
Copy link
Contributor

@steviez steviez commented Apr 16, 2021

Problem

Data shred bytestreams are currently inserted into the blockstore with padded 0's. Every data shred has at least some padded 0's due to there being a "restricted" section at the end of a data shred's payload:
https://github.com/solana-labs/solana/blob/master/ledger/src/shred.rs#L44-L50

Furthermore, data shreds that are not filled to capacity with data will have additional 0-padding to get to fill up the packet.

The result of these two items is that the blockstore is getting bloated with extraneous bytes.

Summary of Changes

Trim the extra padding bytes off of the shred on insertion; "re-expand" the bytestream when retrieving from the blockstore to avoid breaking the erasure coding algorithm (which requires that coding and data shreds are of same length).

Fixes #16236

@codecov
Copy link

codecov bot commented Apr 16, 2021

Codecov Report

Merging #16602 (40ed492) into master (8f56c11) will decrease coverage by 0.0%.
The diff coverage is 97.1%.

@@            Coverage Diff            @@
##           master   #16602     +/-   ##
=========================================
- Coverage    82.7%    82.7%   -0.1%     
=========================================
  Files         414      414             
  Lines      115686   115702     +16     
=========================================
+ Hits        95760    95765      +5     
- Misses      19926    19937     +11     

@steviez
Copy link
Contributor Author

steviez commented Apr 19, 2021

@sakridge - I ended up cherry-picking these commits into my own branch since they were failing the CI before; it appears those failures were either unrelated issues that were fixed or a non-deterministic failure.

Regardless of RocksDB vs. AccountsDB, I think we still want this change to keep our backend datastore as slim as possible, right?

Assuming so, thoughts on any additional testing that should be done for validation of this PR? The .resize() on the vector seems like the only thing that could affect performance

Edit: I'm pushing in one more commit to add a comment or two so CI will re-run, but everything had passed:
image

@sakridge
Copy link
Member

@sakridge - I ended up cherry-picking these commits into my own branch since they were failing the CI before; it appears those failures were either unrelated issues that were fixed or a non-deterministic failure.

Regardless of RocksDB vs. AccountsDB, I think we still want this change to keep our backend datastore as slim as possible, right?

Assuming so, thoughts on any additional testing that should be done for validation of this PR? The .resize() on the vector seems like the only thing that could affect performance

Edit: I'm pushing in one more commit to add a comment or two so CI will re-run, but everything had passed:

Yep, we still want it, exactly as you said to keep the db as small as possible.

@steviez steviez marked this pull request as ready for review April 21, 2021 14:41
@steviez steviez requested a review from sakridge April 21, 2021 14:41
@steviez
Copy link
Contributor Author

steviez commented Apr 21, 2021

Here are the performance run results:
https://solanalabs.slack.com/archives/CP2L2S4KV/p1618955757009100

mean_tps: 21020
max_tps: 50685.5
mean_confirmation_ms: 2244
max_confirmation_ms: 20425
99th_percentile_confirmation_ms: 10463
max_tower_distance: 164
last_tower_distance: 63.5
slots_per_second: 2.041

Does seem to be worse than the recent runs on master's latest (which are hitting 55k+ max TPS)

@sakridge
Copy link
Member

Here are the performance run results:
https://solanalabs.slack.com/archives/CP2L2S4KV/p1618955757009100

mean_tps: 21020
max_tps: 50685.5
mean_confirmation_ms: 2244
max_confirmation_ms: 20425
99th_percentile_confirmation_ms: 10463
max_tower_distance: 164
last_tower_distance: 63.5
slots_per_second: 2.041

Does seem to be worse than the recent runs on master's latest (which are hitting 55k+ max TPS)

I think it might be within the noise of this measurement. You could compare the specific insert_shred or the fetch_entries part of replay stats. Those correspond to when we store or read shreds from the db.

@sakridge sakridge requested a review from carllin April 21, 2021 17:43
sakridge
sakridge previously approved these changes Apr 21, 2021
Copy link
Member

@sakridge sakridge left a comment

Choose a reason for hiding this comment

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

lgtm

@steviez
Copy link
Contributor Author

steviez commented Apr 21, 2021

I think it might be within the noise of this measurement. You could compare the specific insert_shred or the fetch_entries part of replay stats. Those correspond to when we store or read shreds from the db.

So I dug a little deeper on this and did a comparison of my run with the previous nightly run. For the next two graphs, the first two humps are the previous two nightly runs; the third hump is my run.

Here is insert:
image
and here is fetch:
image

Digging deeper on the graphana graphs, the data is pretty "jagged" so think I would agree that any observed difference is within the noise, so I'm happy if you are

@carllin
Copy link
Contributor

carllin commented Apr 21, 2021

nit: Summary of Changes section seems to have been cut off 😃

@steviez steviez force-pushed the trim_extra_shred_bytes branch from ea3f8dd to 66c9c61 Compare April 22, 2021 16:09
@mergify mergify bot dismissed sakridge’s stale review April 22, 2021 16:09

Pull request has been modified.

@steviez steviez force-pushed the trim_extra_shred_bytes branch 2 times, most recently from e9017be to 28f7ad8 Compare April 23, 2021 17:22
core/src/serve_repair.rs Outdated Show resolved Hide resolved
@steviez steviez force-pushed the trim_extra_shred_bytes branch 2 times, most recently from 35b4da4 to f25c9f5 Compare April 26, 2021 16:43
@steviez
Copy link
Contributor Author

steviez commented Apr 26, 2021

Would it make more sense to fold this into test_should_insert_data_shred? That way we can also add a test case in test_should_insert_data_shred

Yeah, I think you're right. We already have another similar validity check in should_insert_data_shred and makes sense to check this as early as possible

carllin
carllin previously approved these changes Apr 27, 2021
@steviez steviez force-pushed the trim_extra_shred_bytes branch from f25c9f5 to 40ed492 Compare April 27, 2021 18:27
@mergify mergify bot dismissed carllin’s stale review April 27, 2021 18:28

Pull request has been modified.

@steviez steviez merged commit bc31378 into solana-labs:master Apr 27, 2021
@steviez steviez deleted the trim_extra_shred_bytes branch April 27, 2021 22:42
steviez pushed a commit to steviez/solana that referenced this pull request May 10, 2021
Strip the zero-padding off of data shreds before insertion into blockstore

Co-authored-by: Stephen Akridge <[email protected]>
Co-authored-by: Nathan Hawkins <[email protected]>
steviez pushed a commit to steviez/solana that referenced this pull request May 10, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
steviez pushed a commit to steviez/solana that referenced this pull request May 10, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
steviez pushed a commit to steviez/solana that referenced this pull request May 10, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
carllin pushed a commit to carllin/solana that referenced this pull request May 11, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
carllin pushed a commit to carllin/solana that referenced this pull request May 11, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
carllin pushed a commit to carllin/solana that referenced this pull request May 11, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
steviez pushed a commit to steviez/solana that referenced this pull request May 14, 2021
This is a partial backport of solana-labs#16602 to allow compatibility with that change.
steviez pushed a commit that referenced this pull request May 14, 2021
* Zero pad data shreds on fetch from blockstore

This is a partial backport of #16602 to allow compatibility with that change.

* Remove size check and resize shreds to consistent length
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.

Data shreds are stored with 0 padding in rocksdb
5 participants