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

Fix bank coalescing #949

Merged
merged 7 commits into from
Aug 12, 2018
Merged

Conversation

aeyakovenko
Copy link
Member

@aeyakovenko aeyakovenko commented Aug 11, 2018

once transactions are processed, they can't be coalesced since that will break assumptions that every transaction in an entry can be spent independently.

Copy link
Contributor

@garious garious left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! This looks like a great fix and a nice optimization to not deserialize spam. Since it would be quite difficult to test the bug you fixed, let's make this code especially readable, and acknowledge those collect() TODOs while we're in the neighborhood. Comments inline.

.collect(); //TODO: so many allocs
res
})
.collect(); //TODO: so many allocs
Copy link
Contributor

Choose a reason for hiding this comment

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

This collect() doesn't look necessary. This module contains use itertools::Itertools;, so you should be able to call chunk() on the iterator. It's possible you'd have to into_iter(), in which case you can hoist the recycling, which wouldn't be so bad.

if 0 == vers[i] {
None
} else {
//seems like we should only deserialize verified data
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, but instead of this comment, can you copy over the comment on the deserialize_transactions() function you deleted?

deserialize(&x.data[0..x.meta.size]).ok()
}
})
.collect(); //TODO: so many allocs
Copy link
Contributor

Choose a reason for hiding this comment

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

The flap_map() documentation suggests you don't need to collect() here. Looks like it'll fuse any type that can be converted into an iterator.

Copy link
Member Author

Choose a reason for hiding this comment

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

no method named `chunks` found for type `std::iter::FlatMap<std::slice::Iter<'_, (std:
``

debug!("process_transactions");
let transactions: Vec<_> = txs.to_vec(); //TODO: so many allocs
Copy link
Contributor

Choose a reason for hiding this comment

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

Go ahead and make process_transactions() a shim that takes/returns a vector and calls a function that takes/returns an Iterator. See to_file_iter in this module for an example. Then call that new process_transactions_iter().

debug!("done process_transactions");

packet_recycler.recycle(msgs);
//once processed, results cannot be merged, output must be sent even if its smaller than a blob
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please update your comment to look like others in this module? They should be complete sentences and begin with a space and capital letter. Also it's "it's".


packet_recycler.recycle(msgs);
//once processed, results cannot be merged, output must be sent even if its smaller than a blob
let output = results.into_iter().filter_map(|x| x.ok()).collect(); //TODO: so many allocs
Copy link
Contributor

Choose a reason for hiding this comment

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

This collect() cannot be removed. If you agree, can you remove that comment?

.collect();

let count = mms.iter().map(|x| x.1.len()).sum();
let txs: Vec<Transaction> = mms
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move all this to a function called deserialize_verified_transactions()? It should do everything up to and not including process_transactions().

@aeyakovenko
Copy link
Member Author

aeyakovenko commented Aug 11, 2018

@garious there is a better way to do this thing. So in page_table each transaction locks a page. when the blob is emitted we unlock the pages for that blob.

  1. for tx in packet, lock the page associated with the key
  2. do a bunch of stuff
  3. write the valid tx's into a blob
  4. blob is full (or we timer expired..)! for every tx in the blob, unlock the page (this guaranteed that until the blob is ready no conflicting TXs can be scheduled.)

@aeyakovenko aeyakovenko merged commit f07c038 into solana-labs:master Aug 12, 2018
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.

2 participants