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

Don't operate bitfiled object in large loops #620

Open
marco-storswift opened this issue Sep 8, 2022 · 0 comments
Open

Don't operate bitfiled object in large loops #620

marco-storswift opened this issue Sep 8, 2022 · 0 comments

Comments

@marco-storswift
Copy link

marco-storswift commented Sep 8, 2022

Proposal

I add log in buildin-actors, found oprate bitfiled object cast large gas.

Background

I optimize the submitwindowpost message that has recovery work, found some info in optate bitfiled

By example:

operate bitfiled object in large loops:

for sector in &faulty_sectors {
          if on_time_sectors.contains(&sector_number) {
              expiration_set.on_time_sectors.unset(sector_number);
              expiration_set.on_time_pledge -= &sector.initial_pledge;
              removed.on_time_pledge += &sector.initial_pledge;               
          }


}

optimize:

let mut sectors_total = Vec::new();
for sector in &faulty_sectors {
         if on_time_sectors.contains(&sector_number) {
             //expiration_set.on_time_sectors.unset(sector_number);
             sectors_total.push(sector_number);
             expiration_set.on_time_pledge -= &sector.initial_pledge;
             removed.on_time_pledge += &sector.initial_pledge;               
         }
}


 if !sectors_total.is_empty() {
       let on_time_sectors = BitField::try_from_bits(sectors_total)?;
      expiration_set.on_time_sectors -= &on_time;
   }

optimized gasused is very less,
I found many case in expiration_queue module.

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

No branches or pull requests

1 participant