-
Notifications
You must be signed in to change notification settings - Fork 269
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
load_addresses performance #3182
Conversation
@@ -51,22 +51,20 @@ impl Bank { | |||
.map_err(|_| AddressLoaderError::SlotHashesSysvarNotFound)?; | |||
|
|||
let mut deactivation_slot = u64::MAX; | |||
let loaded_addresses = address_table_lookups | |||
.map(|address_table_lookup| { | |||
let mut loaded_addresses = LoadedAddresses::default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, with some work in higher-level functions, pre-allocate the space for this.
slot_hashes, | ||
)?; | ||
|
||
// Append to the loaded addresses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before appending we should reserve space for the number of pushed elements to avoid potentially triggering multiple allocations while pushing a lot of elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 used reserve
so it will only allocate if necessary.
Problem
Bank::load_addresses
andBank::load_addresses_from_ref
allocate inefficiently:LoadedAddresses
for eachMessageAddressTableLookup
in themessage
LoadedAddresses
viacollect
into a singleLoadedAddresses
Summary of Changes
LoadedAddresses
up front, and load addresses into that table.Fixes #