filecoin-project / filecoin-project/builtin-actors

Don't operate bitfiled object in large loops

Open
#620 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
96
Forks
94
Avg merge
6d 17h
Merged PRs (30d)
3

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.