builtin-actors
builtin-actors copied to clipboard
Don't operate bitfiled object in large loops
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(§or_number) {
expiration_set.on_time_sectors.unset(sector_number);
expiration_set.on_time_pledge -= §or.initial_pledge;
removed.on_time_pledge += §or.initial_pledge;
}
}
optimize:
let mut sectors_total = Vec::new();
for sector in &faulty_sectors {
if on_time_sectors.contains(§or_number) {
//expiration_set.on_time_sectors.unset(sector_number);
sectors_total.push(sector_number);
expiration_set.on_time_pledge -= §or.initial_pledge;
removed.on_time_pledge += §or.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.