Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Rocks db erasure decoding#1900

Merged
carllin merged 15 commits intosolana-labs:masterfrom
carllin:RocksDbErasure
Dec 5, 2018
Merged

Rocks db erasure decoding#1900
carllin merged 15 commits intosolana-labs:masterfrom
carllin:RocksDbErasure

Conversation

@carllin
Copy link
Copy Markdown
Contributor

@carllin carllin commented Nov 24, 2018

Problem

Erasure decoding was relying on the old windows instead of RocksDb.

Summary of Changes

Update decoding of windows to use new RocksDb style ledger. Needs some elements of
#1888 to build, but tests should be passing after that.

Fixes #

@carllin carllin added the work in progress This isn't quite right yet label Nov 24, 2018
@carllin carllin added the noCI Suppress CI on this Pull Request label Nov 24, 2018
Comment thread src/erasure.rs Outdated
pub fn recover(id: &Pubkey, window: &mut [WindowSlot], start_idx: u64, start: usize) -> Result<()> {
let block_start = start - (start % NUM_DATA);
pub fn recover(
id: &Pubkey,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this can be removed by now, I think

Comment thread src/erasure.rs Outdated
assert!(!corrupt, " {} ", id);

Ok(())
assert!(!corrupt, " {} ", id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we have an opportunity to do something about this, now. if we end up with a corrupt blob, let's not put it in the ledger/window?

@carllin carllin removed the noCI Suppress CI on this Pull Request label Nov 25, 2018
Comment thread src/erasure.rs
}

assert!(!corrupt);
if corrupt {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool, but we want to remove or mark as bogus the coding blobs from the ledger? maybe we need a way to say "this is a bogus blob" in the ledger/window...

Copy link
Copy Markdown
Contributor Author

@carllin carllin Nov 26, 2018

Choose a reason for hiding this comment

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

Yeah we can do that. I don't know how you would be able to tell which of the coding blobs/data blobs were the one that caused the decoding to fail though. We could remove all the coding blobs, and then say that sending bad erasures is a penalizable transgression.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeap.

@carllin carllin force-pushed the RocksDbErasure branch 5 times, most recently from 0f23ddb to 967a0b6 Compare November 26, 2018 04:59
Comment thread src/erasure.rs
db_ledger: &mut DbLedger,
slot: u64,
start_idx: u64,
) -> Result<(Vec<SharedBlob>, Vec<SharedBlob>)> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the result?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also, the function comment doesn't seem accurate, it doesn't take a window anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The result is a list of reconstructed data and coding blobs returned to the caller for processing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, yea just could be indicated with a comment or something, I think a reader of the the function wouldn't realize it just reading the signature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For sure, updated the comment

Comment thread src/erasure.rs
for i in b_wl.meta.size..size {
b_wl.data[i] = 0;
// Add the coding blobs we have into the recovery vector, mark the missing ones
for i in coding_start_idx..block_end_idx {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like a lot of logic to duplicate, can be moved into a function?

Comment thread src/erasure.rs Outdated
use db_ledger::DbLedger;
use db_window::{find_missing_coding_indexes, find_missing_data_indexes};
use packet::{Blob, SharedBlob, BLOB_DATA_SIZE, BLOB_HEADER_SIZE};
use result::Result as SolanaResult;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what happened here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The original erasure module used its own version of Result, so I had to import our more generic result under a different name (SolanaResult) in an earlier commit in order to work with it. I ultimately replaced the erasure-specific Result type with the one in result.rs, so this import from the earlier commit can now be deleted.

Comment thread src/erasure.rs Outdated
return Err(ErasureError::InvalidBlobData);
}
Ok(Some(b)) => {
if b.len() <= BLOB_HEADER_SIZE {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we don't support zero-length blobs...

Comment thread src/erasure.rs Outdated
// Mark the missing memory
erasures.push(erasure_index);
blobs.push(SharedBlob::default());
missing.push(blobs.last_mut().unwrap().clone());
Copy link
Copy Markdown
Contributor

@rob-solana rob-solana Nov 27, 2018

Choose a reason for hiding this comment

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

is this more or less code, compiled, than:

let b = Default::default(); blobs.push(b.clone()); missing.push(b);

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's definitely a lot better, yay!

@carllin carllin force-pushed the RocksDbErasure branch 2 times, most recently from a447149 to 848f8e6 Compare December 3, 2018 23:44
Comment thread src/packet.rs
impl Blob {
pub fn new(data: &[u8]) -> Self {
let mut blob = Self::default();
let data_len = cmp::min(data.len(), blob.data.len());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this won't always be zero?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

blob.data is a fixed size array of size 65408, so it shouldn't be

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok, I see. we're gonna assert!() that data is small enough to fit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a check where new() is called in erasure to make sure the data fits.

@carllin carllin force-pushed the RocksDbErasure branch 2 times, most recently from 3f43a6f to 9562b6b Compare December 4, 2018 00:57
@carllin carllin merged commit 9c30bdd into solana-labs:master Dec 5, 2018
@carllin carllin removed the work in progress This isn't quite right yet label Dec 6, 2018
tao-stones added a commit to tao-stones/solana that referenced this pull request Jul 1, 2024
…olana-labs#1888) (solana-labs#1900)

* Refactor and additional metrics for cost tracking (solana-labs#1888)

* Refactor and add metrics:
- Combine remove_* and update_* functions to reduce locking on cost-tracker and iteration.
- Add method to calculate executed transaction cost by directly using actual execution cost and loaded accounts size;
- Wireup histogram to report loaded accounts size;
- Report time of block limits checking;
- Move account counters from ExecuteDetailsTimings to ExecuteAccountsDetails;

* Move committed transactions adjustment into its own function

(cherry picked from commit c3fadac)

* rename cost_tracker.account_data_size to better describe its purpose is to tracker per-block new account allocation

---------

Co-authored-by: Tao Zhu <82401714+tao-stones@users.noreply.github.com>
Co-authored-by: Tao Zhu <tao@solana.com>
tao-stones added a commit to tao-stones/solana that referenced this pull request Jul 1, 2024
yihau pushed a commit to yihau/solana that referenced this pull request Jul 18, 2024
…port of solana-labs#1888) (solana-labs#1900) (solana-labs#1937)

Revert "v2.0: Refactor and additional metrics for cost tracking (backport of solana-labs#1888) (solana-labs#1900)"

This reverts commit 0aef62e.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants